🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

bigger mapsize slower frame rate

Started by
2 comments, last by RMZ 24 years, 5 months ago
Hi~~~ ^_^ I have a question here//// frame rate goes slow down when I set map size over 300x300.. Is there any way I could improve the speed? I blit only visible tiles but to find visible tiles I have to search entire map...
Advertisement
Why would you have to search the entire map to blit the visible tiles???
well, if you scan each frame to check for visible tiles, its naturally going to be inefficient.

when you suddenly jump from one location to another, THEN you have to scan the entire map, but if you are scrolling by small amounts, you only need to check the edges of the currently visible area. this should definitely speed up the process.

assuming you have tiles that are 64x32, meaning you can get about 30 rows of 10 tiles on the screen at a time, scrolling up or down by small amounts (less than 16 pixels) means you only have to check on 20 tiles (10 at the top to see if they change visibility, and 10 at the bottom to check for a change). left/right scrolling you only have to check 60, to scroll diagonally, you have to check 80 (scroll one way, then scroll the other). even if you have to check 80, you are still doing a lot better than the 90,000 you would have to check on a 300x300 map.

an alternate solution would be to deduce which tiles are non visible based on the playing area''s world coordinates.

find what tile your upper-left corner is on using a mousemap or whatever lookup device you use to map mouse position to world coordinates. move up one tile from that.
the tile you are now pointing to is NOT on the map. nor are any tiles to the north, west, or east. from this you can rule out the majority of your tiles without actually checking them. you can do the samething for other corners/edges of the map.

if you''re using a diagonal map, you may have to come up with a tilewalking class to help with this, since moving north/south/east/west on that type of map is actually moving diagonally on the map.

Get off my lawn!

Thanks for the answer.

This topic is closed to new replies.

Advertisement