Temple of The Roguelike Forums
Development => Programming => Topic started by: Shaggy on October 24, 2010, 01:27:08 AM
-
So for some reason I'm having a major brain fart today ::)
I can't for the life of me wrap my head around an ideal setup for maps in-game. I've got a Tile class [Character, Color, Walkable, Creature, and Item], as well as an array of tiles called CurrentMap which holds a screen-sized square of tiles, but that's not really working.
I either need to have a larger array of tiles that holds the whole map, or somehow load what's outside of the screen area in a buffer of some sort? I dunno. I just feel lost, and was wondering how you guys set up your map/tile classes and such? Not necessarily as in generation algorithms, but just as far as storing them and using the data in-game
-
The map is usually the size of level and part of it (view size) shown from offset.
-
You generally want your map objects to simply contain a level. You could for instance make a Map class that has a .get(x, y) method, which when called on coords that are in bounds returns the tile at those coords, and when called on coourds outside the bounds returns nothing but an undiggable wall. If you want to keep the @ at the middle of the screen when rendering the UI (assuming the upper left corner of your rendering window is (0, 0) on the screen), just take the screen position, subtract half the playing window size, add the player's position on the map, and call your .get() on that.