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
7d802da1
authored
Mar 27, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
6f28b3dd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletions
my_game.py
my_game.py
View file @
7d802da1
...
@@ -26,7 +26,7 @@ obstacle = random.choice([bush, stone, cacti])
...
@@ -26,7 +26,7 @@ obstacle = random.choice([bush, stone, cacti])
rect
=
obstacle
.
get_rect
()
rect
=
obstacle
.
get_rect
()
rect
.
x
=
1000
rect
.
x
=
1000
rect
.
y
=
500
-
rect
.
height
rect
.
y
=
500
-
rect
.
height
time
=
0
while
True
:
while
True
:
for
event
in
pygame
.
event
.
get
():
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
if
event
.
type
==
locals
.
QUIT
:
...
@@ -70,6 +70,19 @@ while True:
...
@@ -70,6 +70,19 @@ while True:
rect
.
y
=
500
-
rect
.
height
rect
.
y
=
500
-
rect
.
height
rect
.
x
-=
8
rect
.
x
-=
8
screen
.
blit
(
obstacle
,
(
rect
.
x
,
rect
.
y
))
screen
.
blit
(
obstacle
,
(
rect
.
x
,
rect
.
y
))
time
+=
1
if
time
>=
60
:
r
=
random
.
randint
(
0
,
100
)
if
r
>
40
:
obstacle
=
Block
(
bush
,
cacti
,
stone
)
block_list
.
add
(
obstacle
)
for
prop
in
block_list
:
prop
.
rect
.
x
-=
8
screen
.
bilt
(
prop
.
image
,(
prop
.
rect
.
x
.
porp
.
rect
.
y
))
if
porp
.
rect
.
x
<=
0
-
prop
.
rect
.
width
:
prop
.
kill
()
# 刷新画面
# 刷新画面
pygame
.
display
.
update
()
pygame
.
display
.
update
()
FPS
.
tick
(
60
)
FPS
.
tick
(
60
)
\ No newline at end of file
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