Commit 0dbf9488 by BellCodeEditor

save project

parent 4d9f5e18
Showing with 16 additions and 1 deletions
import pygame
from pygame import locals
import random
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
......@@ -22,12 +22,17 @@ k = 0
y = 400
jumpsteat = "running"
t = 30
ob = random.choice([apple,cacti,stone])
re = ob.get_rect()
re_x = 1000
re_y = 500 - re.height
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type == locals.KEYDOWN:
if jumpsteat == "running":
if event.key == locals.K_SPACE:
jumpsteat = "up"
if jumpsteat == "up":
......@@ -49,9 +54,18 @@ while True:
if k>4:
k = 0
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(wukong, (150, y))
if re_x <= 0-re.width:
ob = random.choice(([apple,cacti,stone]))
re = ob.get_rect()
re_x = 1000
re_y = 500 - re.height
re_x -= 8
screen.blit(ob,(re_x,re_y))
# 刷新画面
pygame.display.update()
FPS.tick(60)
\ 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