Commit a15af8f7 by BellCodeEditor

save project

parent ca8a8ed3
Showing with 17 additions and 3 deletions
import pygame
from pygame import locals
import random
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
......@@ -16,6 +16,11 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
stones=random.choice([stone,cacti,apple])
rect=stones.get_rect()
stones_x=1000;
stones_y=500-rect[3]
pygame.display.set_caption('悟空酷跑')
index = 0
sport='running'
......@@ -49,9 +54,18 @@ while True:
if index>=len(hero):
index=0
# 将背景图画上去
if stones_x + rect[2] < 0:
stones=random.choice([stone,cacti,apple])
rect=stones.get_rect()
stones_x=1000;
stones_y=500-rect[3]
else:
stones_x -= 2
rect = stones.get_rect()
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(hero[index], (150, y))
screen.blit(stones, (stones_x, stones_y))
# 刷新画面
pygame.display.update()
FPS.tick(6
\ No newline at end of file
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