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
b8245204
authored
May 28, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
d4ce2f64
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
17 deletions
my_game.py
ss.py
my_game.py
View file @
b8245204
...
@@ -13,44 +13,46 @@ cacti = pygame.image.load('cacti.png') # 仙人掌
...
@@ -13,44 +13,46 @@ cacti = pygame.image.load('cacti.png') # 仙人掌
apple
=
pygame
.
image
.
load
(
'bush.png'
)
# 灌木丛
apple
=
pygame
.
image
.
load
(
'bush.png'
)
# 灌木丛
hero
=
pygame
.
image
.
load
(
'hero1.png'
)
hero
=
pygame
.
image
.
load
(
'hero1.png'
)
index
=
0
index
=
0
heros
=
[
pygame
.
image
.
load
(
'hero1.png'
),
heros
=
[
pygame
.
image
.
load
(
'hero1.png'
),
pygame
.
image
.
load
(
'hero2.png'
),
pygame
.
image
.
load
(
'hero2.png'
),
pygame
.
image
.
load
(
'hero3.png'
),
pygame
.
image
.
load
(
'hero3.png'
),
pygame
.
image
.
load
(
'hero4.png'
),
pygame
.
image
.
load
(
'hero4.png'
),
pygame
.
image
.
load
(
'hero5.png'
)]
pygame
.
image
.
load
(
'hero5.png'
)]
y
=
400
y
=
400
herostatus
=
"running"
herostatus
=
"running"
t
=
30
while
True
:
while
True
:
for
event
in
pygame
.
event
.
get
():
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
key
==
locals
.
K_SPACE
:
if
event
.
key
==
locals
.
K_SPACE
:
if
herostatus
==
"running"
:
if
herostatus
==
"running"
:
herostatus
=
"jumping"
herostatus
=
"jumping"
print
(
1
)
if
event
.
type
==
locals
.
QUIT
:
if
event
.
type
==
locals
.
QUIT
:
# 接收到退出事件后退出程序
# 接收到退出事件后退出程序
exit
()
exit
()
if
herostatus
==
"jumping"
:
if
herostatus
==
"jumping"
:
y
=
y
-
5
if
y
<
150
:
if
t
>
0
:
y
=
y
-
t
t
=
t
-
2
else
:
herostatus
=
"down"
herostatus
=
"down"
elif
herostatus
==
"down"
:
elif
herostatus
==
"down"
:
y
=
y
+
5
if
t
<=
30
:
if
y
>
400
:
y
=
y
+
t
t
=
t
+
2
else
:
t
=
30
herostatus
=
"running"
herostatus
=
"running"
# 将背景图画上去
# 将背景图画上去
screen
.
blit
(
background
,
(
0
,
0
))
screen
.
blit
(
background
,
(
0
,
0
))
screen
.
blit
(
road
,
(
0
,
500
))
screen
.
blit
(
road
,
(
0
,
500
))
screen
.
blit
(
heros
[
index
],
(
150
,
y
))
screen
.
blit
(
heros
[
index
],
(
150
,
y
))
print
(
y
)
if
herostatus
==
"running"
:
index
=
index
+
1
index
=
index
+
1
if
index
>
4
:
if
index
>
4
:
index
=
0
index
=
0
# 刷新画面
# 刷新画面
pygame
.
display
.
update
()
pygame
.
display
.
update
()
FPS
.
tick
(
15
)
FPS
.
tick
(
60
)
ss.py
0 → 100644
View file @
b8245204
s
=
30
b
=
0
while
True
:
s
=
s
-
2
b
=
b
+
s
if
s
<
0
:
break
print
(
b
)
\ 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