Commit 40b6a13a by BellCodeEditor

auto save

parent 2742489a
Showing with 13 additions and 11 deletions
...@@ -5,10 +5,10 @@ import random ...@@ -5,10 +5,10 @@ import random
class Block(pygame.sprite.Sprite): class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3): def __init__(self,image1,image2,image3):
super().__init__() super().__init__()
self.image=random.choice([image1,image2,image3]) self.image = random.choice([image1,image2,image3])
self.rect=self.image.get_rect() self.rect = self.image.get_rect()
self.rect.x=1000 self.rect.x = 1000
self.rect.y=500-self.rect.height self.rect.y = 500 - self.rect.height
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
...@@ -26,12 +26,15 @@ hero = [pygame.image.load('hero1.png'), ...@@ -26,12 +26,15 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero4.png'), pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
lu_x=0 lu_x=0
shan_x=0 shan_x = 0
index = 0 index = 0
y = 400 y = 400
road_x = 0
jumpState = "runing" jumpState = "runing"
t = 30 t = 30
aa=Block(bush,cacti,stone) aa = Block(bush,cacti,stone)
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -55,7 +58,7 @@ while True: ...@@ -55,7 +58,7 @@ while True:
t += 2 t += 2
else: else:
jumpState = "runing" jumpState = "runing"
t =30 t = 30
# 悟空造型 # 悟空造型
wukong = hero[index] wukong = hero[index]
...@@ -64,13 +67,12 @@ while True: ...@@ -64,13 +67,12 @@ while True:
if index >= 5: if index >= 5:
index = 0 index = 0
# 将背景图画上去 # 将背景图画上去
shan_x -=2 shan_x -= 2
if shan_x <-1000: if shan_x <-1000:
shan_x=0 shan_x=0
screen.blit(background, (shan_x, 0)) # 远处背景 screen.blit()
lu_x -=8
if lu_x <-1000: if lu_x <-1000:
lu_x=0 lu_x = 0
screen.blit(road, (lu_x, 500)) # 路 screen.blit(road, (lu_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wukong, (150, 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