Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson9_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
9d73df99
authored
Jan 22, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
0367a8c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
5 deletions
my_game.py
record.txt
my_game.py
View file @
9d73df99
...
...
@@ -129,7 +129,7 @@ while True:
sprite
.
kill
()
if
pygame
.
sprite
.
collide_rect
(
wukong
,
sprite
):
# 精灵碰撞检测
gameover
=
pygame
.
image
.
load
(
'gameover.png'
)
# 游戏结束
screen
.
blit
(
gameover
,
(
400
,
200
))
if
die
:
gamestate
=
False
if
score
>
one
:
...
...
@@ -163,4 +163,33 @@ while True:
# 刷新画面
pygame
.
display
.
update
()
FPS
.
tick
(
60
)
\ No newline at end of file
FPS
.
tick
(
60
)
else
:
screen
.
blit
(
gameover
,
(
400
,
200
))
pygame
.
display
.
update
()
for
event
in
pygame
.
event
.
get
():
mouse
=
pygame
.
mouse
.
get_pos
()
mousex
=
mouse
[
0
]
mousey
=
mouse
[
1
]
print
(
mousex
,
mousey
)
if
event
.
type
==
locals
.
QUIT
:
# 接收到退出事件后退出程序
exit
()
if
event
.
type
==
locals
.
MOUSEBUTTONDOWN
:
# if mousex >= 400 and mousex <= 400+206 and mousey >= 200+57 and mousey <= 200:
for
sprite
in
block_list
:
sprite
.
kill
()
if
score
>
one
:
record
[
"第3名"
]
=
record
[
"第2名"
]
record
[
"第2名"
]
=
record
[
"第1名"
]
record
[
"第1名"
]
=
score
elif
score
>
two
:
record
[
"第3名"
]
=
record
[
"第2名"
]
record
[
"第2名"
]
=
score
else
:
record
[
"第3名"
]
=
score
with
open
(
'record.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
json
.
dumps
(
record
,
ensure_ascii
=
False
))
gamestate
=
True
record.txt
View file @
9d73df99
{"第1名": 12, "第2名": 8, "第3名": 7}
\ No newline at end of file
{"第1名": 12, "第2名": 10, "第3名": 9}
\ 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