How to move the image with the arrows

please format code with </> button * homework policy * asking questions

i don’t know how i can not leave the last button on read, so let the image doing two movments at the same time. i mean i don’t know how the image can jump and go straight or back either at the same time. i’m using the arrows and not wasd and to jump the space bar.
if we try to go right and suddendly we need to go left (so we keep the right arrow pressed and we press and release the left arrow) our image would continue on the left side even if we’re still pressing the right arrow. we think it’s because processing keeps reading the last key pressed.

if (keyPressed){
if (keyCode==RIGHT){
marioX+=3;
}
if (keyCode==LEFT){
marioX-=3;
}
}

1 Like

see Players Movement (Java) - OpenProcessing

see keyPressed and keyReleased with java(eclipse) - #3 by GoToLoop

1 Like

Hello @cisky,

There is a tutorial here for this:

:)

thanks for the awesome information.