Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson8_diy3
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
81c8d82a
authored
2 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
d27b41ba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
10 deletions
my_game.py
my_game.py
View file @
81c8d82a
...
...
@@ -32,13 +32,21 @@ y = 400
jumpState
=
"runing"
t
=
30
sb
=
B
(
bush
,
cacti
,
stone
)
sp
=
pygame
.
sprite
.
Group
()
sp
_list
=
pygame
.
sprite
.
Group
()
time
=
0
while
True
:
if
time
=
60
:
time
+=
1
if
time
==
60
:
time
=
0
num
=
random
.
randint
(
0
,
50
)
screen
.
blit
(
sb
.
image
,
(
sb
.
rect
.
x
,
sb
.
rect
.
y
))
num
=
random
.
randint
(
0
,
100
)
if
num
>
40
:
sb
=
B
(
bush
,
cacti
,
stone
)
sp_list
.
add
(
sb
)
for
vk
in
sp_list
:
vk
.
rect
.
x
-=
8
screen
.
blit
(
vk
.
image
,
(
vk
.
rect
.
x
,
vk
.
rect
.
y
))
if
vk
.
rect
.
x
<=
0
-
vk
.
rect
.
width
:
vk
.
kill
()
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
# 接收到退出事件后退出程序
...
...
@@ -79,13 +87,8 @@ while True:
screen
.
blit
(
road
,
(
road_x
,
500
))
# 路
screen
.
blit
(
wukong
,
(
150
,
y
))
# 悟空
if
sb
.
rect
.
x
<=
0
-
sb
.
rect
.
width
:
# 障碍物消失
# 创建障碍物对象
aa
=
B
(
bush
,
cacti
,
stone
)
sb
.
rect
.
x
-=
8
# 刷新画面
pygame
.
display
.
update
()
FPS
.
tick
(
25
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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