Commit e814e6ed by BellCodeEditor

auto save

parent 2742489a
Showing with 15 additions and 3 deletions
import pygame
from pygame import locals
import random
pygame.init()
class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3):
super().__init__()
......@@ -9,7 +9,6 @@ class Block(pygame.sprite.Sprite):
self.rect=self.image.get_rect()
self.rect.x=1000
self.rect.y=500-self.rect.height
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
......@@ -32,7 +31,9 @@ y = 400
jumpState = "runing"
t = 30
aa=Block(bush,cacti,stone)
bg_x=0
road_x=0
obstacle = Block(bush,cacti,stone)
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -42,6 +43,17 @@ while True:
if jumpState == "runing":
if event.key == locals.K_SPACE:
jumpState = "up"
if obstacle.rect.x<= 0-obstacle.rect.width:
obstacle = Block(bush,cacti,stone)
obstacle.rect.x -=8
bg_x-=1
if bg_x<= -1000:
bg_x=0
screen.blit(background,(bg_x,0))
road_x -= 8
if road_x <= -1000:
road_x = 0
screen.blit(road,(road_x,500))
if jumpState == "up": # 起跳状态
if t > 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