Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson8_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
8838abdf
authored
Jul 17, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
4aeacfdf
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
17 deletions
my_game.py
record.txt
my_game.py
View file @
8838abdf
...
@@ -4,21 +4,6 @@ import random
...
@@ -4,21 +4,6 @@ import random
import
json
import
json
pygame
.
init
()
# 初始化
pygame
.
init
()
# 初始化
class
Player
(
pygame
.
sprite
.
Sprite
):
#悟空精灵
def
__init__
(
self
,
image
):
super
()
.
__init__
()
self
.
image
=
image
self
.
rect
=
self
.
image
.
get_rect
()
self
.
rect
.
x
=
150
self
.
rect
.
y
=
400
class
Block
(
pygame
.
sprite
.
Sprite
):
#障碍物精灵
def
__init__
(
self
,
image1
,
image2
,
image3
):
super
()
.
__init__
()
self
.
image
=
random
.
choice
([
image1
,
image2
,
image3
])
self
.
rect
=
self
.
image
.
get_rect
()
self
.
rect
.
x
=
1000
self
.
rect
.
y
=
500
-
self
.
rect
.
height
self
.
score
=
1
# 创建一个窗口
# 创建一个窗口
screen
=
pygame
.
display
.
set_mode
((
1000
,
600
))
#窗口
screen
=
pygame
.
display
.
set_mode
((
1000
,
600
))
#窗口
FPS
=
pygame
.
time
.
Clock
()
# pygame时钟,控制游戏速度(帧数)
FPS
=
pygame
.
time
.
Clock
()
# pygame时钟,控制游戏速度(帧数)
...
@@ -35,6 +20,22 @@ hero = [pygame.image.load('hero1.png'),
...
@@ -35,6 +20,22 @@ hero = [pygame.image.load('hero1.png'),
pygame
.
image
.
load
(
'hero3.png'
),
pygame
.
image
.
load
(
'hero3.png'
),
pygame
.
image
.
load
(
'hero4.png'
),
pygame
.
image
.
load
(
'hero4.png'
),
pygame
.
image
.
load
(
'hero5.png'
)]
#悟空造型列表
pygame
.
image
.
load
(
'hero5.png'
)]
#悟空造型列表
class
Player
(
pygame
.
sprite
.
Sprite
):
#悟空精灵
def
__init__
(
self
,
image
):
super
()
.
__init__
()
self
.
image
=
image
self
.
rect
=
self
.
image
.
get_rect
()
self
.
rect
.
x
=
150
self
.
rect
.
y
=
400
class
Block
(
pygame
.
sprite
.
Sprite
):
#障碍物精灵
def
__init__
(
self
,
image1
,
image2
,
image3
):
super
()
.
__init__
()
self
.
image
=
random
.
choice
([
image1
,
image2
,
image3
])
self
.
rect
=
self
.
image
.
get_rect
()
self
.
rect
.
x
=
1000
self
.
rect
.
y
=
500
-
self
.
rect
.
height
self
.
score
=
1
score_audio
=
pygame
.
mixer
.
Sound
(
'score.wav'
)
#得分音效
score_audio
=
pygame
.
mixer
.
Sound
(
'score.wav'
)
#得分音效
old_score
=
0
old_score
=
0
road_x
=
0
road_x
=
0
...
...
record.txt
View file @
8838abdf
{"第1名": 91, "第2名": 86, "第3名": 13}
{"第1名": 91, "第2名": 86, "第3名": 86}
\ 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