Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson8_diy2
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
9bb266ae
authored
Sep 25, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
0c06206a
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 @
9bb266ae
...
@@ -31,8 +31,10 @@ hero = [pygame.image.load('hero1.png'),
...
@@ -31,8 +31,10 @@ hero = [pygame.image.load('hero1.png'),
pygame
.
image
.
load
(
'hero4.png'
),
pygame
.
image
.
load
(
'hero4.png'
),
pygame
.
image
.
load
(
'hero5.png'
)]
pygame
.
image
.
load
(
'hero5.png'
)]
o
=
Block
(
stone
,
cacti
,
apple
)
#o=Block(stone,cacti,apple)
block_list
=
pygame
.
sprite
.
Group
()
time
=
0
index
=
0
index
=
0
JumpSpeed
=
30
JumpSpeed
=
30
jumpState
=
'runing'
jumpState
=
'runing'
...
@@ -41,14 +43,10 @@ background_x=0
...
@@ -41,14 +43,10 @@ background_x=0
word2
=
0
word2
=
0
nub1
=
0
nub1
=
0
nub
=
0
nub
=
0
gamebegin
=
'go'
y
=
400
y
=
400
while
True
:
while
True
:
if
gamebegin
==
'stop'
:
break
for
event
in
pygame
.
event
.
get
():
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
if
event
.
type
==
locals
.
QUIT
:
...
@@ -109,10 +107,20 @@ while True:
...
@@ -109,10 +107,20 @@ while True:
scoreWord
=
word
.
render
(
info
+
str
(
word2
),
True
,(
255
,
255
,
255
))
scoreWord
=
word
.
render
(
info
+
str
(
word2
),
True
,(
255
,
255
,
255
))
screen
.
blit
(
scoreWord
,
(
730
,
10
))
screen
.
blit
(
scoreWord
,
(
730
,
10
))
if
o
.
rect
.
x
<=
0
-
o
.
rect
.
width
:
time
+=
1
o
=
Block
(
stone
,
cacti
,
apple
)
if
time
==
50
:
o
.
rect
.
x
-=
8
time
=
0
screen
.
blit
(
o
.
image
,(
o
.
rect
.
x
,
o
.
rect
.
y
))
r
=
random
.
randint
(
0
,
100
)
if
r
>
40
:
o
=
Block
(
stone
,
cacti
,
apple
)
block_list
.
add
(
o
)
for
prop
in
block_list
:
prop
.
rect
.
x
-=
8
screen
.
blit
(
prop
.
image
,(
prop
.
rect
.
x
,
prop
.
rect
.
y
))
if
prop
.
rect
.
x
<=
0
-
prop
.
rect
.
width
:
prop
.
kill
()
#if rectNub >= 9 and rect1.x<600 and rect1.x>300 and i==2:
#if rectNub >= 9 and rect1.x<600 and rect1.x>300 and i==2:
# if rect2.x <= 0-rect2.width and nub==2:
# if rect2.x <= 0-rect2.width and nub==2:
# o2=random.choice([stone,cacti,apple])
# o2=random.choice([stone,cacti,apple])
...
...
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