I'm replicating a breakout following a couple tutorials and I found that in both cases they make the paddle stay un mouse.x position or lerp to it, to smooth the movement, but I can make the paddle go away from the sides of the screen and I want it to stop at some point.
If I use bound to layout, the paddle bounces against the layout wall, but... what if I want it to bounce on a different surface? Because of the X position re-positioning itself constantly, it ignores the solid behaviour of the walls. There's no actual movement, but an X position change.
I can't figure out how to make the paddle stop on, for example, a frame that I make to contain the gameplay area.
The only idea I have is to extend the paddle and make the far sides invisible, so they impact before the paddle hits the layout border, but... I don't know. Don't feel very comfortable with that solution.
Any help is very welcome. Thanks in advance and best regards.
Develop games in your browser. Powerful, performant & highly capable.
You can simply do something like this:
paddle set X to clamp(mouse.x, 50, 1030)
or you can make a more sophisticated formula that takes into account paddle.width, layoutWidth etc.