Commit 223bb35c by BellCodeEditor

save project

parent b9b4515c
Showing with 18 additions and 1 deletions
......@@ -4,6 +4,22 @@ import random
pygame.init() # 初始化
# 创建一个窗口
class Block(pygame.sprite,Sprite):
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.x = 500 - self.rect.height
class Player(pygame.sprite,Sprite):
def__init__(self,image):
super().__init__()
self.image =image
self.rect = self.image.get_rect()
self.rect.x = 150
self.rect.x = 400
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
pygame.display.set_caption("悟空酷跑")
......@@ -27,6 +43,7 @@ rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
time = 0
gamestate
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -36,7 +53,7 @@ while True:
if jumpState == "runing":
if event.key == locals.K_SPACE:
jumpState = "up"
if gamestate == true:
if jumpState == "up": # 起跳状态
if t > 0:
y -= t
......
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