Commit 40a902fc by BellCodeEditor

save project

parent 1742c908
Showing with 12 additions and 4 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random import random
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() FPS = pygame.time.Clock()
pygame.display.set_caption("悟空酷跑") pygame.display.set_caption("5空苦跑")
# 载入图片 # 载入图片
background = pygame.image.load('bg.png') # 背景 background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路 road = pygame.image.load('road.png') # 路
...@@ -24,6 +24,8 @@ index = 0 ...@@ -24,6 +24,8 @@ index = 0
jumpState = 'runing' jumpState = 'runing'
y = 400 y = 400
t = 30 t = 30
bg_x = 0
road_x = 0
obstacle = random.choice([bush,stone,cacti]) obstacle = random.choice([bush,stone,cacti])
rect = obstacle.get_rect() rect = obstacle.get_rect()
rect.x=1000 rect.x=1000
...@@ -58,8 +60,14 @@ while True: ...@@ -58,8 +60,14 @@ while True:
index = 0 index = 0
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) bg_x -= 1
screen.blit(road, (0, 500)) if bg_x<=-1000:
bg_x = 0
screen.blit(background, (bg_x, 0))
road_x -= 8
if road_x<=-1000:
road_x = 0
screen.blit(road, (road_x, 500))
screen.blit(wukong, (150, y)) screen.blit(wukong, (150, y))
if rect.x <0-rect.width: if rect.x <0-rect.width:
obstacle =random.choice([bush,stone,cacti]) obstacle =random.choice([bush,stone,cacti])
......
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