Commit 58f8da0f by BellCodeEditor

save project

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