Quote Originally Posted by hwnd View Post
Is it faster than looping through X,Y?
I seriously doubt it is. Why? Becouse you are introducing two aditional mathematical functions which needs to be executed for every loop iteration.
I would gues someone used such approach as they stored whole map in 1D array and not 2D array. So "i" always represent index of the map tile in map array.

And there is another thing in the code that bothers me. What is that thing? Code inside for loop is making changes to for loop control variable. This should be avoided at all times as you can quickly cause infinite loop or compleetly screw up the whole loop.


Quote Originally Posted by hwnd View Post
One less loop to go?
It is not the problem of how many loops you have but what code is in those loops.
So my advice for you is go and try optimize the code which is inside the loops rather than trying to simply reduce hte number of loops used.
The loop mechanizm itself is prety fast so reducing the number of loop implementation won't give you much performance gain.
The only exceptions could be "for in" loops becouse they need to introduce aditional abstract layer to work and that hinders their overal performance. I have talked about this in the thread below:
http://www.pascalgamedevelopment.com...ighlight=loops