Commit 742f53b0 by BellCodeEditor

save project

parent 9a69788a
Showing with 16 additions and 6 deletions
import pygame
from pygame import locals
import random
pygame.init() # 初始
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
......@@ -19,14 +19,19 @@ index = 0
jumpStarte = "runing"
y = 400
t =30
obstacle = random.choice([bush,stone,cacti])
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 event.key == locals.K_SPACE:
jumeStarte = "up"
if jumpStarte == "runing":
if event.key == locals.K_SPACE:
jumeStarte = "up"
if jumpStarte == "up":
if t > 0:
y -= t
......@@ -49,6 +54,12 @@ while True:
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(wokong, (150, y))
# 刷新画面
if rest.x <= 0-rect.width:
obstacle = random.choice([bush,stone,cacti])
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
rect.x = 8# 刷新画面
pygame.display.update()
FPS.tick(60)
\ No newline at end of file
FPS.tick(60)
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