SetTile

From Spheriki

Jump to: navigation, search

Replaces the given tile on the currently loaded map with a new one.

Contents

Usage

SetTile(x, y, layer, tile);
  • x Number. The x coordinate of the tile to be changed
  • y Number. The y coordinate of the tile to be changed
  • layer Number. The layer number of the tile to be changed.
  • tile Number. The index of the new tile that will replace the old one.


Examples

The below is an example for a door opening trigger. In the map's tileset, the 50th tile is the bottom of an open door, and the 51st is the top of it. At the base of the door, on the layer the input person will be moving in, a map trigger is placed that contains a call to DoorOpen(x,y,layer); where x and y are the tile coordinates of the trigger, and layer is the layer number it is on. The DoorOpen function itself looks like:

 
function DoorOpen(x,y,layer) 
{ 
  SetTile(x,y,layer, 51); 
  SetTile(x,y-1,layer, 50); 
} 

So when the map trigger is executed, this function change the tiles below it with the opened door tiles. For added effect, a door opening sound may also be added into this function.


Notes

  • The map engine must be running with a map loaded for this function to be used.
  • Used when parts of the map need to be changed in real time, during a cutscene, or changing an existing map based on the actions of the player.
  • Common examples include opening a door (as given above), closing a gate, or springing a trap.
  • More elaborate examples can include a custom house for which the player can buy furniture for. So upon entry, if the player has bought something (a bed for example), then it will be added to the room at a particular spot. Another example would be random or procedural map generation.

See also

Personal tools