Commit 77387de3 by BellCodeEditor

save project

parent cca9d15a
Showing with 17 additions and 9 deletions
import pygame
from pygame import locals
import random
pygame.init() # 初始化
# 创建一个窗口
......@@ -19,27 +20,34 @@ hero5 = pygame.image.load('hero5.png')
heroo =[hero1,hero2,hero3,hero4,hero5]
index = 0
y = 400
JS = "runing"
jumpState = "runing"
t=30
obstacle=random.choice([stone,cacti,apple])
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 == locals.KEYDOWN:
if JS=="runing":
if jumpState=="runing":
if event.type == locals.K_SPACE:
JS = "UP"
if JS=="UP":
jumpState = "up"
if jumpState=="up":
if y > 150:
y-=5
y-=t
t-=2
else:
JS = "down"
if JS == "down":
jumpState = "down"
if jumpState == "down":
if y < 400:
y+= 5
y+= t
t+=2
else:
JS = "runing"
jumpState = "runing"
t=30
herooo = heroo[index]
index += 1
if index >= 5:
......
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