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
ca10315b
authored
3 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
eba81d69
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
9 deletions
my_game.py
my_game.py
View file @
ca10315b
...
@@ -32,8 +32,9 @@ nu = 30
...
@@ -32,8 +32,9 @@ nu = 30
#获取障碍x,y
#获取障碍x,y
road_x
=
0
road_x
=
0
bg_x
=
0
bg_x
=
0
zhuangzhe
=
Block
(
stone
,
cacti
,
bush
)
time
=
0
#zhuangzhe = Block(stone,cacti,bush)
block_list
=
pygame
.
sprite
.
Group
()
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
:
...
@@ -71,20 +72,34 @@ while True:
...
@@ -71,20 +72,34 @@ while True:
bg_x
-=
1
bg_x
-=
1
if
bg_x
<=
-
1000
:
if
bg_x
<=
-
1000
:
bg_x
=
0
bg_x
=
0
screen
.
blit
(
background
,
(
bg_x
,
0
))
screen
.
blit
(
background
,
(
bg_x
,
0
))
road_x
-=
8
road_x
-=
8
if
road_x
<=
-
1000
:
if
road_x
<=
-
1000
:
road_x
=
0
road_x
=
0
screen
.
blit
(
road
,
(
road_x
,
500
))
screen
.
blit
(
road
,
(
road_x
,
500
))
# 将背景图画上去
# 将背景图画上去
screen
.
blit
(
wukong
,
(
150
,
y
))
screen
.
blit
(
wukong
,
(
150
,
y
))
# 刷新画面
# 刷新画面
if
zhuangzhe
.
rect
.
x
<=
0
-
zhuangzhe
.
rect
.
width
:
#if zhuangzhe.rect.x <= 0-zhuangzhe.rect.width:
zhuangzhe
=
Block
(
stone
,
cacti
,
bush
)
#zhuangzhe = Block(stone,cacti,bush)
zhuangzhe
.
rect
.
x
-=
8
# zhuangzhe.rect.x -= 8
time
+=
1
if
time
>=
60
:
time
=
0
num
=
random
.
randint
(
0
,
100
)
if
num
>
40
:
zhuangzhe
=
Block
(
stone
,
cacti
,
bush
)
block_list
.
add
(
zhuangzhe
)
for
prop
in
block_list
:
prop
.
rect
.
x
-=
8
screen
.
blit
(
prop
.
image
,(
prop
.
rect
.
x
,
prop
.
rect
.
y
))
if
prop
.
rect
.
x
<=
0
-
prop
.
rect
.
width
:
prop
.
kill
()
screen
.
blit
(
zhuangzhe
.
image
,
(
zhuangzhe
.
rect
.
x
,
zhuangzhe
.
rect
.
y
))
#
screen.blit(zhuangzhe.image, (zhuangzhe.rect.x, zhuangzhe.rect.y))
pygame
.
display
.
update
()
pygame
.
display
.
update
()
FPS
.
tick
(
60
)
FPS
.
tick
(
60
)
...
...
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