Hey, i’m in the early process of writing a side-scrolling tile based game, and i have been trying to figure out which is the best way of caching tiles.
Idea 1:
I would store an instance of a tile class such as grass for every tile in the game (sounds very costly), this allows each tile to have its own unique properties (still being a subset of grass ofcourse).
Idea 2:
I would store the id of every tile in the game, and use a tile lookup table to retrieve a singleton instance of that tile, this option seems to be more fitting however then each tile of the same type must be the same globally, and couldn’t have different properties to other grass tiles.
Which idea would be the most viable, and if you have a better idea, please feel free to share it :).