Commit 79c4f9eb by BellCodeEditor

save project

parent 192e9fbe
Showing with 26 additions and 24 deletions
......@@ -10,10 +10,11 @@ class Books(pygame.sprite.Sprite):
self.rect = self.image.get_rect()
self.rect.x = 1000
self.rect.y = 500 - self.rect.height
class wukong(pygame.sprite.Sprite):
class Wukong(pygame.sprite.Sprite):
def __init__(self,image):
super().__init__(image)
self.rect = self.get_rect()
super().__init__()
self.image = image
self.rect = self.image.get_rect()
self.rect.x = 150
self.rect.y = 400
# 创建一个窗口
......@@ -51,30 +52,28 @@ while True:
if event.key == locals.K_SPACE:
jump = "up"
wukong = wukong(hero[index])
wukong = Wukong(hero[index])
if jump == "running":
index += 1
if index == 5:
index = 0
if jump == "up":
if t > 0:
y -= t
wukong.rect.y = y
t -= 2
else:
jump = "down"
if jump == "down":
if t <= 35:
y += t
wukong.rect.y = y
t += 2
else:
jump = "running"
t = 35
if game == 0:
if jump == "up":
if t > 0:
y -= t
wukong.rect.y = y
t -= 2
else:
jump = "down"
if jump == "down":
if t <= 35:
y += t
wukong.rect.y = y
t += 2
else:
jump = "running"
t = 35
# 将背景图画上去
beijing_x -= 4
if beijing_x <= -1000:
......@@ -85,7 +84,7 @@ while True:
if road_x <= -1000:
road_x = 0
screen.blit(road, (road_x, 500))
screen.blit(image, (150, y))
screen.blit(wukong.image, (150, y))
#障碍物
time += 1
......@@ -101,8 +100,10 @@ while True:
if sprite.rect.x <=0-sprite.rect.width:
sprite.kill()
if pygame.sprite.collide_rect(wukong,sprite):
qinglong3 = pygame.image.load('qinglong3.png') #结束
gameover = pygame.image.load('gameover.png') #结束
screen.blit(gameover,(400,200))
game = 1
# 刷新画面
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