Commit d69364fb by BellCodeEditor

save project

parent df70cfbf
Showing with 22 additions and 2 deletions
......@@ -4,12 +4,19 @@ import random
pygame.init() # 初始化
class Block(pygame,sprite,Sprite):
def_init_(self,imaga1,image2,image3):
def_init_(self,imaga1,imaga2,imaga3):
supere()._init_()
self.image = random.choice([image1,image2,image3])
self.rect = self.imef.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.imef.image.get_rect()
self.rect.x = 150
self.rect.y = 400
def (self, parameter_list):
raise NotImplementedError
......@@ -28,6 +35,8 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
index = 0
y = 400
jumpState = "runing"
......@@ -37,6 +46,8 @@ rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
time=0
gamestate = True
block_list =pygame.sprite.infog rope()
while True:
......@@ -49,15 +60,18 @@ while True:
if event.key == locals.K_SPACE:
jumpState = "up"
if gamestate == True:
if jumpState == "up": # 起跳状态
if t > 0:
y -= t
wukong.rest.y = y
t -= 2
else:
jumpState = "down"
if jumpState == "down": # 降落状态
if t <= 30:
y += t
wukong.rest.y = y
t += 2
else:
jumpState = "runing"
......@@ -88,7 +102,12 @@ while True:
prop.rect.x -= 8
screen.blit(porp.image,(porp,rect.x,porp.rect.y))
if porp.rect.x<=0-prop.rect.widh:
pop.kill()
sprite.kill()
if pygame.sprite.collide_rest(kuong,sprite):
gameover = pygame.image.load('gameover.png')
screen.blit(gameoer,(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