Commit 555886d6 by BellCodeEditor

auto save

parent 53d838d6
Showing with 6 additions and 8 deletions
import pygame
from pygame import locals
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
pygame.display.set_caption("悟空跑酷")
# 载入图片
background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路
......@@ -17,10 +17,10 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
index = 0
y = 400
jumpState = "runing"
y = 400
t = 30
stone_x = 1000
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -30,14 +30,12 @@ while True:
if jumpState =="runing":
if event.key == locals.K_SPACE:
jumpState = "up"
if jumpState == "up":
if t > 0:
y -= t
t -= 2
else:
jumpState = "down"
t = 30
if jumpState == "down":
if t <= 30:
y += t
......@@ -45,8 +43,8 @@ while True:
else:
jumpState = "runing"
t = 30
wukong = hero[index]
wukong = hero[index]
if jumpState =="runing":
index += 1
if index == 5:
......@@ -55,8 +53,7 @@ while True:
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(wukong, (150, y))
stone_x -= 5
screen.blit(stone,(stone_x,400))
#screen.blit(stone,(stone_x,400))
# 刷新画面
pygame.display.update()
FPS.tick(30)
\ 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