I am coding a tile based game. The levels are about 512x512 fields - but may also be bigger (>= 256.000 objects). The tiles consist of a floor plane and may contain objects lying on the floor - e.g. diamonds to pick up or walls,...
Tiles don't collide with each other - only the player interacts with the world.
For the game only the tiles in the neighborhood of the actor are relevant for the game. It should be enough to calculate only 6x6 squares around the player.
Due to limination on the destination platform (mobile device) initialising the complete world could exceed the available memory on the plattform.
So I am currently thinking about only adding the relevant parts of the world before calculating the next simulation step. This means that in the worst case I have to exchange 11 tiles (if the player moved diagonal)...
Code: Select all
R R R R R R P = Player
. . . . . . R . . . . . A A = Added Tiles
. . . . . . R . . . . . A R = Removed Tiles
. . . . . . R . . P . . A
. . P . . . => R . . . . . A
. . .\. . . R . . . . . A
. . . . . . A A A A A A
Which would be the best broad phase to implement this?
So the broad phase algorithm itself should just do nothing - except that it should be very fast to add and remove objects.
Or ist it possible to run without a broad phase?
Is it possible to reuse the collision shapes from the tiles removed to avoid allocation/freeing of memory?