Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson8_diy1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4b658832
authored
Jul 29, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
209cc334
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
5 deletions
my_game.py
my_game.py
View file @
4b658832
...
...
@@ -2,7 +2,7 @@ import pygame
from
pygame
import
locals
import
random
bg
=
pygame
.
display
.
set_mode
(
1000
,
600
)
bg
=
pygame
.
display
.
set_mode
(
(
1000
,
600
)
)
pygame
.
display
.
set_caption
(
"悟空酷跑"
)
background
=
pygame
.
image
.
load
(
'bg.png'
)
# 背景
road
=
pygame
.
image
.
load
(
'road.png'
)
# 路
...
...
@@ -43,15 +43,77 @@ lu.x=0
bg_x
=
0
gamestate
=
True
jingling_list
=
pygame
.
sprite
.
Group
()
my_font
=
pygame
.
font
.
Font
(
'STKAITI.TTF'
,
18
)
'''my_font=pygame.font.Font('STKAITI.TTF',18)'''
while
True
:
for
event
in
pygame
.
event
.
get
():
#检测如果按下退出,就结束
if
event
.
type
==
locals
.
QUIT
:
exit
()
if
event
.
type
==
locals
KEYDOWN
:
if
event
.
key
==
K_up
:
if
jumpstate
==
"up"
:
y
-=
t
t
-
2
if
t
<=
0
:
jumpstate
=
"down"
if
jumpstate
==
"down"
:
y
+=
t
t
+
2
if
t
>=
30
:
jumpstate
=
"run"
bg_x
-=
8
#背景向左移动,到屏幕边缘返回原点
screen
.
blit
(
background
,(
0
,
0
))
if
bg_x
<
-
1000
:
screen
.
blit
(
background
,(
bg_x
,
0
))
if
bg_x
<
=
1000
:
bg_x
=
0
lu_x
-=
8
screen
.
blit
(
rode
,(
lu_x
,
200
))
if
lu_x
<=
1000
:
lu_x
=
0
obstacle
.
rect
.
x
-=
8
screen
.
blit
(
obstacle
,(
obstacle
.
rect
.
x
,
200
))
...
...
@@ -67,7 +129,7 @@ while True:
screen
.
blit
(
aa
.
image
,
(
aa
.
rect
.
x
,
aa
.
rect
.
y
))
# 刷新画面
pygame
.
display
.
update
()
FPS
.
tick
(
60
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment