Commit 14812889 by BellCodeEditor

save project

parent 72a99074
Showing with 15 additions and 3 deletions
import pygame
from pygame import locals
import random
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') # 石头
......@@ -21,7 +22,10 @@ index = 0
jumpState = 'running'
y=400
t=30
o=random.choice([stone,cacti,apple])
rect = o.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
while True:
for event in pygame.event.get():
......@@ -48,11 +52,18 @@ while True:
else:
jumpState='running'
t=30
if rect.x <= 0-rect.width:
o=random.choice([stone,cacti,apple])
rect = o.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
rect.x-=8
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(wukong, (150, y))
screen.blit(o, (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