Commit 769cf6ba by BellCodeEditor

save project

parent 2591d9ea
Showing with 21 additions and 7 deletions
......@@ -2,7 +2,19 @@ import pygame
from pygame import locals
import random
pygame.init() # 初始化
pygame.init()
class Block(pygame.sprite.spri):
def _init__(self,imagei1,imagei2,imagei3):
super()._init_()
self.image = random.choice([image1,image2,image3])
self.rect = self.image.get_rect()
self.rect.x = 1000
self.rect.y = 500 - self.rect.height
class Player(pygame.sprite.sprite):
def _init_(self,image):
super()._init_()
self.image = image
self.rect = self# 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
......@@ -22,15 +34,11 @@ index = 0
y = 400
jumpState = "runing"
t = 30
obstacle = random.choice([bush, stone, cacti])
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
road_x = 0
bg_x = 0
time = 0
background_x = 0
gamestate = True
block_list =pygame.sprite.Group()
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -40,6 +48,12 @@ while True:
if jumpState == "runing":
if event.key == locals.K_SPACE:
jumpState = "up"
wukong = Player(hero[index])
if jumpState == "runing":
index += 1
if index >= 5:
index = 0
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