Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson9_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
7a57dcf3
authored
4 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
33ca308c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
my_game.py
my_game.py
View file @
7a57dcf3
import
pygame
import
pygame
from
pygame
import
locals
from
pygame
import
locals
import
random
import
random
import
json
pygame
.
init
()
# 初始化
pygame
.
init
()
# 初始化
# 创建一个窗口
# 创建一个窗口
screen
=
pygame
.
display
.
set_mode
((
1000
,
600
))
screen
=
pygame
.
display
.
set_mode
((
1000
,
600
))
...
@@ -24,6 +25,13 @@ new_score = 0
...
@@ -24,6 +25,13 @@ new_score = 0
old_score
=
0
old_score
=
0
score_music
=
pygame
.
mixer
.
Sound
(
'score.wav'
)
score_music
=
pygame
.
mixer
.
Sound
(
'score.wav'
)
sss
=
pygame
.
font
.
Font
(
'STKAITI.TTF'
,
20
)
sss
=
pygame
.
font
.
Font
(
'STKAITI.TTF'
,
20
)
with
open
(
'record.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
text
:
text_read
=
text
.
read
()
text_loads
=
json
.
loads
(
text_read
)
one
=
text_loads
[
'第1名'
]
two
=
text_loads
[
'第2名'
]
three
=
text_loads
[
'第3名'
]
class
Block
(
pygame
.
sprite
.
Sprite
):
class
Block
(
pygame
.
sprite
.
Sprite
):
def
__init__
(
self
,
image1
,
image2
,
image3
):
def
__init__
(
self
,
image1
,
image2
,
image3
):
super
()
.
__init__
()
super
()
.
__init__
()
...
@@ -115,6 +123,13 @@ while True:
...
@@ -115,6 +123,13 @@ while True:
speed
=
speed
+
new_score
//
3
speed
=
speed
+
new_score
//
3
score_music
.
play
()
score_music
.
play
()
text
=
sss
.
render
(
'SCORE:'
+
str
(
new_score
),
True
,(
0
,
0
,
0
))
text
=
sss
.
render
(
'SCORE:'
+
str
(
new_score
),
True
,(
0
,
0
,
0
))
one_score
=
sss
.
render
(
'第一名:'
+
str
(
one
),
True
,(
0
,
0
,
0
))
two_score
=
sss
.
render
(
'第二名:'
+
str
(
two
),
True
,(
0
,
0
,
0
))
three_score
=
sss
.
render
(
'第三名:'
+
str
(
three
),
True
,(
0
,
0
,
0
))
screen
.
blit
(
text
,(
0
,
0
))
screen
.
blit
(
text
,(
0
,
0
))
screen
.
blit
(
one_score
,(
900
,
0
))
screen
.
blit
(
two_score
,(
900
,
30
))
screen
.
blit
(
three_score
,(
900
,
60
))
pygame
.
display
.
update
()
# 刷新画面
pygame
.
display
.
update
()
# 刷新画面
FPS
.
tick
(
50
)
FPS
.
tick
(
50
)
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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