Physics & Camera - Infinite floor
Posted: Thu Sep 30, 2021 8:20 pm
Hello.
I'm hacking together something where I've got a ball which gets launched as if out of a cannon, and a floor the ball bounces on until it comes to a stop - it's basically an adaptation of the physics tutorial in the wiki. I've added a "camera" to keep the ball in frame based on what's in this tutorial video - basically calling love.graphics.translate() before drawing the ball.
The issue I'm having is that the floor the ball bounces on gets moved out of frame, so after the ball moves out of the first "screen" the ball has nothing to bounce on anymore. I can of course make the ground wider, but in my ultimate game it will be theoretically possible for the ball to keep flying/bouncing forever (eventually there will be obstacles and such to stop them) - recall the old Nanaca Crash Flash game if that helps.
There's three solutions I can think of;
One - I constantly reposition the ball "sprite" so that its X value doesn't actually change, but reposition other elements in the game field so that the appearance of movement is persisted. I don't like this idea since it seems like it'd be a lot of work and not worth using physics or camera concepts in the first place.
Two - I constantly reposition the floor to always be under the ball depending on what the X position of the ball becomes after physics are applied. This seems like a relatively simple approach, but I'm not sure if it's the best, because maybe there's…
Three - Some part of the Physics module I'm not aware of which lets you place an infinite "floor" or other border in a world.
What would be the best approach for this sort of thing? Thanks in advance for your feedback.
I'm hacking together something where I've got a ball which gets launched as if out of a cannon, and a floor the ball bounces on until it comes to a stop - it's basically an adaptation of the physics tutorial in the wiki. I've added a "camera" to keep the ball in frame based on what's in this tutorial video - basically calling love.graphics.translate() before drawing the ball.
The issue I'm having is that the floor the ball bounces on gets moved out of frame, so after the ball moves out of the first "screen" the ball has nothing to bounce on anymore. I can of course make the ground wider, but in my ultimate game it will be theoretically possible for the ball to keep flying/bouncing forever (eventually there will be obstacles and such to stop them) - recall the old Nanaca Crash Flash game if that helps.
There's three solutions I can think of;
One - I constantly reposition the ball "sprite" so that its X value doesn't actually change, but reposition other elements in the game field so that the appearance of movement is persisted. I don't like this idea since it seems like it'd be a lot of work and not worth using physics or camera concepts in the first place.
Two - I constantly reposition the floor to always be under the ball depending on what the X position of the ball becomes after physics are applied. This seems like a relatively simple approach, but I'm not sure if it's the best, because maybe there's…
Three - Some part of the Physics module I'm not aware of which lets you place an infinite "floor" or other border in a world.
What would be the best approach for this sort of thing? Thanks in advance for your feedback.