Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson9_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
f16e5530
authored
Jan 13, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
1dd4baea
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
my_game.py
my_game.py
View file @
f16e5530
...
...
@@ -23,8 +23,8 @@ class Player(pygame.sprite.Sprite): # 悟空
self
.
image
=
image
# image的get_rect()方法,可以返回pygame.Rect(0,0,图像宽,图像高)的对象
self
.
rect
=
self
.
image
.
get_rect
()
self
.
rect
.
x
=
150
self
.
rect
.
y
=
400
self
.
rect
.
x
=
150
0
self
.
rect
.
y
=
400
0
# 创建一个窗口
screen
=
pygame
.
display
.
set_mode
((
1000
,
600
))
...
...
@@ -47,13 +47,13 @@ basic_font = pygame.font.Font('STKAITI.TTF', 18) # 字体
index
=
0
y
=
400
jumpState
=
"runing"
t
=
35
t
=
1200
road_x
=
0
bg_x
=
0
time
=
0
gamestate
=
True
score
=
0
speed
=
8
speed
=
99999
old_score
=
score
block_list
=
pygame
.
sprite
.
Group
()
# 创建精灵组
...
...
@@ -85,13 +85,13 @@ while True:
else
:
jumpState
=
"down"
if
jumpState
==
"down"
:
# 降落状态
if
t
<=
35
:
if
t
<=
1200
:
y
+=
t
wukong
.
rect
.
y
=
y
t
+=
2
else
:
jumpState
=
"runing"
t
=
35
t
=
1200
# 将背景图画上去
bg_x
-=
1
...
...
@@ -136,4 +136,4 @@ while True:
# 刷新画面
pygame
.
display
.
update
()
FPS
.
tick
(
60
)
\ No newline at end of file
FPS
.
tick
(
1000
)
\ No newline at end of file
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