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