Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson7_diy4
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
8d3a2ce4
authored
Mar 05, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
5c41971a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
lesson8-diy1.py
my_game.py
lesson8-diy1.py
View file @
8d3a2ce4
...
...
@@ -82,9 +82,9 @@ while True:
if
obstacle
.
rect
.
x
<=
0
-
obstacle
.
rect
.
width
:
# 障碍物消失
# 创建障碍物对象
obstacle
=
Block
(
bush
,
stone
,
cacti
)
obstacle
.
rect
=
obstacle
.
get_rect
()
obstacle
.
rect
.
x
=
1000
obstacle
.
rect
.
y
=
500
-
obstacle
.
rect
.
height
#
obstacle.rect = obstacle.get_rect()
#
obstacle.rect.x = 1000
#
obstacle.rect.y = 500 - obstacle.rect.height
obstacle
.
rect
.
x
-=
8
screen
.
blit
(
obstacle
.
image
,
(
obstacle
.
rect
.
x
,
obstacle
.
rect
.
y
))
# 刷新画面
...
...
my_game.py
View file @
8d3a2ce4
...
...
@@ -20,8 +20,8 @@ hero = [pygame.image.load('hero1.png'),
pygame
.
image
.
load
(
'hero4.png'
),
pygame
.
image
.
load
(
'hero5.png'
)]
class
Block
(
pygame
.
sprite
.
Sprite
):
def
_
init
_
(
self
,
image1
,
image2
,
image3
):
super
()
.
_
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
...
...
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