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
c087d118
authored
Sep 23, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
d11f9cb5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
my_game.py
my_game.py
View file @
c087d118
...
@@ -14,6 +14,7 @@ pygame.init() # 初始化
...
@@ -14,6 +14,7 @@ pygame.init() # 初始化
screen
=
pygame
.
display
.
set_mode
((
1000
,
600
))
screen
=
pygame
.
display
.
set_mode
((
1000
,
600
))
FPS
=
pygame
.
time
.
Clock
()
# pygame时钟,控制游戏速度(帧数)
FPS
=
pygame
.
time
.
Clock
()
# pygame时钟,控制游戏速度(帧数)
pygame
.
display
.
set_caption
(
"悟空酷跑"
)
pygame
.
display
.
set_caption
(
"悟空酷跑"
)
block_list
=
pygame
.
sprite
.
Group
()
# 载入图片
# 载入图片
background
=
pygame
.
image
.
load
(
'bg.png'
)
# 背景
background
=
pygame
.
image
.
load
(
'bg.png'
)
# 背景
road
=
pygame
.
image
.
load
(
'road.png'
)
# 路
road
=
pygame
.
image
.
load
(
'road.png'
)
# 路
...
@@ -76,11 +77,18 @@ while True:
...
@@ -76,11 +77,18 @@ while True:
screen
.
blit
(
road
,
(
road_x
,
500
))
# 路
screen
.
blit
(
road
,
(
road_x
,
500
))
# 路
screen
.
blit
(
wukong
,
(
150
,
y
))
# 悟空
screen
.
blit
(
wukong
,
(
150
,
y
))
# 悟空
if
things
.
rect
.
x
<=
0
-
things
.
rect
.
width
:
# 障碍物消失
#
if things.rect.x <= 0-things.rect.width: # 障碍物消失
# 创建障碍物对象
#
# 创建障碍物对象
things
=
Block
(
bush
,
cacti
,
stone
)
#
things = Block(bush,cacti,stone)
things
.
rect
.
x
-=
8
#
things.rect.x -= 8
block_list
.
add
(
things
.
image
)
for
i
in
block_list
:
if
things
.
rect
.
x
<
0
-
things
.
rect
.
width
:
things
.
rect
.
x
-=
8
screen
.
blit
(
things
.
image
,
(
things
.
rect
.
x
,
things
.
rect
.
y
))
screen
.
blit
(
things
.
image
,
(
things
.
rect
.
x
,
things
.
rect
.
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