Commit 36ae96be by BellCodeEditor

save project

parent 2e442738
Showing with 18 additions and 1 deletions
......@@ -9,6 +9,13 @@ class Block(pygame.sprite.Sprite):
self.rect=self.image.get_rect()
self.rect.x=1000
self.rect.y=500-self.rect.height
class Block(pygame.sprite.Sprite):
def __init__(self,image):
super().__init__()
self.image= image
self.rect=self.image.get_rect()
self.rect.x=150
self.rect.y=400
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
......@@ -31,6 +38,7 @@ index = 0
y = 400
jumpState = "runing"
t = 30
gamestate = True
obstacle=Block(bush,cacti,stone)
time = 0
block_list=pygame.sprite.Group()
......@@ -44,8 +52,9 @@ while True:
if jumpState == "runing":
if event.key == locals.K_SPACE:
jumpState = "up"
if gamestate == True:
if jumpState == "up": # 起跳状态
if t > 0:
y -= t
t -= 2
......@@ -94,6 +103,13 @@ while True:
screen.blit(sprite.image, (sprite.rect.x, sprite.rect.y)
if sprite.rect.x<=0-sprite.rect.width:
sprite.kill()
if pygame.sprite.collide_rect(wukong,sprite):
gameover = pygame.image.load("gameover.png")
screen.blit(gameover,(400,200))
gamestate = False
pygame.display.update()
FPS.tick(60)
\ No newline at end of file
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