Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson8_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
7b1a9ab1
authored
Apr 29, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
bc444811
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
my_game.py
my_game.py
View file @
7b1a9ab1
#导包
import
pygame
from
pygame
import
locals
import
random
class
Block
(
pygame
.
sprite
.
Sprite
):
#创建障碍物类
class
Block
(
pygame
.
sprite
.
Sprite
):
#继承精灵
#继承init
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
class
Player
(
pygame
.
sprite
.
Sprite
):
#继承精灵
#继承init
def
__init__
(
self
,
image
):
super
()
.
__init__
()
#随机障碍物
self
.
image
=
image
self
.
rect
=
self
.
image
.
get_rect
()
pygame
.
init
()
# 初始化
# 创建一个窗口
screen
=
pygame
.
display
.
set_mode
((
1000
,
600
))
...
...
@@ -31,9 +42,10 @@ index = 0
y
=
400
jumpState
=
"runing"
t
=
30
GameState
=
'True'
aa
=
Block
(
bush
,
cacti
,
stone
)
while
True
:
while
GameState
==
'True'
:
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
# 接收到退出事件后退出程序
...
...
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