Index

Package: Maps

Description

package Maps is

Classes

Map_Object (abstract)

type Map_Object is abstract new Object with private;

Ancestors:

Immediate Children:

Maps.Keen.Keen_Map

Primitive operations:

Adjust (overriding Objects.Adjust)
Construct
Delete (overriding Objects.Delete)
Object_Input
Object_Read (overriding Objects.Object_Read)
Object_Write (overriding Objects.Object_Write)
Objects.Construct (Inherited)
Objects.To_String (Inherited)
A Map_Object is layered, two-dimensional grid of tile ids used by Worlds. It's composed of a stack of Layers of identical dimensions. To get and set tile ids in the map, locations must be addressed by coordinates (layer, x, y). All coordinates start at 1. Layer 1 is the most background layer, ie: the furthest away in the z-order. The number of layers in a map is a constant, determined at construction by the concrete Map subclass.

Types

Layer_Data

type Layer_Data is array(Positive range <>) of Natural;
A one dimensional array of tiles for a map layer

Layer

type Layer(size : Positive) is
        record
            physical : Boolean := False;     -- entities should clip to layer
            data     : Layer_Data(1..size);  -- tile ids (size = width * height)
        end record;
A single map layer, where 'size' is the number of tiles in the layer.

A_Layer

type A_Layer is access all Layer;

Layer_Array

type Layer_Array is array (Positive range <>) of A_Layer;
An array of map layers. All layers are expected to be the same size.

A_Layer_Array

type A_Layer_Array is access all Layer_Array;

A_Map

type A_Map is access all Map_Object'Class;

Constants & Global variables

MAX_WIDTH (Positive)

MAX_WIDTH  : constant Positive;
Maximum supported map dimensions

MAX_HEIGHT (Positive)

MAX_HEIGHT : constant Positive;

Subprograms & Entries

Copy

function Copy
( src: A_Layer_Array ) return A_Layer_Array;
Returns a deep copy of a layer array.

Delete

procedure Delete
( la: in out A_Layer_Array );
Deep deletes a layer array.

Move

procedure Move
( dst, src: in out A_Layer_Array );
Moves a layer array reference. If 'dst' is not null it will be deleted.

Create_Map

function Create_Map
( width, height: Positive ) return A_Map;
Creates a new empty map with the given dimensions. The registered allocator will determine the concrete class of the map and how many layers it will have. An exception is raised if the dimensions are too large.

Get_Height

function Get_Height
( this: not null access Map_Object'Class ) return Positive;
Returns the map's height in tiles.

Get_Layers

function Get_Layers
( this: not null access Map_Object'Class ) return Positive;
Returns the number of layers in the map.

Get_Layers_Data

function Get_Layers_Data
( this: not null access Map_Object'Class ) return A_Layer_Array;
Returns a pointer to the layer data owned by the map. Do not modify the contents.

Get_Tile_Id

function Get_Tile_Id
( this: not null access Map_Object'Class;
layer: Positive;
x, y: Integer ) return Natural;
Returns the id of a tile in the map. If the location is not on the map then 0 will be returned.

Get_Width

function Get_Width
( this: not null access Map_Object'Class ) return Positive;
Returns the width of the map in tiles.

Object_Input (abstract)

function Object_Input
( stream: access Root_Stream_Type'Class ) return Map_Object is abstract;
All concrete Map classes must implement this to be read from streams.

Resize

procedure Resize
( this: not null access Map_Object'Class;
width, height: Positive );
Resizes the map. If the new size is larger in a dimension, the new space will be filled with tile id 0. If the new size is smaller in a dimension, the right and bottom edges will be clipped down to the new size. An exception will be raised if new dimensions are too large.

Set_Tile

procedure Set_Tile
( this: not null access Map_Object'Class;
layer: Positive;
x, y: Integer;
tile: Natural );
Sets the tile id at a location in the map. If the location doesn't exist, nothing will happen.

Tile_Width

function Tile_Width
( this: not null access Map_Object'Class ) return Positive;
Returns the width of tiles in the map in pixels.

Copy

function Copy
( src: A_Map ) return A_Map;
Returns a deep copy of the map.

Delete

procedure Delete
( this: in out A_Map );
Deletes the map.