Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson8_diy2
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
56442dc5
authored
Oct 05, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
44c75cb2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
my_game.py
my_game.py
View file @
56442dc5
...
...
@@ -7,8 +7,8 @@ pygame.init() # 初始化
class
Block
(
pygame
.
sprite
.
Sprite
):
def
__init__
(
self
,
image1
,
image2
,
image3
):
super
()
.
__init__
()
self
.
image
=
random
.
choice
([
image1
,
image2
,
image3
])
self
.
rect
=
self
.
image
.
get_rect
()
self
.
image
=
random
.
choice
([
bush
,
stone
,
cacti
])
self
.
rect
.
x
=
1000
self
.
rect
.
y
=
500
-
self
.
rect
.
height
...
...
@@ -32,7 +32,9 @@ index = 0
y
=
400
jumpState
=
"runing"
t
=
30
road_x
=
0
obstacle
=
Block
(
stone
,
cacti
,
bush
)
ground_x
=
0
while
True
:
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
...
...
@@ -67,8 +69,12 @@ while True:
if
road_x
<-
1000
:
road_x
=
0
ground_x
-=
4
if
ground_x
<-
1000
:
ground_x
=
0
# 将背景图画上去
screen
.
blit
(
background
,
(
0
,
0
))
# 远处背景
screen
.
blit
(
background
,
(
ground_x
,
0
))
# 远处背景
screen
.
blit
(
road
,
(
road_x
,
500
))
# 路
screen
.
blit
(
wukong
,
(
150
,
y
))
# 悟空
...
...
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