So I was attempting a 'Hit the X' game (e.g Toss the turtle, spank the monkey) in which an uncontrollable object travels across the screen in hopes of hitting certain objects and avoiding others.
My dilemma is how to efficiently create and destroy these objects with respect to the character - that is, if the player is at, say, (90,34), all objects whose x position is less than 90 are garbage collected while more objects are generated at x > 90 or 100.
The only solution I could think of was to: randomly populate a tree that organizes by X values at the start of each round and to simply trim off the leaves at every so frames - if the player hits a certain spot, in which the tree is looking scrawny, start adding some more random objects on.
But this seems inefficient and unwieldy. Does anyone have any suggestions?