Hi,
I am kind of think in out loud and wondering what is best, or even normal prodedure with building map/tile based games.
There is only so much each frame cycle can do before it has an effect on how the game runs, so I am looking for advice on how to keep the map drawing at optimal performance to allow for other events within the same cycle.
In the main loop (if the map is bigger than the visible screen), is it best to:
a. iterate through the tileset/map (see pseudo) and draw the whole map each frame (also in the loop, checking each tile for player/tile collisions)
b. iterate through the tileset/map (see pseudo, would need modifying) and draw only what is viewable (again, checking each tile for player/tile collisions)
c. Before the main loop, draw the map, copy it to an image or something, and then in the main loop draw that image (checking collisions based on a color mask?)
I am favouring "b", but as game development is new to me, I am wondering if this the correct way or what other approaches there are.
Many thanks,
I am kind of think in out loud and wondering what is best, or even normal prodedure with building map/tile based games.
There is only so much each frame cycle can do before it has an effect on how the game runs, so I am looking for advice on how to keep the map drawing at optimal performance to allow for other events within the same cycle.
In the main loop (if the map is bigger than the visible screen), is it best to:
a. iterate through the tileset/map (see pseudo) and draw the whole map each frame (also in the loop, checking each tile for player/tile collisions)
b. iterate through the tileset/map (see pseudo, would need modifying) and draw only what is viewable (again, checking each tile for player/tile collisions)
c. Before the main loop, draw the map, copy it to an image or something, and then in the main loop draw that image (checking collisions based on a color mask?)
I am favouring "b", but as game development is new to me, I am wondering if this the correct way or what other approaches there are.
'Pseudo (very rough and straight from my head): Type TMap Field x:Int Field y:Int ... Function DrawMap(sLevel) RestoreData sLevel For Local iCols:Int = 0 to 6 For Local iRows:Int = 0 to 3 Read Local iTile:Int DrawImage( TImage, iCols * 32, iRows, iTile) ' TImage is pointing to imagearray (LoadAnimImage...) Next Next End Function End Type #level_1 DefData 1, 2, 2, 2, 2, 2, 3 ... DefData 1, 2, 2, 2, 2, 2, 3 #level_2 DefData 1, 2, 2, 2, 2, 2, 3 ... DefData 1, 2, 2, 2, 2, 2, 3
Many thanks,