Commit 2ff22b1a by BellCodeEditor

save project

parent 41c8d59b
Showing with 19 additions and 12 deletions
...@@ -5,7 +5,7 @@ import random ...@@ -5,7 +5,7 @@ import random
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
pygame.display.set_caption("悟空跑酷")
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 载入图片 # 载入图片
background = pygame.image.load('bg.png') # 背景 background = pygame.image.load('bg.png') # 背景
...@@ -23,10 +23,10 @@ index = 0 #索引位置 ...@@ -23,10 +23,10 @@ index = 0 #索引位置
jumpstate = "running" jumpstate = "running"
y=400 y=400
t=30 t=30
# obstacle = random.choice([stone,cacti,bush]) obstacle = random.choice([stone,cacti,bush])
# rect = obstacle.get_rect() rect = obstacle.get_rect()
# rect.x = 1000 rect.x = 1000
# rect.y = 500 - rect.height rect.y = 500 - rect.height
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -52,17 +52,23 @@ while True: ...@@ -52,17 +52,23 @@ while True:
else: else:
jumpstate = "running" jumpstate = "running"
t=30 t=30
wukong = hero[index]
if jumpstate == "running": #跑步状态下不换造型 if jumpstate == "running": #跑步状态下不换造型
index += 1 index += 1
if index == 5: if index == 5:
index = 0 index = 0
# if rect.x <= 0 - rect.width: screen.blit(background,(0,0))
# obstacle = random.choice([stone,cacti,bush]) screen.blit(road,(0,500))
# rect = obstacle.get_rect() screen.blit(wukong,(150,y))
# rect.x = 1000 if rect.x <= 0 - rect.width:
# rect.y = 500 - rect.height obstacle = random.choice([stone,cacti,bush])
# rect.x -= 8 rect = obstacle.get_rect()
# screen.blit(obstacle,(rect.x, rect.y)) rect.x = 1000
rect.y = 500 - rect.height
rect.x -= 8
screen.blit(obstacle,(rect.x, rect.y))
# 刷新画面 # 刷新画面
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