Commit 7b1a9ab1 by BellCodeEditor

save project

parent bc444811
Showing with 15 additions and 3 deletions
#导包
import pygame
from pygame import locals
import random
class Block(pygame.sprite.Sprite):
#创建障碍物类
class Block(pygame.sprite.Sprite):#继承精灵
#继承init
def __init__(self,image1,image2,image3):
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):#继承精灵
#继承init
def __init__(self,image):
super().__init__()
#随机障碍物
self.image=image
self.rect=self.image.get_rect()
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
......@@ -31,9 +42,10 @@ index = 0
y = 400
jumpState = "runing"
t = 30
GameState='True'
aa=Block(bush,cacti,stone)
while True:
while GameState=='True':
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
......
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