Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson8_diy4
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
eb56baaf
authored
2 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
0fd8c024
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
5 deletions
my_game.py
my_game.py
View file @
eb56baaf
...
...
@@ -10,7 +10,7 @@ class Block(pygame.sprite.Sprite):
self
.
rect
.
x
=
1000
self
.
rect
.
y
=
500
-
self
.
rect
.
height
class
player
(
pygame
.
sprite
.
Sprite
):
def__init__
(
self
,
image
):
def
__init__
(
self
,
image
):
super
()
.
__init__
()
self
.
image
=
image
self
.
rect
=
self
.
image
.
get_rect
()
...
...
@@ -49,10 +49,9 @@ while True:
if
jumpState
==
"runing"
:
if
event
.
key
==
locals
.
K_SPACE
:
jumpState
=
"up"
if
if
jumpState
==
"up"
:
# 起跳状态
if
t
>
0
:
wukong
.
y
=
y
y
-=
t
t
-=
2
else
:
jumpState
=
"down"
...
...
@@ -65,7 +64,7 @@ while True:
t
=
30
# 悟空造型
wukong
=
player
([
index
])
wukong
=
player
(
hero
[
index
])
if
jumpState
==
"runing"
:
# 跑步状态下
index
+=
1
if
index
>=
5
:
...
...
@@ -79,7 +78,7 @@ while True:
if
lu_x
<-
1000
:
lu_x
=
0
screen
.
blit
(
road
,
(
lu_x
,
500
))
# 路
screen
.
blit
(
wukong
,
(
150
,
y
))
# 悟空
screen
.
blit
(
wukong
.
image
,
(
150
,
y
))
# 悟空
if
obstacle
.
rect
.
x
<=
0
-
obstacle
.
rect
.
width
:
# 障碍物消失
# 创建障碍物对象
...
...
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