Arcade街机多房间关卡演示例

以下是部分代码预览:

"""
Arcade街机多房间关卡演示例
"""

import arcade
import os

SPRITE_SCALING = 0.5
SPRITE_NATIVE_SIZE = 128
SPRITE_SIZE = int(SPRITE_NATIVE_SIZE * SPRITE_SCALING)

SCREEN_WIDTH = SPRITE_SIZE * 14
SCREEN_HEIGHT = SPRITE_SIZE * 10
SCREEN_TITLE = "Arcade街机多房间关卡演示例"

MOVEMENT_SPEED = 5

class Room:
    """
    房间的父类,只是设定了墙列表和背景属性
    """
    def __init__(self):
        # 定义墙列表
        self.wall_list = None

        # 定义背景属性
        self.background = None


def setup_room_1():
    """
    创建房间一
    """
    room = Room()

    """ 给房间的wall_list赋值. """
    # Sprite lists
    room.wall_list = arcade.SpriteList()

    wall = arcade.Sprite("images/boxCrate_double.png", SPRITE_SCALING)
    wall.left = 7 * SPRITE_SIZE
    wall.bottom = 5 * SPRITE_SIZE
    room.wall_list.append(wall)

    # 可以在房间里加些金币道具等角色

    # 加载此关的背景
    room.background = arcade.load_texture("images/background.jpg")

    return room


def setup_room_2():
    """
    创建房间2
    """
    room = Room()


class MyGame(arcade.Window):
    """ Main application class. """

    def __init__(self, width, height, title):
        """
        Initializer
        """
        super().__init__(width, height, title)

        # 房间的索引号
        self.current_room = 0

        # 定义玩家的一些变量
        self.rooms = None
        self.player_sprite = None
        self.player_list = None
        self.physics_engine = None

    def setup(self):
        """ Set up the game and initialize the variables. """
        # 实例化玩家对象
        self.player_sprite = arcade.Sprite("images/character.png", SPRITE_SCALING)
        self.player_sprite.center_x = 100
        self.player_sprite.center_y = 100
        self.player_list = arcade.SpriteList()
        self.player_list.append(self.player_sprite)

        # 房间列表
        self.rooms = []

        # 设置房间.
        room = setup_room_1()
        self.rooms.append(room)


    def on_draw(self):
        """
        渲染房间
        """


def main():
    """ Main method """
    window = MyGame(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
    window.setup()
    arcade.run()


if __name__ == "__main__":
    main()

 

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

VIP免费查看

已有0人支付

本站所有作品,教程等皆为原创,盗版必究。一旦付款,表示同意本站知识付费原则:数字商品,不支持退款。扫码付款后的朋友可以加QQ: 406273900,提供技术支持及发送作品图片与配音素材。亦可直接向微信号scratch8付款购买。
李兴球的博客_Python创意编程技术前沿 » Arcade街机多房间关卡演示例

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

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