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
92662126
authored
Oct 30, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
7fdd198f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
18 deletions
my_game.py
my_game.py
View file @
92662126
...
@@ -53,6 +53,10 @@ dw,s=150,0
...
@@ -53,6 +53,10 @@ dw,s=150,0
time
=
0
time
=
0
PS
=
60
PS
=
60
gametate
=
True
gametate
=
True
yy
=
0
yyy
=
8
clock
=
1
l
=
0
class
Rsc
(
pygame
.
sprite
.
Sprite
):
class
Rsc
(
pygame
.
sprite
.
Sprite
):
def
__init__
(
self
,
im1
,
im2
,
im3
):
def
__init__
(
self
,
im1
,
im2
,
im3
):
...
@@ -74,8 +78,8 @@ blist=pygame.sprite.Group()
...
@@ -74,8 +78,8 @@ blist=pygame.sprite.Group()
while
True
:
while
True
:
wukong
=
heros
(
hero
[
index
])
wukong
=
heros
(
hero
[
index
])
print
(
G
)
print
(
clock
)
time
+=
1
time
+=
0.5
*
clock
if
time
>=
60
:
if
time
>=
60
:
a
=
randint
(
1
,
60
)
a
=
randint
(
1
,
60
)
if
a
>=
20
:
if
a
>=
20
:
...
@@ -103,13 +107,6 @@ while True:
...
@@ -103,13 +107,6 @@ while True:
if
IM
!=
'running'
and
I_M
>=
1
:
if
IM
!=
'running'
and
I_M
>=
1
:
if
event
.
key
==
locals
.
K_w
:
if
event
.
key
==
locals
.
K_w
:
IM
=
'dup'
IM
=
'dup'
I_M
=
0
G
+=
2
if
index
<=
4
:
index
+=
1
if
index
==
5
:
index
=
1
dws
=
150
,
y
if
gametate
==
True
:
if
gametate
==
True
:
if
IM
==
'up'
:
if
IM
==
'up'
:
y
-=
G
y
-=
G
...
@@ -118,7 +115,8 @@ while True:
...
@@ -118,7 +115,8 @@ while True:
if
G
<=
-
42
:
if
G
<=
-
42
:
IM
=
'running'
IM
=
'running'
G
=
40
G
=
40
if
IM
==
'dup'
:
wukong
.
rect
.
y
=
75
# if IM=='down':
# if IM=='down':
# if G==0:
# if G==0:
# y+=G
# y+=G
...
@@ -136,11 +134,11 @@ while True:
...
@@ -136,11 +134,11 @@ while True:
herorun
=
hero
[
index
]
herorun
=
hero
[
index
]
# 将背景图画上去
# 将背景图画上去
bg_x
-=
1
bg_x
-=
(
2
+
0.25
*
clock
)
if
bg_x
<=-
1000
:
if
bg_x
<=-
1000
:
bg_x
=
0
bg_x
=
0
screen
.
blit
(
bg
,
(
bg_x
,
0
))
screen
.
blit
(
bg
,
(
bg_x
,
0
))
rond_x
-=
8
rond_x
-=
(
8
+
0.5
*
clock
)
if
rond_x
<=
-
1000
:
if
rond_x
<=
-
1000
:
rond_x
=
0
rond_x
=
0
screen
.
blit
(
road
,
(
rond_x
,
500
))
screen
.
blit
(
road
,
(
rond_x
,
500
))
...
@@ -148,16 +146,15 @@ while True:
...
@@ -148,16 +146,15 @@ while True:
# if obg.rect.x<0-obg.rect.height:
# if obg.rect.x<0-obg.rect.height:
# obg=Rsc(stone,cacti,apple)
# obg=Rsc(stone,cacti,apple)
for
pop
in
blist
:
for
pop
in
blist
:
pop
.
rect
.
x
-=
8
pop
.
rect
.
x
-=
(
8
+
clock
)
screen
.
blit
(
pop
.
image
,(
pop
.
rect
.
x
,
pop
.
rect
.
y
))
screen
.
blit
(
pop
.
image
,(
pop
.
rect
.
x
,
pop
.
rect
.
y
))
if
pygame
.
sprite
.
collide_rect
(
wukong
,
pop
):
if
pygame
.
sprite
.
collide_rect
(
wukong
,
pop
):
screen
.
blit
(
go
,(
400
,
200
))
screen
.
blit
(
go
,(
400
,
200
))
gametate
=
False
gametate
=
False
for
event
in
pygame
.
event
.
get
():
else
:
if
event
.
type
==
locals
.
KEYDOWN
:
if
(
pop
.
rect
.
x
+
pop
.
rect
.
y
)
<
wukong
.
rect
.
x
-
wukong
.
rect
.
height
:
if
event
.
key
==
locals
.
K_r
:
clock
+=
0.1
gametate
=
True
pygame
.
sprite
.
kill
(
pop
)
# 刷新画面
# 刷新画面
pygame
.
display
.
update
()
pygame
.
display
.
update
()
...
...
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