Commit d7fc96d1 by BellCodeEditor

auto save

parent 3d4729ee
Showing with 10 additions and 8 deletions
...@@ -27,15 +27,16 @@ hero = [pygame.image.load('hero1.png'), ...@@ -27,15 +27,16 @@ 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')]
class Player(Block): index = 0
def __init__(self): class Player(pygame.sprite.Sprite):
def __init__(self,image):
super().__init__() super().__init__()
self.image = hero[index] self.image = image
self.rect = self.image.get_rect() self.rect = self.image.get_rect()
self.rect.x=150 self.rect.x=150
self.rect.y=500-self.rect.height self.rect.y=400
# shan_x=0 # shan_x=0
index = 0
y = 400 y = 400
jumpState = "runing" jumpState = "runing"
t = 30 t = 30
...@@ -53,18 +54,19 @@ while True: ...@@ -53,18 +54,19 @@ while True:
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumpState = "up" jumpState = "up"
wukong = Player() wukong = Player(hero[index])
print(wukong.image)
if jumpState == "up": # 起跳状态 if jumpState == "up": # 起跳状态
if t > 0: if t > 0:
y -= t y -= t
wukong.rect.y = y # wukong.rect.y = y
t -= 2 t -= 2
else: else:
jumpState = "down" jumpState = "down"
if jumpState == "down": # 降落状态 if jumpState == "down": # 降落状态
if t <= 30: if t <= 30:
y += t y += t
wukong.rect.y = y # wukong.rect.y = y
t += 2 t += 2
else: else:
jumpState = "runing" jumpState = "runing"
......
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