Each object in the level is expected to have a filled in type property as well as a filled in name.
The type property is used to load the object in the level using the following path: res://objects/type/type.tscn
Custom properties exist for specific object types. These propoerties are read from objecttypes.json when editing the level in Tiled.
When creating the level in-game, the setup() method is called, passing a dictionary to the object with it's properties. It is up to the object to set them. If the object does not have a setup() method, a warning is raised.
For saving and loading objects, two functions exist: get_stats(), and set_stats().
If it is needed for an object to save/restore its stats on level entry and exit, it can be added to the group saveOnExit.
When fetching stats for an object (Config.getStatsOrNull(levelName: String, object: Object)), there are two places that are checked. One is Config.saveData which contains the data from the save file. The other is Config.saveBuffer which contains stats that have been changed this session, but not yet stored in the save file.
Triggers
Objects on the trigger layer are considered to be triggers. They are converted to Area2Ds and run code when the player enters or exits them. The scripts are loaded from objects/0triggers/type_trigger.gd. In the level, the _trigger suffix is omitted in the object type, so transition_trigger simply becomes transition.
camera
When the player enters, their camera's limits are snapped to the area. When the player leaves, the camera limits are returned to their previous values. Due to the current implementation, the areas cannot overlap without the camera getting stuck.
x,y,width,height- camera bounds
transition
Handle horizontal transitions. The player's position on exit is kept proportionate to their position when entering
dest_door- destinationtransitiontriggerdest_level- level path(relative tores://tiled/levels) without extension to which the trigger should send the player. Ifdest_levelisnone, the trigger will not activate.
transition_vertical
Handle vertical transitions. Inherits properties from transition.
The player's x position on exit is proportionate to their x position on entry
Each of the flags specifies if there is a ledge for landing in that area. The ledges have to be placed accordingly to ensure the player is able to reach them.
Diagram showing different transition rules
Exiting from the top
- If neither flags are set, the player's x position on exit remains relative to their x position on entry
- If one flag is set, the player jumps onto the only ledge.
- If both flags are set, the player jumps onto the ledge in the direction they were facing.
Exiting from the bottom
- If neither flags are set, the player's x position on exit remains relative to their x position on entry
- If one flag is set, the player falls to the only ledge
- If both flags are set, the player falls onto the ledge that lies in the direction they were facing.
Properties
dest_door- seetransitiondest_level- seetransitionleftTop- if the trigger has a top left ledge as an exitrightTop- if the trigger has a top right ledge as an exitleftBottom- if the trigger has a bottom left ledge as an available exitrightBottom- if the trigger has a bottom right edge as an available exit
Metadata
These obejcts store general information about the level
level
Stores basic level information
darkness- how dark the level is from 0 to 1.0music- what music to load (unimplemented)script- what to set the level script to. See titlescreen.tmx as an example.x,y,width,height- camera bounds
background
Specifies which paralax backgrounds to load
n/texture- path(relative tores://tilesets/) to texture to use for thenth layer.n/scroll_x- x motion scale for the parallax layern/scroll_y- y motion scale for the parallax layer
Other
bush
A bush that can be harvested by the player. Regrows over time.
branches- amount of branches for the plant to have. This is used when loading the texture. An example texture path isitems/001_bush_3.pngwhich is used by bushes with an item id of1, and3branches. The item id is padded to a length of 3 with 0's. The amount of branches is also used when harvesting(items/bushes.txt).itemName- item name for the bush to use. The itemidis derived from this. An example would befungusticks- the starting amount of ticks to use when loading the level for the very first time
door
A simpler version of the transition trigger. When intercted with, moves the player to the corresponding door.
dest_door- seetransitiondest_level- seetransition
overworld_item
A collectable item that can be placed in the map. It is added to the player's inventory when they touch it.
infinite- allow infinite respawnsitemName- name of item to give when collecteditemAmount- amount of item to giverespawn- number of times to respawn. A value of0will only allow the item to be collected oncerespawnTime- (unimplemented) time in seconds after which to respawn. After this amount of time has passed, the item will respawn again on room entry.
save
A lamp used for saving the game. The currentSlot from levelManager is used.
lampColor- color of light
player
The player object. This is where the player is placed if they did not go through a door or transition.