Commit 2ff22b1a by BellCodeEditor

save project

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