Commit 724cf3a1 by BellCodeEditor

save project

parent 8bca0852
Showing with 19 additions and 6 deletions
......@@ -12,7 +12,7 @@ class Block(pygame.sprite.Sprite):
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
pygame.display.set_caption("悟空酷跑")
pygame.display.set_caption("sha13游戏")
# 载入图片
background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路
......@@ -28,9 +28,10 @@ index = 0
y = 400
jumpState = "runing"
t = 30
obstacle = Block(bush,cacti,stone)
block_list=pygame.sprite.Group()
lu=0
beijing=0
time=0
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -72,10 +73,21 @@ while True:
screen.blit(background, (beijing, 0)) # 远处背景
screen.blit(road, (lu, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空
if obstacle.rect.x<=0-obstacle.rect.width:
obstacle = Block(bush,stone,cacti)
obstacle.rect.x-=8
screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y))
# if obstacle.rect.x<=0-obstacle.rect.width:
# obstacle = Block(bush,stone,cacti)
# obstacle.rect.x-=8
# screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y))
time+=1
if time>60:
time=0
r=random.randint(0,100)
if r >40:
obstacle = Block(bush,cacti,stone)
block_list.add(obstacle)
for prop in block_list:
prop.rect.x-=8
screen.blit(prop.image,(prop.rect.x,prop.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