Commit 136cc89e by BellCodeEditor

save project

parent a84302d9
Showing with 34 additions and 8 deletions
......@@ -3,7 +3,15 @@ from pygame import locals
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
class Block(pygame.sprite.sprite):
def __init__(self,image1,image2,image3):
super().__init__()
self.image = random.choice([image1,image2,image3])
self.rect = self.image.get_rect()
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
pygame.display.set_coption("悟空酷跑")
# 载入图片
......@@ -18,6 +26,13 @@ jumpostate = "runing"
y = 400
t = 30
bg_x = 0
road_x = 0
time = 0
#obstacle = Block(bush,cacti,stone)
Block_list =pygame.sprite.group()
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -41,14 +56,25 @@ while True:
t=30
wukong = hero[index]
if jumpostate == "runing":
index += 1
if index == 5:
index = 0
#if jumpostate == "runing":
#index += 1
#if index == 5:
# index = 0
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(hero, (150, y))
time += 1
if time >= 60:
r andom.randint(0,100)
if r > 40:
obstacle = Block(bush,cacti,stone)
Block-list.add(obstacle)
time = 0
for prop in block_list:
prop.rect.X -= 8
screen.blit(prop.image,(prop.rect,x, prop.rect.y))
if prop.rect.x<=0-prop.rect.width:
prop.kill()
# 刷新画面
if rect.x <= 0-rect.width:
......
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