-
-
Notifications
You must be signed in to change notification settings - Fork 120
Game Map
Kaetram uses Tiled map editor for easily managing large tilemaps. We support a large amount of the features of Tiled editor. These include rotations, polygon tools, and animations. The program works by layering chunks of a tilesheet onto a canvas, these chunks (represented by their pixel dimensions, e.g. 16x16, 32x32, etc) are placed one by one to produce an image. Once the map has been created to the author's liking, it is parsed by Kaetram's parser and all the necessary data is compressed neatly.
Each tilemap contains one or more tilesets, these are the images that we use to place tiles from. A tile is a defined group of pixels out of the tileset. For example, Kaetram by default uses 16x16 pixels to represent a tile. Given the versatility of the game engine, you can place larger tile maps and with some adjustments have them work with Kaetram. Each tile on the tilesheet corresponds to an ID. The first tile is ID 0, the next is ID 1, and so on. When we reach the border of the tilesheet, we move to the next row and continue counting. When we combine multiple tilesheets together, the counting starts over with each new tilesheet. When we actually parse the tilesheet data in the client or server, we append the last ID of the previous tilesheet to the first ID of the next tilesheet. Consider two tilesheets of size 1024x1024 pixels and a tile size of 16x16. Each tilesheet will have 4096 tiles. Since we begin counting at 0, the last tile is 4095, meaning that the first tile ID of the second tilesheet is 4096. When we refer to a tile ID in the client for rendering purposes, we must first pinpoint which tilesheet the tile corresponds to. By storing the first and last tile ID for each tilesheet, we can easily iterate and determine where the tile belongs.
The tiles in each tileset can be assigned properties. These are provided to manipulate the behaviour of in-game elements. In order to access the tile property menu, click the wrench button at the bottom of the tilesets window.
You should be able to see all the tiles available in the tileset. Upon clicking them you have a couple options to manipulate said tile. On the left-hand side you can add properties. The available properties are as follow:
-
c
- (No value needed) Collision tile, this tile will be considered a collision tile and will not be walkable -
v
- (No value needed) Represents a 'high' tile, that is, a tile drawn on top of other players and mobs -
o
- (No value needed) An interactable collision tile. Players cannot walk on it, but can walk up to it, at which point the server handles the action. -
h
/obs
(No value needed) Obstructing/hidden tiles. These are tiles which, when on the topmost layer, the tiles of the layers below will not be parsed. We use these when we want to eliminate unnecessary tile rendering. -
cursor
- Takes a string value correlating to a cursor sprite. Only applies if the tile has the 'o' property. When this property is present, a specified cursor will be shown when the player is hovering over the tile. -
tree
/stump
/cutstump
- Takes a string value relating to the type of tree. This property is used by the resource system to determine the type of tree, and the stump that it will be replaced with upon being cut. This is part of the dynamic tiling system which changes the static nature of the world map and relays updates to all players. -
rock
/rockbase
/rockempty
- Same as the tree properties, but used for rocks.
Animations can be accessed by selecting a tile and pressing the camera button at the top of the Tiled application.
This menu allows you to create animations and specify the animation speed between frames. The client automatically handles the animation. You can begin adding animations by drag and dropping the tiles into the left menu of the animation menu. Start with the tile you selected.
The tilemap contains a series of layers. These are divided into two types, object layers and tile layers. Object layers are used to apply properties to a specific portion of the map. For example, we may use object layer to play music when a player enters an area. Tile layers are where all the visuals take place. We use these layers to structure tiles on top of one another.
There are a couple special tile layers which we will discuss. These include the 'blocking,' 'entities,' and 'plateau' layers:
- Blocking: The blocking layer is an additional collision layer used in situations where you do not want to set the tile property of a tile to be colliding all the time, but there are times when you want it to be colliding. An example includes the cliff edges, though you want players to walk on them in most cases, you do not want them to be walkable when in a cave and the cliff is supposed to act as a wall.
- Entities: Tiles placed on the entity layer must be from the
Entities
tilesheet. The string value of the first property of the tile placed in the layer corresponds to the key of the mob/item/NPC that we want to spawn. - Plateau: These special tiles are used to delimit mob roaming and attacking conditions. A mob that spawns on a plateau (default 0) can only roam within that plateau. A mob or a player that is on a plateau level lower than its intended target will not be able to use ranged attacks. This is used to prevent players from safe-spotting mobs.
The remaining tile layers are normally rendered and the respective tile properties are stored into the exported map file upon processing.
NOTE: When layering tiles it is generally good practice to not draw full tiles on top of other tiles unnecesarily. Though this will not cause issues (unlike before), for the sake of convention, where possible, and where time restraints aren't an issue, it is still good practice to remove the tiles behind full tiles. The
h
tile property handles these cases automatically and reduces the array of tiles to one if it detects that the tile is the topmost on its index. The following is an example of such:
Object layers are used for applying special properties to one or more tiles on the map. For example, we can specify a door property at a coordinate, or we can specify an area where if the player enters we apply an overlay. In order to create an object in one of the layers, select the layer and use one of the object tools in the toolbar:
Note: It is preferable to use rectangular objects in most cases, though polygons are supported, rectangular objects produce less overhead.
The following are the available object layers:
- Dynamic - Dynamic tiles are tiles that undergo changes according to a player's progress. For example, if a player completes an achievement, a door may become accessible. Dynamic properties consist of a rectangular area, the necessary property for the area must be and object type named
mapping
. Themapping
property is then connected to another object that we want the tiles to be replaced with upon completing an achievement or quest (specified in the properties as well). For example:
In this example, the rectangular object maps to the another rectangular object (ID 350). When the achievement with they key pathofdeath
is completed, the empty area (for this example) will be replaced with the tiles in the mapped object (ID 350).
-
Overlay - The overlay object layer creates rectangular objects that change the graphics on the client-side. These overlays can also apply status effects, for example when entering the snowy mountains, a freezing effect, a darkening effect, and a fog image overlay is applied on the top-most rendering canvas:
This system will be expanded after more development decisions are made regarding the rendering system.
-
PVP - Used to denote an area in which if the player enters they will be able to attack other players.
-
Chests - Chest areas are used for killing tasks. A chest area will look for all the mobs in the area, when a player kills all the mobs a chest will spawn. The properties for these objects are as follows:
-
items
- A list of item keys that the chest will drop (separated by comma, picked randomly). -
spawnX
- The X grid coordinate where the chest will spawn. -
spawnY
- The Y grid coordinate where the chest will spawn. -
achievement
- (Optional) The key to an achievement that we want to reward the player with.
-
- Chest - Spawns a singular static chest at a coordinate (must be the size of a tile, if bigger then the first coordinate of the first tile will be used). A static chest appears and re-spawns after it has been looted. The properties for chest objects are as follow:
-
items
- A list of item keys that the chest will drop (separated by comma, picked randomly). -
achievement
- (Optional) The key to an achievement that we want to reward the player with.
-
- Doors - Doors are handled entirely through the tiled map editor. It is a matter of creating two objects, adding the
destination
custom property to both (type object), and connecting them together. The available properties are as follow:-
destination
- The ID of the object that we want to teleport the player to (another door object). -
quest
/stage
- (Optional) Used for quest progression, used to indicate that the player must be at a certain stage of a quest before being able to pass through the door (the quest must be active). After the player passes through the door, the quest will advance. -
level
- (Optional) Requires a level to be reached before passing through. -
reqItem
/reqItemCount
- (Optional) Requires an item to be in the player's inventory before passing through (reqItemCount
indicates how much of that item player must have, defaults to 1 if not specified). -
reqQuest
- (Optional) Requires a quest to be completed before passing through. -
reqAchievement
- (Optional) Requires an achievement to be completed before passing through.
-
- Warps - Warps are objects that player can teleport to using the warp menu. The warps and the properties specified in the map file must correspond to the warp enum names provided in the
Modules
. The available properties for a warp object are:-
name
- The name of the warp (must correspond to the warp enum name). -
level
- (Optional) Requires a level to be reached before being able to use the warp. -
quest
- (Optional) Requires a quest to be completed before being able to use the warp. -
achievement
- (Optional) Requires an achievement to be completed before being able to use the warp.
-
- Music - Similar to an overlay area, this is a simple rectangular (or polygon) object that specifies the key of the song that will play (corresponds to the filename). The available properties are:
-
song
- The key of the song that will play.
-
- Signs - Objects placed on top of tiles with the
o
property. Upon interacting with the object, the game will display text of the sign until the list of text is exhausted (the list is a series of words separated by commas). Each comma represents one text bubble in-game. The available properties are:-
text
- The text that will be displayed in-game, separate by commas.
-
- It is good practice to try and place objects in the tile layer that corresponds with their type (trees in the trees layer, water in the water layer, etc). If you are unsure, the miscellaneous layer is a good place to put objects that do not fit into any other layer.
- When placing ground, have at least 3 layers for the ground, and start working based off the middle one. This is because certain ground tile have dirt tiles beneath them.
- Avoid creating unnecessary tile layers, this can lead to a disorganized map file, which becomes much harder to maintain.
- Use the camera view port to space out areas. The rule of thumb is that for Kaetram the camera (zoomed out to the max) can see about 30 tiles width-wise, and 15 tiles height-wise. This may vary depending on what you use this engine for, or if you modify the size of the tiles.
- Do not place the same trees right next to one another. Trees are parsed recursively by looking through all the neighboring tiles, so you must give at least 1 tile distance between same trees. You may place an
oak2
andoak3
next to one another, but not anoak2
andoak2
.