Store and create game objects at positions along terrain
- by Alex
I have a circular character that rolls down terrain like that shown in the picture below.
The terrain is created from an array holding 1000 points. The ground is drawn one screen width infront and one screen width behind. So as the character moves, edges are created infront and edges are removed behind.
My problem is, I want to create box2d bodies at certain locations along the path and need a way to store these creator methods or objects.
I need some way to store a position at which they are created and some pointer to a function to create them, once the character is in range. I guess this would be an array of some sort that is checked each time the ground is updated and then if in range, the function is executed and removed from the array. But I'm not sure if its even possible to store pointers to functions with parameters included... any help is much appreciated!