erikwatson / Bramble

A little JS game engine for jamming on prototypes.
MIT License
0 stars 1 forks source link

Tile Maps #3

Open erikwatson opened 5 years ago

erikwatson commented 5 years ago

We should be able to draw tiles from tilesheets, however there are a couple of ways we might want to do this that need to be considered.

Simple

Each number in the grid represents a different tile graphic, it's up to you to place each different tile graphic by hand.

const grid = [
  [0, 0, 0, 0, 0],
  [0, 1, 2, 3, 0],
  [0, 4, 5, 6, 0],
  [0, 7, 8, 9, 0],
  [0, 0, 0, 0, 0]
]

Auto-Tile

Each number in the grid represents a different type of terrain, and an algorithm figures out which graphic needs to be placed from the sheet by considering it's neigbouring tiles.

const grid = [
  [0, 0, 0, 0, 0],
  [0, 1, 1, 1, 0],
  [0, 1, 1, 1, 0],
  [0, 1, 1, 1, 0],
  [0, 0, 0, 0, 0]
]

Custom

I am unsure how this might fit in just yet, need to think on it, but I may want to build more complicated versions of the Auto-Tile functionality.

Perhaps you want extra variants for each tile, maybe you want to occasionally add decorations on top of a certain type of tile, etc.

I imagine the Grid representation would remain the same as for Auto-Tile.

const grid = [
  [0, 0, 0, 0, 0],
  [0, 1, 1, 1, 0],
  [0, 1, 1, 1, 0],
  [0, 1, 1, 1, 0],
  [0, 0, 0, 0, 0]
]
erikwatson commented 3 years ago

Unity calls auto-tiling that looks in all 8 directions “terrain” and they call auto-tiling that only looks in 4 directions “pipeline”.

Terrain was already in here before I saw this, it’s a natural fit. Pipeline is less comfortable but it is quite good, evocative.

It seems to me that much like Unity has done it, we should have Terrain, Pipelines and a custom Rules Tile of some kind in case we want new, specific behaviour.

Once the Rule Tile is in the other two kinds can easily be built from it.