So basically right now my character moves at a constant speed left and right and what I would like to have is the character slowly speed up the longer the movement key (left or right) is pressed and then come to astop when its released.

Here is my move method right now.

1 2 3 4 5 6 7 8 9 10 11

publicvoidmove() {x += speed * dx;y += dy;

if(y > 760 || y < 0) {dead = true;x = startX;y = startY; }

dx is the value that determines if he moves left or right, switches between 0, 1, -1speed is a constant. currently set to 1.

If someone could update it and explain to me how works I would be super happy.

publicclassPlayerextendsThread{privateImageimage;privateThreadanimator; //animates the jumpprivatebooleanjump = false;privatebooleanjumping = false; //is in the middle of a jumpprivatebooleandone = false; //tells when jumping is doneprivatebooleanpeak = false; //tells when at peak of jumpprivatebooleanfalling = false; //if player is falling, or in the air stillprivatebooleanrising = false;privatebooleanmovingRight = false;

publicclassPlayerextendsThread{privateImageimage;privateThreadanimator; //animates the jumpprivatebooleanjump = false;privatebooleanjumping = false; //is in the middle of a jumpprivatebooleandone = false; //tells when jumping is doneprivatebooleanpeak = false; //tells when at peak of jumpprivatebooleanfalling = false; //if player is falling, or in the air stillprivatebooleanrising = false;privatebooleanmovingRight = false;

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org