I want to make a stick that starts falling left / right and every time you press a button the stick goes back to the otiginal angle.. if you press it very soon it will move there no problem but if you press the button too late the stick wont just go to the original angle, it will also move past it and go at the opposite negative angle!
I want to imitate the movement or Mr. Muscle when he starts falling to the left / right, (check on the android app store to see exactly)
What im doing now is:
Every 0.1 seconds i set the sprite's angle to: balance x (1+speed)
inside the every 01 seconds i check to see if a variable called goleftorright is 1 or 2 (1 for left 2 for right)
if its 1 then i add the value of 1 to balance and if its 2 i substract the value of 1 to balance
On button pressed i just switch goleftorright when its 2 to 1 and when its 1 to 2
and at the end it sets a boolean variable to true
After the set true is done i check if
Variable is True and then do Every 0.1 seconds add 0.01 to speed
On button touched = variable becomes false
'also here i have to reset speed somehow and set it to 0 before we start counting the time it took to press the button from the last time we pressed it. Thats how i measure the speed with which the sprite will move back to angle 0 or beyond
basically i just see the time it took to press the button and use that as a reference to the speed (the longer the time the higher the speed and so on)
This is more or less the code i've got up to now, doesn't seem to do the job properly.. any ideas?