Commit faf88930 by BellCodeEditor

auto save

parent 080ee70a
Showing with 15 additions and 6 deletions
......@@ -7,12 +7,12 @@ pygame.init() # 初始化
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
pygame.display.set_caption("悟空酷跑")
# 载入图片
background = pygame.image.load('bg.png') # 背景
# 载入图片 # 背景
road = pygame.image.load('road.png') # 路
stone = pygame.image.load('stone.png') # 石头
cacti = pygame.image.load('cacti.png') # 仙人掌
bush = pygame.image.load('bush.png') # 灌木丛
bg = pygame.image.load('bg.png')
hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero2.png'),
pygame.image.load('hero3.png'),
......@@ -26,6 +26,8 @@ obstacle = random.choice([bush, stone, cacti])
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
rode_x = 0
bg_x = 0
while True:
for event in pygame.event.get():
......@@ -52,16 +54,17 @@ while True:
t =30
# 悟空造型
wukong = hero[index]
wukong = hero[int(index)]
if jumpState == "runing": # 跑步状态下
index += 1
index += 0.2
if index >= 5:
index = 0
# 将背景图画上去
screen.blit(background, (0, 0)) # 远处背景
screen.blit(road, (0, 500)) # 路
screen.blit(bg, (bg_x, 0)) # 远处背景
screen.blit(road, (rode_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空
if rect.x <= 0-rect.width: # 障碍物消失
# 创建障碍物对象
obstacle = random.choice([bush,stone,cacti])
......@@ -69,6 +72,12 @@ while True:
rect.x = 1000
rect.y = 500 - rect.height
rect.x -= 8
rode_x -= 8
bg_x -= 2
if rode_x <= -1000:
rode_x = 0
if bg_x <= -1000:
bg_x = 0
screen.blit(obstacle, (rect.x, rect.y))
# 刷新画面
pygame.display.update()
......
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