I’m looking for some idea’s on how to create the 2d layout (walk path) of a game.
The tiles will be 32×32 pixels aswell as the character moving on the tiles.
I’ve thought of two ways currently, havn’t tried any of them out yet.
The game will be shown in a window of about 400×300 or 512×356 something.. not much bigger than that where the game map itself could be bigger then 1000×1000. So only a portion of the map will be visible most times.
So here’s my 2 options as far as I’ve thought of them.
[1]: Create the entire map at the start (which might increase the loading times but it will make it more easy to move the map around) including each object, player, enemies etc etc.
[2]: Create only the map seen and 1 tile around it (which is not visible) so I can make that one visible with a story board and remove the row / column which is out of bounds and create a column again.
Which means, If I have a room of 5×5 tiles, and I load 7×7 tiles. If I move right, I move all the tiles left and keep the player in the middle of the screen. Then I remove the far left set of tiles and create a new set of tiles on the right side, which will hopefully be done before the storyboard has finished moving.
In the second method all I have to consider is objects that are larger then 32×32. How could I best react on those.. However, this is a problem I’d like to address later.. Right now I prefer to know people’s opinions and possible better methods.
I do apoligize if this question is no apropriate for stackoverflow.
Just be careful with the “load” word. Loading, means taking the data from the disk/drive and putting it memory. For that, you should load all the current world/map at once, before the game start. Trust me, you don’t want to get yourself in dynamic loading stuff while the map is running.
But you only need to load the definition of your map, you don’t need to create the instance of the object at that point. So you can create the instance from the map definition as the player walks… but are you really that constraint in memory? I can understand that for a game like Minecraft or Terraria where the map contains virtually millions of tiles… But for 32×32, you can consider making them all when you load the definition.
Of course, whatever the solution, you should only draw/compute/collide/update the tiles that are visible on screen.