Exemplo n.º 1
0
    def setup(self):
        """ Set up the game and initialize the variables. """

        # Sprite lists
        self.player_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()
        self.floor_list = arcade.SpriteList()
        self.objects_list = arcade.SpriteList()

        self.my_map = arcade.read_tiled_map('dungeon.tmx')

        # Set up the player
        self.player_sprite = arcade.Sprite("images/character.png", 0.4)
        px, py = arcade.isometric_grid_to_screen(
            self.my_map.width // 2, self.my_map.height // 2, self.my_map.width,
            self.my_map.height, self.my_map.tilewidth, self.my_map.tileheight)

        self.player_sprite.center_x = px * SPRITE_SCALING
        self.player_sprite.center_y = py * SPRITE_SCALING
        self.player_list.append(self.player_sprite)

        read_sprite_list(self.my_map.layers["Floor"], self.floor_list)
        read_sprite_list(self.my_map.layers["Walls"], self.wall_list)
        read_sprite_list(self.my_map.layers["Furniture"], self.wall_list)

        # Set the background color
        if self.my_map.backgroundcolor is None:
            arcade.set_background_color(arcade.color.BLACK)
        else:
            arcade.set_background_color(self.my_map.backgroundcolor)

        # Set the viewport boundaries
        # These numbers set where we have 'scrolled' to.
        self.view_left = 0
        self.view_bottom = 0
Exemplo n.º 2
0
    def setup(self):
        self.player_list = arcade.SpriteList()
        self.wall_list = arcade.SpriteList()
        self.floor_list = arcade.SpriteList()
        self.objects_list = arcade.SpriteList()

        self.my_map = arcade.read_tiled_map('dungeon.tmx')

        # Set up the player
        self.player_sprite = arcade.Sprite("images/character.png", 0.4)
        px, py = arcade.isometric_grid_to_screen(
            self.my_map.width // 2, self.my_map.height // 2, self.my_map.width,
            self.my_map.height, self.my_map.tilewidth, self.my_map.tileheight)

        self.player_sprite.center_x = px * SPRITE_SCALING
        self.player_sprite.center_y = py * SPRITE_SCALING
        self.player_list.append(self.player_sprite)

        read_sprite_list(self.my_map.layers["Floor"], self.floor_list)
        # read_sprite_list(self.my_map.layers["Walls"], self.wall_list)
        read_sprite_list(self.my_map.layers["Furniture"], self.wall_list)

        # Set the background color
        if self.my_map.backgroundcolor is None:
            arcade.set_background_color(arcade.color.BLACK)
        else:
            arcade.set_background_color(self.my_map.backgroundcolor)

        self.view_left = 0
        self.view_bottom = 0
Exemplo n.º 3
0
def test_isometric_grid_to_screen():
    tile_x = 0
    tile_y = 0
    width = 10
    height = 10
    tile_width = 64
    tile_height = 64
    x, y = arcade.isometric_grid_to_screen(tile_x, tile_y, width, height,
                                           tile_width, tile_height)
    assert x == 320
    assert y == 608

    tile_x = 2
    tile_y = 2
    width = 10
    height = 10
    tile_width = 64
    tile_height = 64
    x, y = arcade.isometric_grid_to_screen(tile_x, tile_y, width, height,
                                           tile_width, tile_height)
    assert x == 320
    assert y == 480