Sign in to follow this  

2D tilemap water physics

Recommended Posts

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

Share this post

Link to post
Share on other sites
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 :)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this