Commit 21f15edf by BellCodeEditor

auto save

parent 44e8520e
Showing with 7 additions and 5 deletions
......@@ -9,8 +9,8 @@ FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3):
super().__init__()
self.image.random.choice([image1,image2,image3])
self.rect.image.get_rect()
self.image=random.choice([image1,image2,image3])
self.rect=self.image.get_rect()
self.rect.x=1000
self.rect.y=500-self.rect.height
......@@ -26,12 +26,13 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
obstacle=Block(bush,cacti,stone)
index = 0
raod_x=0
y = 400
jumpState = "runing"
t = 30
obstacle=Block(bush,cacti,stone)
baijing_x=0
while True:
for event in pygame.event.get():
......@@ -74,8 +75,9 @@ while True:
screen.blit(road, (raod_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空
if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失
obstacle.raod_x-=8
if obstacle.rect.x <= 0-obstacle.rect.width:#
obstacle=Block(bush,cacti,stone) #障碍物消失
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