I am trying to make a game similar to a game on the Play Store, called 'Sine Line'.
I am not able to figure out how to keep the particle oscillating when input is not given. When input is given, the particle should travel in a sinusoidal manner. But when you release the input, it shouldn't stop. Instead, it should keep oscillating along the X axis. Any help appreciated.
Thank you in advance.
P.S. I am attaching the JS file. I've written it in a very messy manner. Sorry for that.
game.js