when user hit up key, jump get set to true and when user let go of up key jump get set to false.
gravity = 2
velocity = 20
y = y postion of my player
problem:
1st - if i hold up key my player go up 20 pics, but when i keep on going down for ever.
2nd - if i hit up key and let go, then hit up key and let go, and so on ..... it keep on going up for ever.
while(true){ if(jump == true){ velocity -= gravity; y -= velocity; } else if(jump == false){ velocity = 20; } }
problem #2 is bc i am seting velocity = 20 in else if. to fix this problem i can just del the statment.
problem #1 is really hard and i cant find a good sloution for it. may be if i have a test inside of
if(jump == true){