Open shikaan opened 5 months ago
Some options to implement tile maps.
In this case the format would define everything it needs. It would define map and tiles and tiles are expected to be dumb: they would only represent graphical elements, but they would not encode any behaviour (e.g., triggers) or any data (e.g., altitude, terrain type etc). Additional behaviour needs to be added ad additional game objects. It looks very much like the example in the beginning.
Pros:
Cons:
Questions:
Another idea would be to make maps not declare entirely what they need, but reference a tile map which needs to be provided programmatically
#v0.1#
8 // tile height in pixels
8 // tile width in pixels
32 // map height in tiles
32 // map width in tiles
11111122221111122222111122211111
11111222211112222211111111111111
00000000000000000000000000000000
33333333333333333333333333333333
33333333333333333333333333333333
And this would be parsed like
class Tile : public Object {}
using TileFactory = function<Tile*()>;
MapParser::fromString(string map, vector<TileFactory> tiles);
Pro:
Cons:
TileFactory
list), which might lead to inconsistent state between tools and gameWe could have something entirely declarative, data included. Similar to what tiled does.
#v0.1#
8 // tile height in pixels
8 // tile width in pixels
32 // map height in tiles
32 // map width in tiles
#tile definitions#
1: grass 1 # values that map to a struct, e.g. sprite=grass collide=1(=true)
4: bush 0
#map#
11111122221111122222111122211111
11111222211112222211111111111111
00000000000000000000000000000000
33333333333333333333333333333333
33333333333333333333333333333333
Pros
Cons:
Questions:
Current idea
#v0.1#
8 # tile height
8 # tile width
10 # width
10 # height
a # background color
# map
----------
----------
----------
----------
----------
----------
--BBMBBM--
----------
--G-----G-
FFFFFFFFFF
# definitions
B:assets/tiles/block.lbsp;
M:assets/tiles/mystery.lbsp;
G:assets/tiles/goomba.lbsp;10,1;
F:assets/tiles/floor.lbsp;
Decisions:
Trade offs:
Open points:
X,Y:0,1,2,3
where the coordinates represent the position of the object whose parameters you want to set. Now all the chests can be indicated by the same symbol. We need to define a divider for this.ClassName;X,Y;0,1,2,3
#v0.1#
8 # tile height
8 # tile width
10 # width
10 # height
2 # layers (1-4, maps altitude)
a # background color
# altitude 0
--------------------
--------------------
--------------------
--------------------
--------------------
--------------------
----B0B0M0B0B0M1----
--------------------
--------------------
FlFlFlFlFlFlFlFlFlFl
# altitude 1
--------------------
--------------------
--------------------
--------------------
--------------------
--------------------
--------------------
--------------------
----G0-----G0-------
--------------------
# definitions
# Mystery Boxes
M0:10;
M1:100;
# Goombas
G0:10,1;
Further iteration:
Tradeoffs:
We should probably also do something about using a tilemap. The current workaround is to have all the tiles on the same line (in the png case) and something like
RM.loadImageSprite("assets/tileset.png", "tile", 92, STOP_ANIMATION_SLOWDOWN);
But there are a few things we don't need here:
class Tile : public Object {
public:
Tile(int index) : Object("tile") {
this->setSprite("tile");
auto animation = this->getAnimation();
animation.setIndex(index);
animation.setSlowdownCount(STOP_ANIMATION_SLOWDOWN);
this->setAnimation(animation);
}
};
We need some sort of support for tile maps and level editing. Might be something like we do for sprites and sounds with a text-based proprietary format.
Some ideas: