Commit 427dedc2 by BellCodeEditor

save project

parent ee633f86
Showing with 16 additions and 2 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random
pygame.init() # 初始化 pygame.init() # 初始化
pygame.display.set_caption("悟空酷跑")# 创建一个窗口 pygame.display.set_caption("悟空酷跑")# 创建一个窗口
...@@ -10,7 +11,7 @@ background = pygame.image.load('bg.png') # 背景 ...@@ -10,7 +11,7 @@ background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路 road = pygame.image.load('road.png') # 路
stone = pygame.image.load('stone.png') # 石头 stone = pygame.image.load('stone.png') # 石头
cacti = pygame.image.load('cacti.png') # 仙人掌 cacti = pygame.image.load('cacti.png') # 仙人掌
apple = pygame.image.load('bush.png')
hero= [pygame.image.load('hero1.png'), hero= [pygame.image.load('hero1.png'),
pygame.image.load('hero2.png'), pygame.image.load('hero2.png'),
pygame.image.load('hero3.png'), pygame.image.load('hero3.png'),
...@@ -19,7 +20,11 @@ hero= [pygame.image.load('hero1.png'), ...@@ -19,7 +20,11 @@ hero= [pygame.image.load('hero1.png'),
j="run" j="run"
t=30 t=30
index = 0 index = 0
o=random.choice([stone,cacti])
r=o.get_rect()
r.x=1000
r.y=500 - r.height
y=400 y=400
...@@ -59,6 +64,14 @@ while True: ...@@ -59,6 +64,14 @@ while True:
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(road, (0, 500)) screen.blit(road, (0, 500))
screen.blit(wk, (150, y)) screen.blit(wk, (150, y))
if r.x<=0-r.width:
o=random.choice([stone,cacti])
r=o.get_rect()
r.x=1000
r.y=500 - r.height
r.x-=8
screen.blit(o,(r.x,r.y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) 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