Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson8_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
7b33b7ea
authored
Jun 18, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
0577f89a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
16 deletions
my_game.py
qqqqqqqqq.py
my_game.py
View file @
7b33b7ea
...
@@ -3,6 +3,10 @@ from pygame import locals
...
@@ -3,6 +3,10 @@ from pygame import locals
import
random
import
random
asa
=
'541880452'
asa
=
'541880452'
qqq
=
input
(
'Are you SB?'
)
qqq
=
input
(
'Are you SB?'
)
bg_x
=
0
roed_x
=
0
time
=
0
if
qqq
==
asa
:
if
qqq
==
asa
:
pygame
.
init
()
# 初始化
pygame
.
init
()
# 初始化
class
le
(
pygame
.
sprite
.
Sprite
):
class
le
(
pygame
.
sprite
.
Sprite
):
...
@@ -30,6 +34,7 @@ if qqq==asa:
...
@@ -30,6 +34,7 @@ if qqq==asa:
index
=
0
index
=
0
y
=
400
y
=
400
jumpState
=
"runing"
jumpState
=
"runing"
t
=
30
t
=
30
obstacle
=
random
.
choice
([
bush
,
stone
,
cacti
])
obstacle
=
random
.
choice
([
bush
,
stone
,
cacti
])
rect
=
obstacle
.
get_rect
()
rect
=
obstacle
.
get_rect
()
...
@@ -72,18 +77,35 @@ if qqq==asa:
...
@@ -72,18 +77,35 @@ if qqq==asa:
if
index
>=
5
:
if
index
>=
5
:
index
=
0
index
=
0
# 将背景图画上去
# 将背景图画上去
bg
_x
-=
1
if
bg_x
<=-
1000
:
bg_x
=
0
screen
.
blit
(
background
,(
bg_x
,
0
))
roed_x
-=
8
if
roed_x
<=-
1000
:
roed_x
=
0
screen
.
blit
(
roed
,(
roed
,
0
))
screen
.
blit
(
background
,
(
0
,
0
))
# 远处背景
screen
.
blit
(
background
,
(
0
,
0
))
# 远处背景
screen
.
blit
(
road
,
(
0
,
500
))
# 路
screen
.
blit
(
road
,
(
0
,
500
))
# 路
screen
.
blit
(
wukong
,
(
150
,
y
))
# 悟空
screen
.
blit
(
wukong
,
(
150
,
y
))
# 悟空
if
time
>
60
:
r
=
random
.
randint
(
0
,
100
)
if
r
>
40
:
obstacle
=
Block
(
bush
,
cacti
,
stone
)
block_list
.
add
(
obstacle
)
time
=
0
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
rect
.
x
<=
0
-
rect
.
width
:
# 障碍物消失
# 创建障碍物对象
obstacle
=
random
.
choice
([
bush
,
stone
,
cacti
])
rect
=
obstacle
.
get_rect
()
rect
.
x
=
1000
rect
.
y
=
500
-
rect
.
height
rect
.
x
-=
8
screen
.
blit
(
obstacle
,
(
rect
.
x
,
rect
.
y
))
# 刷新画面
# 刷新画面
pygame
.
display
.
update
()
pygame
.
display
.
update
()
FPS
.
tick
(
60
)
FPS
.
tick
(
60
)
print
(
'SB'
)
qqqqqqqqq.py
View file @
7b33b7ea
...
@@ -26,7 +26,7 @@ obstacle = random.choice([bush, stone, cacti])
...
@@ -26,7 +26,7 @@ obstacle = random.choice([bush, stone, cacti])
rect
=
obstacle
.
get_rect
()
rect
=
obstacle
.
get_rect
()
rect
.
x
=
1000
rect
.
x
=
1000
rect
.
y
=
500
-
rect
.
height
rect
.
y
=
500
-
rect
.
height
#block_lisst=
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
:
...
@@ -62,13 +62,9 @@ while True:
...
@@ -62,13 +62,9 @@ while True:
screen
.
blit
(
road
,
(
0
,
500
))
# 路
screen
.
blit
(
road
,
(
0
,
500
))
# 路
screen
.
blit
(
wukong
,
(
150
,
y
))
# 悟空
screen
.
blit
(
wukong
,
(
150
,
y
))
# 悟空
if
rect
.
x
<=
0
-
rect
.
width
:
# 障碍物消失
# 创建障碍物对象
#obstacle = random.choice([bush,stone,cacti])
obstacle
=
random
.
choice
([
bush
,
stone
,
cacti
])
#block_
rect
=
obstacle
.
get_rect
()
rect
.
x
=
1000
rect
.
y
=
500
-
rect
.
height
rect
.
x
-=
8
screen
.
blit
(
obstacle
,
(
rect
.
x
,
rect
.
y
))
screen
.
blit
(
obstacle
,
(
rect
.
x
,
rect
.
y
))
# 刷新画面
# 刷新画面
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