Commit cf88de8e by BellCodeEditor

save project

parent 08afd35a
Showing with 26 additions and 14 deletions
...@@ -11,6 +11,15 @@ class Block(pygame.sprite.Sprite) ...@@ -11,6 +11,15 @@ class Block(pygame.sprite.Sprite)
self.rect.x = 1000 self.rect.x = 1000
self.rect.y = 500 - rect.height self.rect.y = 500 - rect.height
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
class Player(pygame.sprite.Sprite)
daf_init_(self,image)
super()_init_()
self.image= image
self.rect =selfimage.get_rect()
self.rect.x = 1000
self.rect.y = 500 - rect.height
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
pygame.display.set_caption("悟空酷跑") pygame.display.set_caption("悟空酷跑")
# 载入图片 # 载入图片
...@@ -31,6 +40,7 @@ t = 30 ...@@ -31,6 +40,7 @@ t = 30
road_x=0 road_x=0
bg_x=0 bg_x=0
time = 0 time = 0
gamestart = True
# obstacle = Block(bush, stone, cacti) # obstacle = Block(bush, stone, cacti)
Block_list = pygame.sprite.Group() Block_list = pygame.sprite.Group()
...@@ -43,20 +53,22 @@ while True: ...@@ -43,20 +53,22 @@ while True:
if jumpState == "runing": if jumpState == "runing":
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumpState = "up" jumpState = "up"
wukong = Plo
if gamestart == True
if jumpState == "up": # 起跳状态 if jumpState == "up": # 起跳状态
if t > 0: if t > 0:
y -= t y -= t
t -= 2 t -= 2
else: else:
jumpState = "down" jumpState = "down"
if jumpState == "down": # 降落状态 if jumpState == "down": # 降落状态
if t <= 30: if t <= 30:
y += t y -= t
t += 2 wukong.rect.y = y
else: else:
jumpState = "runing" jumpState = "runing"
t =30 t =30
# 悟空造型 # 悟空造型
wukong = hero[index] wukong = hero[index]
...@@ -82,7 +94,7 @@ while True: ...@@ -82,7 +94,7 @@ while True:
obstacle = Block(bush, stone, cacti) obstacle = Block(bush, stone, cacti)
block_list.add(obstacle) block_list.add(obstacle)
time = 0 time = 0
screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y)) screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y))
# 刷新画面 # 刷新画面
......
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