Commit 58f8da0f by BellCodeEditor

save project

parent 83816a98
Showing with 10 additions and 7 deletions
import pygame
from pygame import locals
import random
pygame.init()
class Block(pygame.sprite.Sprite):
......@@ -35,16 +36,16 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero5.png')]
index = 0
bg_x = 0
road_x = 0
lu_x=0
road_x = 0
y = 400
jumpState = "runing"
t = 30
time = 0
block_list = pygame.sprite.Group()
gamestate = True
block_list = pygame.sprite.Group()
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -54,8 +55,8 @@ while True:
if jumpState == "runing":
if event.key == locals.K_SPACE:
jumpState = "up"
wukong = Player(hero[index])
if jumpState == "runing": # 跑步状态下
wukong = Player(hero[index])
if jumpState == "runing": # 跑步状态下
index += 1
if index >= 5:
index = 0
......@@ -63,12 +64,14 @@ while True:
if jumpState == "up": # 起跳状态
if t > 0:
y -= t
wukong.rect.y = y
t -= 2
else:
jumpState = "down"
if jumpState == "down": # 降落状态
if t <= 30:
y += t
wukong.rect.y = y
t += 2
else:
jumpState = "runing"
......@@ -114,4 +117,4 @@ while True:
#screen.blit(obstacle, (rect.x, rect.y))
# 刷新画面
pygame.display.update()
FPS.tick(60)
\ No newline at end of file
FPS.tick(50)
\ 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