Commit 4b431b2e by BellCodeEditor

auto save

parent c6bc7f18
Showing with 16 additions and 11 deletions
import pygame
from pygame import locals
import random
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
pygame.display.set_caption('我是人')
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
a='running'
y=400
t=30
y=500
zaw = random.choice([stone,cacti,apple])
rect = zaw.get_rect()
rect.x = 1000
rect.y = 500-rect.height
# 载入图片
background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路
......@@ -30,7 +36,7 @@ while True:
if event.key==locals.K_SPACE:
a='up'
if a=='up':
if t>0:
if t>=0:
y-=t
t-=2
else:
......@@ -41,15 +47,14 @@ while True:
t+=2
else:
a='running'
t = 30
t=30
if rect.x<=0-rect.width:
zaw = random.choice([stone,cacti,apple])
rect = zaw.get_rect()
rect.x = 1000
rect.y = 500-rect.height
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
......
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