Commit daffbd8b by BellCodeEditor

save project

parent e1a56324
Showing with 3 additions and 25 deletions
......@@ -10,16 +10,6 @@ class Block(pygame.sprite.Sprite):
self.rect.x=1000
self.rect.y=500-self.rect.height
pygame.init() # 初始化
class player(pygame.sprite.Sprite):
def __init__(self,image):
super().__init__()
self.image=image
self.rect=self.image.get_rect()
self.rect.x=150
self.rect.y=400
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
......@@ -69,7 +59,7 @@ while True:
t =30
# 悟空造型
wukong = Player(hero[index])
wukong = hero[index]
if jumpState == "runing": # 跑步状态下
index += 1
if index >= 5:
......@@ -83,22 +73,10 @@ while True:
if lu_x <-1000:
lu_x=0
screen.blit(road, (lu_x, 500)) # 路
screen.blit(wukong.image, (150, y)) # 悟空
screen.blit(wukong, (150, y)) # 悟空
if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失
time+=1 # 创建障碍物对象
if time>=60:
time=0
num=random.randint(0,50)
if num>20:
obstacle=Block(bush,cacti,stone)
block_list.add(obstacle)
for sprite in block_list:
sprite.rect.x-=8
screen.blit(sprite.image,(sprite.rect.x,sprite.rect.y))
if sprite
# 创建障碍物对象
obstacle=Block(bush,stone,cacti)
obstacle.rect.x-=8
screen.blit(obstacle.image,(obstacle.rect.x,obstacle.rect.y))
......
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