Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson7_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
8e2804a0
authored
Apr 16, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
ee59b50b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
1 deletions
111
111.py
my_game.py
111
0 → 100644
View file @
8e2804a0
import
\ No newline at end of file
111.py
0 → 100644
View file @
8e2804a0
import
pygame
cacti
=
pygame
.
image
.
load
(
'cacti.png'
)
rect
=
cacti
.
get_rect
()
print
(
rect
)
print
(
rect
.
x
)
print
(
rect
.
y
)
print
(
rect
.
width
)
print
(
rect
.
height
)
\ No newline at end of file
my_game.py
View file @
8e2804a0
import
pygame
import
pygame
import
random
from
pygame
import
locals
from
pygame
import
locals
pygame
.
init
()
# 初始化
pygame
.
init
()
# 初始化
...
@@ -21,7 +22,10 @@ wukong_number = 0
...
@@ -21,7 +22,10 @@ wukong_number = 0
sss
=
"running"
sss
=
"running"
t
=
30
t
=
30
y
=
400
y
=
400
si
=
random
.
choice
([
apple
,
cacti
,
stone
])
rect
=
si
.
get_rect
()
rect
.
x
=
1000
rect
.
y
=
500
-
rect
.
height
while
True
:
while
True
:
for
event
in
pygame
.
event
.
get
():
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
if
event
.
type
==
locals
.
QUIT
:
...
@@ -55,5 +59,12 @@ while True:
...
@@ -55,5 +59,12 @@ while True:
screen
.
blit
(
road
,
(
0
,
500
))
screen
.
blit
(
road
,
(
0
,
500
))
screen
.
blit
(
wukong
,
(
150
,
y
))
screen
.
blit
(
wukong
,
(
150
,
y
))
# 刷新画面
# 刷新画面
rect
.
x
-=
8
screen
.
blit
(
si
,(
rect
.
x
,
rect
.
y
))
if
rect
.
x
<
0
-
rect
.
width
:
si
=
random
.
choice
([
apple
,
cacti
,
stone
])
rect
=
si
.
get_rect
()
rect
.
x
=
1000
rect
.
y
=
500
-
rect
.
height
pygame
.
display
.
update
()
pygame
.
display
.
update
()
FPS
.
tick
(
30
)
FPS
.
tick
(
30
)
\ 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