Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson7_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
62e95463
authored
3 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
acef3d97
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
8 deletions
my_game.py
my_game.py
View file @
62e95463
...
@@ -41,12 +41,14 @@ hero = [pygame.image.load('hero1.png'),
...
@@ -41,12 +41,14 @@ hero = [pygame.image.load('hero1.png'),
pygame
.
image
.
load
(
'hero5.png'
)]
pygame
.
image
.
load
(
'hero5.png'
)]
zhang_ai
=
Block
(
stone
,
cacti
,
bush
)
block_list
=
pygame
.
sprite
.
Group
()
#rect = zhang_ai.get_rect()
#rect = zhang_ai.get_rect()
#rect.x=1000
#rect.x=1000
#rect.y = 500-rect.height
#rect.y = 500-rect.height
index
=
0
index
=
0
do
=
0
while
True
:
#不要动
while
True
:
#不要动
wukong
=
hero
[
i
]
#不要动 #不要动 #不要动#不要动#不要动#不要动#不要动#不要动#不要动
wukong
=
hero
[
i
]
#不要动 #不要动 #不要动#不要动#不要动#不要动#不要动#不要动#不要动
...
@@ -94,11 +96,21 @@ while True:
...
@@ -94,11 +96,21 @@ while True:
#障碍:随机,移动
#障碍:随机,移动
if
zhang_ai
.
rect
.
x
<=
0
-
zhang_ai
.
rect
.
width
:
do
+=
1
zhang_ai
=
Block
(
stone
,
cacti
,
bush
)
if
do
>=
60
:
zhang_ai
.
rect
.
x
-=
8
r
=
random
.
randint
(
0
,
100
)
screen
.
blit
(
zhang_ai
.
image
,(
zhang_ai
.
rect
.
x
,
zhang_ai
.
rect
.
y
))
if
r
>
40
:
zhang_ai
=
Block
(
stone
,
cacti
,
bush
)
block_list
.
add
(
zhang_ai
)
do
=
0
for
wu
in
block_list
:
wu
.
rect
.
x
-=
8
screen
.
blit
(
wu
.
image
,(
wu
.
rect
.
x
,
wu
.
rect
.
y
))
if
wu
.
rect
.
x
<=
0
-
wu
.
rect
.
width
:
wu
.
kill
()
print
(
len
(
block_list
))
pygame
.
display
.
update
()
#保存
pygame
.
display
.
update
()
#保存
FPS
.
tick
(
40
)
# 刷新画面
FPS
.
tick
(
60
)
# 刷新画面
\ No newline at end of file
\ 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