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
1a2919f4
authored
Oct 22, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
bea756d4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
my_game.py
my_game.py
View file @
1a2919f4
...
...
@@ -5,8 +5,13 @@ from random import*
pygame
.
init
()
# 初始化
class
class
Block
(
pygame
.
sprite
.
Sprite
):
def
__init__
(
self
,
image1
,
imeage2
,
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
# 创建一个窗口
screen
=
pygame
.
display
.
set_mode
((
1000
,
600
))
FPS
=
pygame
.
time
.
Clock
()
# pygame时钟,控制游戏速度(帧数)
...
...
@@ -82,6 +87,8 @@ while True:
xingzhuang
=
zhangaiwu
.
gut_rest
()
#获得障碍物的坐标和宽,高
xingzhuang
.
x
=
1000
#使障碍物的x为1000
xingzhuang
.
y
=
500
-
xingzhuang
.
height
#初始化障碍物的坐标
time
+=
1
if
time
>=
60
screen
.
blit
(
zhangaiwu
,(
xingzhuang
.
x
,
xingzhuang
.
y
))
...
...
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