2D tilemap water physics

Started by
1 comment, last by NukeCorr 13 years ago
Hey hey, I see a new website and forum. Long time since I was here, but anyway..

I'm programming a 2D game with C++ and openGL. I have implemented 2D water physics but it seem to eat lot of fps on slower computers. I have tilemap 200x200 size and water is a tile or many tiles.
My code runs through the whole tilemap with for() loops searching for tiles that are water and drops them or moves them, etc.
I've noticed the for() loops through the 200x200 tilemap is very slow and on my betatesters' older computers fps drops alot.
What would be the efficient method to check tiles for water and not lose too much fps on large tilemaps?

edit. so the question would be: what are the alternative methods for for() loop?

ps. if the video gives you any better perspective on this topic, here's a clip how the water/lava works
What the h*ll are you?
Advertisement
I am not completly sure if this will help, but while looking up octree's i came accross an article that used them for collision. It splits the screen into 4, then each part into another 4 and so on, and so on, using this method you may be able to check sections of your array or screen, and leaving out others that have no water at all. Like i said i really dont know if that will help you at all. But its worth looking into :)
That might be the method I've been looking for, atleast for now.
I'll try that one, although I'm open for every suggestion
What the h*ll are you?

This topic is closed to new replies.

Advertisement