Commit 95332963 by BellCodeEditor

save project

parent 02aff926
Showing with 22 additions and 7 deletions
......@@ -32,6 +32,9 @@ y = 400
jumpState = "runing"
t = 30
aa=Block(bush,cacti,stone)
count = 0
time = 0
block_list = pygame.sprite.Group()
while True:
for event in pygame.event.get():
......@@ -60,9 +63,11 @@ while True:
# 悟空造型
wukong = hero[index]
if jumpState == "runing": # 跑步状态下
index += 1
count += 1
index = count // 6
if index >= 5:
index = 0
count = 0
# 将背景图画上去
shan_x -=2
if shan_x <-1000:
......@@ -74,13 +79,24 @@ while True:
screen.blit(road, (lu_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空
if aa.rect.x <= 0-aa.rect.width: # 障碍物消失
time += 1
if time >= 60:
time = 0
num = random.randint(0,50)
if num > 20:
obstacle = Block(bush,stone,cacti)
block_list.add(obstacle)
for aa in block_list:
# 创建障碍物对象
aa=Block(bush,cacti,stone)
aa.rect.x -= 8
aa.rect.x -= 8
screen.blit(aa.image, (aa.rect.x, aa.rect.y))
if aa.rect.x <= 0-aa.rect.width: # 障碍物消失
aa.kill()
screen.blit(aa.image, (aa.rect.x, aa.rect.y))
# 刷新画面
pygame.display.update()
FPS.tick(60)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment