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
f14e2b25
authored
Apr 23, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
881a8236
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
my_game.py
my_game.py
View file @
f14e2b25
...
@@ -30,22 +30,25 @@ class Block(pygame.sprite.Sprite):
...
@@ -30,22 +30,25 @@ class Block(pygame.sprite.Sprite):
self
.
rect
=
self
.
image
.
get_rect
()
self
.
rect
=
self
.
image
.
get_rect
()
self
.
rect
.
x
=
1000
+
self
.
rect
.
width
self
.
rect
.
x
=
1000
+
self
.
rect
.
width
self
.
rect
.
y
=
500
-
self
.
rect
.
height
self
.
rect
.
y
=
500
-
self
.
rect
.
height
blocks
=
Block
(
grass
,
hole
,
stone
,
bush
,
cacti
)
blocks
=
Block
(
grass
,
hole
,
stone
,
bush
,
cacti
)
clocks
=
Block
(
grass
,
hole
,
stone
,
bush
,
cacti
)
clocks
.
rect
.
x
+=
400
+
random
.
randint
(
-
400
,
400
)
while
True
:
while
True
:
##Shadow
shadow
=
1
if
blocks
.
rect
.
x
-
450
<=
100
and
state
!=
"down"
:
state
=
"up"
shadow
=
0
##Keys
##Keys
for
event
in
pygame
.
event
.
get
():
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
if
event
.
type
==
locals
.
QUIT
:
exit
()
exit
()
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
type
==
locals
.
KEYDOWN
and
shadow
==
1
:
if
state
==
"moving"
and
event
.
key
==
locals
.
K_UP
:
if
state
==
"moving"
and
event
.
key
==
locals
.
K_UP
:
state
=
"up"
state
=
"up"
if
state
==
"down"
and
event
.
key
==
locals
.
K_DOWN
:
if
state
==
"down"
and
event
.
key
==
locals
.
K_DOWN
:
pass
pass
##Shadow
if
blocks
.
rect
.
x
-
350
<=
50
:
state
=
"up"
##Action
##Action
if
state
==
"up"
:
if
state
==
"up"
:
if
t
>
0
:
if
t
>
0
:
...
@@ -72,13 +75,17 @@ while True:
...
@@ -72,13 +75,17 @@ while True:
i
=
0
i
=
0
if
blocks
.
rect
.
x
<
0
-
blocks
.
rect
.
width
:
if
blocks
.
rect
.
x
<
0
-
blocks
.
rect
.
width
:
blocks
=
Block
(
grass
,
hole
,
stone
,
bush
,
cacti
)
blocks
=
Block
(
grass
,
hole
,
stone
,
bush
,
cacti
)
##Play
blocks
.
rect
.
x
-=
30
blocks
.
rect
.
x
-=
30
if
clocks
.
rect
.
x
<
0
-
clocks
.
rect
.
width
:
clocks
=
Block
(
grass
,
hole
,
stone
,
bush
,
cacti
)
clocks
.
rect
.
x
+=
400
+
random
.
randint
(
-
400
,
400
)
clocks
.
rect
.
x
-=
30
##Play
screen
.
blit
(
background
,
(
bg_x
,
0
))
screen
.
blit
(
background
,
(
bg_x
,
0
))
screen
.
blit
(
road
,
(
road_x
,
500
))
screen
.
blit
(
road
,
(
road_x
,
500
))
screen
.
blit
(
heroes
[
i
],
(
150
,
y
))
screen
.
blit
(
heroes
[
i
],
(
150
,
y
))
screen
.
blit
(
blocks
.
image
,(
blocks
.
rect
.
x
,
blocks
.
rect
.
y
))
screen
.
blit
(
blocks
.
image
,(
blocks
.
rect
.
x
,
blocks
.
rect
.
y
))
screen
.
blit
(
clocks
.
image
,(
clocks
.
rect
.
x
,
clocks
.
rect
.
y
))
pygame
.
display
.
update
()
pygame
.
display
.
update
()
FPS
.
tick
(
20
)
FPS
.
tick
(
20
)
\ 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