Commit c4194eaa by BellCodeEditor

save project

parent 0b77c686
Showing with 9 additions and 8 deletions
import pygame import pygame
from pygame import locals from pygame import locals
pygame.init() # 初始化 pygame.init() # 初始
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 载入图片 # 载入图片
...@@ -19,8 +18,7 @@ hero = [pygame.image.load('hero1.png'), ...@@ -19,8 +18,7 @@ hero = [pygame.image.load('hero1.png'),
index = 0 index = 0
jumpStarte = "runing" jumpStarte = "runing"
y = 400 y = 400
x = 30 t =30
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:
...@@ -30,17 +28,20 @@ while True: ...@@ -30,17 +28,20 @@ while True:
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumeStarte = "up" jumeStarte = "up"
if jumpStarte == "up": if jumpStarte == "up":
if y > 150: if t > 0:
y -= 5 y -= t
t -= 2
else: else:
jumpStarte = "down" jumpStarte = "down"
if jumpStarte == "down": if jumpStarte == "down":
if y < 400: if t <= 30:
y += 5 y += t
t += 2
else: else:
jumpStarte = "runing" jumpStarte = "runing"
wokong = hero[index] wokong = hero[index]
if jumpStarte == "runing":
index += 1 index += 1
if index == 5: if index == 5:
index = 0 index = 0
......
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