Commit 32a20abf by BellCodeEditor

save project

parent b8245204
Showing with 19 additions and 3 deletions
import random
import pygame
from pygame import locals
index=0
......@@ -13,6 +14,12 @@ cacti = pygame.image.load('cacti.png') # 仙人掌
apple = pygame.image.load('bush.png') # 灌木丛
hero = pygame.image.load('hero1.png')
index = 0
obs=[stone,cacti,apple]
obstacle=random.choice(obs)
rect=obstacle.get_rect()
rect.x=1000
rect.y=500-rect.height
heros=[
pygame.image.load('hero1.png'),
pygame.image.load('hero2.png'),
......@@ -35,13 +42,13 @@ while True:
if t>0:
y=y-t
t=t-2
t=t-1.85
else:
herostatus="down"
elif herostatus=="down":
if t<=30:
y=y+t
t=t+2
t=t+1.85
else:
t=30
herostatus="running"
......@@ -53,6 +60,15 @@ while True:
index=index+1
if index>4:
index=0
if rect.x+rect.width>0:
rect.x=rect.x-15
else:
obs=[stone,cacti,apple]
obstacle=random.choice(obs)
rect=obstacle.get_rect()
rect.x=1000
rect.y=500-rect.height
screen.blit(obstacle, (rect.x, rect.y))
# 刷新画面
pygame.display.update()
FPS.tick(60)
FPS.tick(25)
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