Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson9_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
58f628c3
authored
Apr 03, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
b7890fc6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
lesson9-diy2.py
score.txt
lesson9-diy2.py
View file @
58f628c3
...
@@ -132,6 +132,20 @@ while True:
...
@@ -132,6 +132,20 @@ while True:
gameover
=
pygame
.
image
.
load
(
'gameover.png'
)
# 游戏结束
gameover
=
pygame
.
image
.
load
(
'gameover.png'
)
# 游戏结束
screen
.
blit
(
gameover
,
(
400
,
200
))
screen
.
blit
(
gameover
,
(
400
,
200
))
gamestate
=
False
gamestate
=
False
if
score
>
three
:
if
score
>
one
:
score1
[
'第1名'
]
=
score
score1
[
'第2名'
]
=
one
score1
[
'第3名'
]
=
tow
elif
score
>
tow
:
score1
[
'第2名'
]
=
score
score1
[
'第3名'
]
=
tow
else
:
score1
[
'第3名'
]
=
score
score1
=
json
.
dumps
(
score1
,
ensure_ascii
=
False
)
with
open
(
'score.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
score1
)
else
:
else
:
if
(
sprite
.
rect
.
x
+
sprite
.
rect
.
width
)
<
wukong
.
rect
.
x
:
if
(
sprite
.
rect
.
x
+
sprite
.
rect
.
width
)
<
wukong
.
rect
.
x
:
score
+=
sprite
.
score
score
+=
sprite
.
score
...
@@ -150,18 +164,5 @@ while True:
...
@@ -150,18 +164,5 @@ while True:
scoreSurf
=
basic_font
.
render
(
"第3名:"
+
str
(
three
),
True
,
(
255
,
255
,
255
))
scoreSurf
=
basic_font
.
render
(
"第3名:"
+
str
(
three
),
True
,
(
255
,
255
,
255
))
screen
.
blit
(
scoreSurf
,
(
880
,
80
))
screen
.
blit
(
scoreSurf
,
(
880
,
80
))
# 刷新画面
pygame
.
display
.
update
()
pygame
.
display
.
update
()
FPS
.
tick
(
60
)
FPS
.
tick
(
60
)
\ No newline at end of file
score.txt
View file @
58f628c3
{"第1名": 0, "第2名": 0, "第3名": 0}
{"第1名": 59, "第2名": 1, "第3名": 0}
\ No newline at end of file
\ 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