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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
16 deletions
my_game.py
record.txt
my_game.py
View file @
b1070a18
...
@@ -85,14 +85,15 @@ obg=Rsc(stone,cacti,apple)
...
@@ -85,14 +85,15 @@ obg=Rsc(stone,cacti,apple)
wukong
=
heros
(
hero
[
index
])
wukong
=
heros
(
hero
[
index
])
blist
=
pygame
.
sprite
.
Group
()
blist
=
pygame
.
sprite
.
Group
()
while
True
:
with
open
(
'record.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
with
open
(
'record.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
cont
=
f
.
read
()
cont
=
f
.
read
()
text
=
json
.
loads
(
cont
)
text
=
json
.
loads
(
cont
)
print
(
cont
)
print
(
cont
)
one
=
text
[
'第1名'
]
one
=
text
[
'第一名'
]
two
=
text
[
'第2名'
]
two
=
text
[
'第二名'
]
three
=
text
[
'第3名'
]
three
=
text
[
'第三名'
]
while
True
:
wukong
=
heros
(
hero
[
index
])
wukong
=
heros
(
hero
[
index
])
if
gametate
==
True
:
if
gametate
==
True
:
time
+=
1
time
+=
1
...
@@ -103,10 +104,10 @@ while True:
...
@@ -103,10 +104,10 @@ while True:
blist
.
add
(
obg
)
blist
.
add
(
obg
)
time
=
10
time
=
10
s_c
=
score
//
3
s_c
=
score
//
3
speed
=
8
+
s_c
+
p
speed
=
12
+
s_c
+
p
if
IM
==
'running'
:
if
IM
==
'running'
:
ind
+=
1
ind
+=
1
if
ind
>=
5
:
if
ind
>=
3
:
index
+=
1
index
+=
1
ind
=
0
ind
=
0
if
index
==
5
:
if
index
==
5
:
...
@@ -122,10 +123,10 @@ while True:
...
@@ -122,10 +123,10 @@ while True:
text
[
'第二名'
]
=
score
text
[
'第二名'
]
=
score
text
[
'第三名'
]
=
two
text
[
'第三名'
]
=
two
else
:
else
:
text
[
'第三名'
]
=
thre
e
text
[
'第三名'
]
=
scor
e
text
=
json
.
dumps
(
text
,
ensure_ascii
=
False
)
text
=
json
.
dumps
(
text
,
ensure_ascii
=
False
)
with
open
(
'record.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
with
open
(
'record.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
cont
=
f
.
write
(
)
f
.
write
(
text
)
exit
()
exit
()
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
key
==
locals
.
K_SPACE
:
if
event
.
key
==
locals
.
K_SPACE
:
...
@@ -152,6 +153,13 @@ while True:
...
@@ -152,6 +153,13 @@ while True:
obg
=
Rsc
(
stone
,
cacti
,
apple
)
obg
=
Rsc
(
stone
,
cacti
,
apple
)
blist
.
add
(
obg
)
blist
.
add
(
obg
)
if
gametate
==
True
:
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'
:
if
IM
==
'up'
:
y
-=
G
y
-=
G
wukong
.
rect
.
y
=
y
wukong
.
rect
.
y
=
y
...
@@ -203,19 +211,21 @@ while True:
...
@@ -203,19 +211,21 @@ while True:
else
:
else
:
screen
.
blit
(
go
,(
400
,
200
))
screen
.
blit
(
go
,(
400
,
200
))
gametate
=
False
gametate
=
False
if
score
>
three
:
if
score
>
one
:
if
score
>
one
:
text
[
'第一名'
]
=
score
text
[
'第一名'
]
=
score
text
[
'第二名'
]
=
one
text
[
'第二名'
]
=
one
text
[
'第三名'
]
=
two
text
[
'第三名'
]
=
two
elif
score
>
two
:
if
score
>
two
:
text
[
'第一名'
]
=
one
text
[
'第二名'
]
=
score
text
[
'第二名'
]
=
score
text
[
'第三名'
]
=
two
text
[
'第三名'
]
=
two
else
:
if
score
>
two
:
text
[
'第三名'
]
=
three
text
[
'第一名'
]
=
one
text
[
'第二名'
]
=
two
text
[
'第三名'
]
=
score
text
=
json
.
dumps
(
text
,
ensure_ascii
=
False
)
text
=
json
.
dumps
(
text
,
ensure_ascii
=
False
)
with
open
(
'record.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
with
open
(
'record.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
cont
=
f
.
write
(
)
f
.
write
(
text
)
else
:
else
:
if
(
pop
.
rect
.
x
+
pop
.
rect
.
width
)
<=
wukong
.
rect
.
x
:
if
(
pop
.
rect
.
x
+
pop
.
rect
.
width
)
<=
wukong
.
rect
.
x
:
score
+=
pop
.
score
score
+=
pop
.
score
...
...
record.txt
View file @
b1070a18
{"第1名": 902, "第2名": 0, "第3名": 0}
{"第一名": 31, "第二名": 7, "第三名": 5}
\ 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