al2f/umbrella
1
2
Fork
You've already forked umbrella
0
7 Objects
al2f edited this page 2023年01月13日 01:51:11 +00:00

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 - destination transition trigger
  • dest_level - level path(relative to res://tiled/levels) without extension to which the trigger should send the player. If dest_level is none, 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 - see transition
  • dest_level - see transition
  • leftTop - if the trigger has a top left ledge as an exit
  • rightTop - if the trigger has a top right ledge as an exit
  • leftBottom - if the trigger has a bottom left ledge as an available exit
  • rightBottom - 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.0
  • music - 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 to res://tilesets/) to texture to use for the nth layer.
  • n/scroll_x - x motion scale for the parallax layer
  • n/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 is items/001_bush_3.png which is used by bushes with an item id of 1, and 3 branches. 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 item id is derived from this. An example would be fungus
  • ticks - 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 - see transition
  • dest_level - see transition

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 respawns
  • itemName - name of item to give when collected
  • itemAmount - amount of item to give
  • respawn - number of times to respawn. A value of 0 will only allow the item to be collected once
  • respawnTime - (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.