python街机萤火虫勇闯黑夜迷宫_大型滚动地图

你好,请进入Q群:225792826,免费下载本站最新提供的视频教程原创源码资料,从2020年2月20号到3月底,成为本站会员只要原价的3折,即2980元*0.3 = 894元 ,向微信scratch8付款即可成为本站会员。即可拥有本站所有原创资源,并提供技术支持。如本消息修改,以最后时间的为准。

python arcade 萤火虫勇闯黑夜迷宫_大型滚动地图 lixingqiu下面gif动录制作软件把图片进行了压缩,所以呈现了“圆圈”效果。实际上效果像上图这样。python arcade 萤火虫勇闯黑夜迷宫_大型滚动地图 lixingqiu

以下是部分代码预览:

"""
萤火虫勇闯黑夜迷宫_大型滚动地图

"""

import random
import arcade
import os

SPRITE_SCALING = 1

SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
SPRITE_PIXEL_SIZE = 64

# 距离屏幕边距的最小距离 

VIEWPORT_MARGIN = 40
MOVEMENT_SPEED = 5

class MyGame(arcade.Window):
    """主应用程序类. """

    def __init__(self, width, height):
        """
        初始化器
        """
        super().__init__(width, height,"萤火虫勇闯黑夜迷宫_大型滚动地图 lixingqiu")

        self.game_over = False

        # 角色列表
        self.player_list = None
        self.coin_list = None

        # 设置游戏及玩家相关变量
        self.score = 0
        self.player_sprite = None
        self.wall_list = None
        self.physics_engine = None
        self.view_bottom = 0
        self.view_left = 0

    def setup(self):
        """ 实例化变量 """

        # 角色列表
        self.player_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()

        # 设置蒙板
        self.mask = arcade.Sprite("images/mask.png")
        self.mask.scale = 2

        # 实例化玩家操作的角色
        self.score = 0
        self.player_sprite = arcade.Sprite("images/lixingqiu.png", 0.4)
        self.player_sprite.center_x = 128
        self.player_sprite.center_y = 270
        self.player_list.append(self.player_sprite)

    def on_draw(self):
        """
        渲染屏幕
        """

        # 开始渲染
        arcade.start_render()

        # 画各个角色
        self.wall_list.draw()
        self.player_list.draw()
        self.小东西_list.draw()
        self.mask.draw()
                

    def on_key_press(self, key, modifiers):
        """当按键时调用此方法 """

        if key == arcade.key.UP:
            self.player_sprite.change_y = MOVEMENT_SPEED
        elif key == arcade.key.DOWN:
            self.player_sprite.change_y = -MOVEMENT_SPEED
        elif key == arcade.key.LEFT:
            self.player_sprite.change_x = -MOVEMENT_SPEED
        elif key == arcade.key.RIGHT:
            self.player_sprite.change_x = MOVEMENT_SPEED

    def on_key_release(self, key, modifiers):
        """当松开按键时调用此方法 """

        if key == arcade.key.UP or key == arcade.key.DOWN:
            self.player_sprite.change_y = 0
        elif key == arcade.key.LEFT or key == arcade.key.RIGHT:
            self.player_sprite.change_x = 0

    def update(self, delta_time):
        """ 游戏逻辑设定,结果都是更新坐标/角度,删除/添加角色等。"""

        # 调用物理引擎
        self.physics_engine.update()

        # 蒙板跟随玩家角色
        self.mask.center_x = self.player_sprite.center_x
        self.mask.center_y = self.player_sprite.center_y


def main():
    """ 主要方法"""
    window = MyGame(SCREEN_WIDTH, SCREEN_HEIGHT)
    window.setup()
    arcade.run()

if __name__ == "__main__":
    main()

如需要查看完整代码,请扫码付款:

VIP免费查看

已有0人支付

本站所有作品,教程等皆为原创,盗版必究。一旦付款,表示同意本站知识付费原则:数字商品,不支持退款。亦可直接向微信号scratch8付款购买。QQ群免费教学群:225792826 (提供真实姓名可入群)
李兴球的博客_Python创意编程技术前沿 » python街机萤火虫勇闯黑夜迷宫_大型滚动地图

学本领,探索更大的世界!

李兴球博客 风火轮编程主页