MAP interface implements a 2D map of fixed-size nodes arranged into
MAP is suitable for 2D overhead, isometric and platform graphics.
Each nodes contains a stack of
Four types of items are currently defined:
Graphical elements define two displacements in pixels of the image from the tile's origin, the centering offset and the motion offset.
The centering offset is typically assigned by a level designer, and the motion offset is for animation purposes. If the map is drawn scaled, the centering offset is scaled to the tile size, but the motion offset is not.
Graphical elements provide the renderer with a list of graphical transformations that should be applied before the tile is drawn (the resulting tile is cached). A per-element layer attribute also defines the attributed layer.
|AG_Object(3)-> space(3)-> MAP.|
MAP_New() allocates, initializes and attaches a new map.
The MAP_AllocNodes() function allocates w x h nodes, assuming that no node is currently allocated. MAP_AllocNodes() returns 0 on success or -1 on failure. The maximum allowable geometry is defined by MAP_WIDTH_MAX and MAP_HEIGHT_MAX. The MAP_FreeNodes() function releases the nodes allocated by map.
The MAP_Resize() function reallocates the nodes arrays, initializing the new nodes and freeing the excess ones. MAP_Resize() returns 0 on sucess or -1 on failure.
The MAP_SetZoom() function sets the zoom factor for a given map view. Actors are displayed to this scale.
The MAP_NodeInit() function initializes a node. The MAP_NodeDestroy() function frees resources allocated by a node (such as the item stack). To reinitialize a node, this function must be followed by MAP_NodeInit().
The MAP_NodeLoad() function loads a node from ds, returning 0 on success or -1 on failure. MAP_NodeSave() saves a node to ds.
The MAP_ItemInit() function initializes a node element structure.
The MAP_ItemSetCenter() function sets the centering offset of a graphical element. MAP_ItemSetMotion() sets the motion offset of a graphical element.
The functions MAP_ItemSetTile() and MAP_ItemSetAnim() associate a new tile or animation to the element r (of type MAP_ITEM_TILE or MAP_ITEM_ANIM).
The MAP_ItemSetLayer() function associates the graphical element r with the given layer. The layer does not need to exist; the element will not be visible if that is the case.
The MAP_ItemDestroy() function frees the resources reserved by a node element. It must be followed by MAP_ItemInit to reinitialize the node element structure.
The MAP_NodeMoveItem() function moves src_r from src_node to the node at specific map coordinates and returns 0, or -1 if the coordinates are outside of dst_map. The element is associated with the layer dlayer, unless it is -1.
The MAP_NodeCopyItem() function inserts a copy of src_r on top of dst_node, and associate with dst_layer (unless it is -1).
The MAP_NodeDelItem() function detaches and destroys the given node element.
The MAP_NodeAddTile() function creates a graphical element (a reference to a RG_Tile(3)), where tileID is a tile name (an index into the tiletbl of a RG_Tileset(3)).
The MAP_NodeAddAnim() function creates an animation element (a reference to a RG_Anim(3)), where animID is an animation name (an index into the animtbl of a RG_Tileset(3)).
MAP_NodeAddWarpPoint() Creates a warp point, where targetMap is the pathname of the destination map (as returned by AG_ObjectCopyName()), and the x, y and dir arguments describe the initial position and direction of the object (whatever it may be) in the destination map.
MAP_AttachActor() attaches the given actor to the map. An object dependency is automatically created, and the map operation of the actor is invoked. This operation is usually responsible for inserting tiles onto the map.
MAP_DetachActor() detaches the given actor from the map. Any pending timer events related to the actor are cancelled, tiles related to the actor are removed and the object dependency is removed.
See MAP_Actor(3) for more information.
|AG_Object(3), MAP_Actor(3), MAP_View(3), SG_Intro(3)|
|The MAP interface first appeared in FreeSG 1.0. It is based on the Agar-MAP library originally in Agar-1.0.|