配套视频教程
项目代码
跳跃
mario.py
init
handle_state
standing
walking
新增
玛丽不掉落,但上去就下不来
jumping
玛丽跳跃正常
jumping
新增falling
def falling(self, keys, current_time):
self.y_vel += self.gravity
if (self.rect.bottom > (600 - self.rect.height)):
self.y_vel = 0
self.gravity = c.GRAVITY
self.state = c.WALK
if keys[pg.K_LEFT]:
self.facing_right = False
if self.x_vel > (self.max_x_vel * - 1):
self.x_vel -= self.x_accel
elif keys[pg.K_RIGHT]:
self.facing_right = True
if self.x_vel < self.max_x_vel:
self.x_vel += self.x_accel
玛丽跳跃短按小跳,长按大跳
jumping
网友评论