Commit 73b1c727 by BellCodeEditor

save project

parent 4c568fe8
Showing with 13 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 Plaver(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))
......@@ -34,6 +41,7 @@ t = 30
road_x=0
bg_x=0
time=0
gamestate=True
block_list=pygame.sprite.Group()
while True:
......@@ -45,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
......@@ -88,6 +96,10 @@ 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
......
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