Commit 79c4f9eb by BellCodeEditor

save project

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