美文网首页
Python实现超级玛丽游戏系列教程03玛丽跳跃

Python实现超级玛丽游戏系列教程03玛丽跳跃

作者: __豆约翰__ | 来源:发表于2020-12-20 10:56 被阅读0次

配套视频教程

配套视频教程

项目代码

项目代码

跳跃

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


相关文章

网友评论

      本文标题:Python实现超级玛丽游戏系列教程03玛丽跳跃

      本文链接:https://www.haomeiwen.com/subject/hyahnktx.html