Commit aff6b4f6 by BellCodeEditor

save project

parent c97b323a
Showing with 34 additions and 7 deletions
imprt pygame
from pygame import locals
pygame.init()
screen = pygame.display.set_mode((1000,600))
FPS = pygame.time.Clock()
pygame.dispplay.set_caption("悟空跑酷")
backpround = pygame.image.load('bg.png')
road = pygame.image.load('road.png')
stond = pygame.image.load('stomd.png')
cacti = pygame.image.load('cacty.png')
apple = pygame.image.load('apple.png')
hero = [pygame.image.load('hero1.png')
pygame.image.load('hero2.png')
......@@ -5,31 +15,48 @@ hero = [pygame.image.load('hero1.png')
pygame.image.load('hero4.png')
pygame.image.load('hero5.png')]
index = 0
jumpState = "runing"
y = 400
jumpState = "runing"
t =30
obstacle = random.choice([bush, stond, cacti])
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
if event.type == locaols.K_SPACE:
if jumpState == "runing"
if event.key == locals.K_SPAE:
jumpState = "up"
if jumpStare == "up":
if y > 150:
y -= 5
if t > 0:
y -= t
t -= 2
else:
jumpState = "down":
if jumState == "down":
if y < 400:
y += 5
if t < 30:
y += t
t += 2
else:
jumpState = "runing"
t = 30
wukon = hero[index]
index += 1
if index == 5:
index = 0
screen.blit(background,(0,0))
screen.blit(road,(0,500))
screen.blit(wukong,(150,400))
screen.blit(wukong,(150,t))
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()
FPS.tick(60)
FPS.tick(30)
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