Terrain definition - all_terrain.json

Post Reply
Stratego (dev)
Site Admin
Posts: 15752
Joined: Fri Apr 25, 2014 9:28 pm

Terrain definition - all_terrain.json

Post by Stratego (dev) »

The all_terrain.json contains the information about the image and its section to be used as a specific tile (tile ID).
so contains
- imagename,
- image "map",
- and tile ID reference.
- and other helper options

Code: Select all

{
        "id":7500,
        "imgName":"terrain/terrain_elevation.png",
        "imgTilesetColumnCount":10,
        "imgTilesetPosition":null,
        "imgCropToRect":{"top":0, "left":0,"bottom":32,"right":96},
        "imgTilesetPositionRange":"+20",
        "imgTilesetTileSize":32,
        "imgColumns":1,
        "layer":"TERRAIN_DECOR",
        "terrainClassName":"cliff"
     },
where:
"id": -> the tile ID (it can be used in the tile_join.json as a reference)
"imgName": -> the image name where the sprite in (in a tileset, or individual image)
"imgTilesetColumnCount":-> means the tileset image has this many "tile" comlumns
"imgTilesetPosition": -> which position this tile is on this image.
"imgCropToRect":{"top":0, "left":0,"bottom":32,"right":96}, -> set imgTilesetPosition to NULL this to take effect! this case you can define a mapping in the tileset saying which part or the image should be used as this tile (this example is a 32x96 animation mapping)
"imgTilesetPositionRange":"+20", -> if you set this number (with a + sign) than the logic automatically generates this many tiles from that tileset image (this case 1 + 20 = 21 tiles will be definer ID-s auto numbered )
"imgTilesetTileSize":32, -> pixel size of one tile.
"imgColumns":1, -> if set to more then 1 than the tile is an animation! all frames should be beside each other
Integer animFrameDuration; //unit animation how long a frame to show in millisecs, in case of NULL it will be the default 200ms.
long[] animFrameDurations; //in millisecs
int[] animFramePreDelayRandom = null; //!only work with animFrameDurations!: 2 values in array, 0th: randomFrom 1th:randomTo, rnd between values, and delay that amount of ms before starting animation.
Integer animLoopCount; //0 means forever, bigger value is the number of playings
"layer": -> TERRAIN_DECOR/TERRAIN targets the the 2 layers of terrain we have
"terrainClassName":"cliff" -> this name is for something i dont remember :) will check later. One i remember: on mapeditor UI you can select them by this classification.

Animated tiles

If u plan to use animations on mass of tiles (eg. water) - that would look good though - but
1) beware not to be annoying to see the map as a player - so VERY minor movement should only be set on water like a few pixel chanigng color maximum or something
2) since now the engine used static tiles only, so i dont know what would be the impact on performance playing an OCEAN like map where most water tiles animating - that needs testing if runs well.

Helper features
several attributes can be omitted as they AUTO-filled by the logic if they are not set

Code: Select all

      {
         "id":4600,
         "imgName":"terrain/terrain_road_decoration.png",
         "imgTilesetColumnCount":16,
         "imgTilesetPosition":0,
         "imgTilesetPositionRange":"+13",
         "imgTilesetTileSize":32,
         "imgColumns":1,
         "layer":"TERRAIN_DECOR",
         "terrainClassName":"roadd"
     },
{
         "id":4616,
         "imgTilesetPosition":16,
         "imgTilesetPositionRange":"+10",
         "terrainClassName":"roadd"
      },
  {
         "id":4632,
         "imgTilesetPosition":32,
         "imgTilesetPositionRange":"+11",
         "terrainClassName":"roadd"
      },
{
         "id":4648,
         "imgTilesetPosition":48,
         "imgTilesetPositionRange":"+2",
         "terrainClassName":"roadd"
      },
{
         "id":4652,
         "imgTilesetPosition":52,
         "imgTilesetPositionRange":"+6",
         "terrainClassName":"roadd"
      },
in this example
- the first item defines most things and "imgTilesetPositionRange":"+13", means total 14 tiles are defined as "roadd" decorations tiles.
- the upcoming tiles need no repeat all information as the logic "auto" fills them, so second definition defines additional 11 tiles
Stratego (dev)
Site Admin
Posts: 15752
Joined: Fri Apr 25, 2014 9:28 pm

Re: Terrain definition - all_terrain.json

Post by Stratego (dev) »

new tags:
Integer animFrameDuration; //unit animation how long a frame to show in millisecs, in case of NULL it will be the default 200ms.
long[] animFrameDurations; //in millisecs
Integer animLoopCount; //0 means forever, bigger value is the number of playings
Stratego (dev)
Site Admin
Posts: 15752
Joined: Fri Apr 25, 2014 9:28 pm

Re: Terrain definition - all_terrain.json

Post by Stratego (dev) »

new attribute for animations:
public int[] animFramePreDelayRandom = null; //!only work with animFrameDurations!: 2 values in array, 0th: randomFrom 1th:randomTo, rnd between values, and delay that amount of ms before starting animation.
Post Reply

Return to “Terrains and Graphic Design”