Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson8_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
b1070a18
authored
Nov 06, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
bc84c8c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
25 deletions
my_game.py
record.txt
my_game.py
View file @
b1070a18
...
...
@@ -85,14 +85,15 @@ obg=Rsc(stone,cacti,apple)
wukong
=
heros
(
hero
[
index
])
blist
=
pygame
.
sprite
.
Group
()
with
open
(
'record.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
cont
=
f
.
read
()
text
=
json
.
loads
(
cont
)
print
(
cont
)
one
=
text
[
'第一名'
]
two
=
text
[
'第二名'
]
three
=
text
[
'第三名'
]
while
True
:
with
open
(
'record.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
cont
=
f
.
read
()
text
=
json
.
loads
(
cont
)
print
(
cont
)
one
=
text
[
'第1名'
]
two
=
text
[
'第2名'
]
three
=
text
[
'第3名'
]
wukong
=
heros
(
hero
[
index
])
if
gametate
==
True
:
time
+=
1
...
...
@@ -103,10 +104,10 @@ while True:
blist
.
add
(
obg
)
time
=
10
s_c
=
score
//
3
speed
=
8
+
s_c
+
p
speed
=
12
+
s_c
+
p
if
IM
==
'running'
:
ind
+=
1
if
ind
>=
5
:
if
ind
>=
3
:
index
+=
1
ind
=
0
if
index
==
5
:
...
...
@@ -122,10 +123,10 @@ while True:
text
[
'第二名'
]
=
score
text
[
'第三名'
]
=
two
else
:
text
[
'第三名'
]
=
thre
e
text
[
'第三名'
]
=
scor
e
text
=
json
.
dumps
(
text
,
ensure_ascii
=
False
)
with
open
(
'record.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
cont
=
f
.
write
(
)
f
.
write
(
text
)
exit
()
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
key
==
locals
.
K_SPACE
:
...
...
@@ -152,6 +153,13 @@ while True:
obg
=
Rsc
(
stone
,
cacti
,
apple
)
blist
.
add
(
obg
)
if
gametate
==
True
:
with
open
(
'record.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
cont
=
f
.
read
()
text
=
json
.
loads
(
cont
)
print
(
cont
)
one
=
text
[
'第一名'
]
two
=
text
[
'第二名'
]
three
=
text
[
'第三名'
]
if
IM
==
'up'
:
y
-=
G
wukong
.
rect
.
y
=
y
...
...
@@ -202,20 +210,22 @@ while True:
pop
.
score
=
0
else
:
screen
.
blit
(
go
,(
400
,
200
))
gametate
=
False
if
score
>
three
:
if
score
>
one
:
text
[
'第一名'
]
=
score
text
[
'第二名'
]
=
one
text
[
'第三名'
]
=
two
elif
score
>
two
:
text
[
'第二名'
]
=
score
text
[
'第三名'
]
=
two
else
:
text
[
'第三名'
]
=
three
gametate
=
False
if
score
>
one
:
text
[
'第一名'
]
=
score
text
[
'第二名'
]
=
one
text
[
'第三名'
]
=
two
if
score
>
two
:
text
[
'第一名'
]
=
one
text
[
'第二名'
]
=
score
text
[
'第三名'
]
=
two
if
score
>
two
:
text
[
'第一名'
]
=
one
text
[
'第二名'
]
=
two
text
[
'第三名'
]
=
score
text
=
json
.
dumps
(
text
,
ensure_ascii
=
False
)
with
open
(
'record.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
cont
=
f
.
write
(
)
f
.
write
(
text
)
else
:
if
(
pop
.
rect
.
x
+
pop
.
rect
.
width
)
<=
wukong
.
rect
.
x
:
score
+=
pop
.
score
...
...
record.txt
View file @
b1070a18
{"第1名": 902, "第2名": 0, "第3名": 0}
\ No newline at end of file
{"第一名": 31, "第二名": 7, "第三名": 5}
\ 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