I am currently optimising the collision detection code for the players bullet sprites with the game map.
The best way I can see is to sort the bullet sprites as suggeted in another thread.
This is the way the routine works at the moment:
1. Scan through the bullet structures to see which contain an on screen bullet.
2. Store used bullets structures X coord, Y coord and strucuture address in a table.
3. Sort the table into decending order (for example in the Y dimension bullets furthest to the top of the screen first, bottom of the screen last).
4. Scan through current tiles on screen coords and check with the sorted table, if an onscreen bullet has hit a tile read the structures address and set bullet status
accordingly. Read the next bullet from the table and check with the same tile if no collision move onto next tile.
Dong things this way means I only need to scan though the tiles onscreen once to check all onscreen bullets.
The problem I have is that only some bullets seem to be being detected.
Would I need to sort the bullets in the X dimension, sort the table and do a collision detect and then sort the bullets in the Y dimension, sort the table and do a second collision detect?
I know my sort routine works OK as it's from an old vectorball routine I wrote that sorted the balls into the Z dimension correctly.
I should also point out that the tiles are checked in the normal manner, left to right, top to bottom.
So let it be written, So let it be done. I'm sent here by the chosen one.