i have the following code to make an ellipse move to the left right top and bottom. but now the player can only move in one direction at the time. so if the player moves to the left he cant move to the to the top or bottom. how do i make my code so the player can move both left and right and to the top and the bottom at the same time? any suggestions are appreciated. :)
see the code that i have so far:
void userInput() {
if (keyPressed && (key == 's')) {
speedY = 1;
println("yes");
}
if (keyPressed && (key == 'w')) {
speedY = -1;
println("yes");
}
if (keyPressed && (key == 'd')) {
println("yes");
speedX = 1;
}
if (keyPressed && (key == 'a')) {
println("yes");
speedX = -1;
}
if (keyPressed &&(key != 'a' && key != 'd')) {
println("no");
speedX = 0;
}
if (keyPressed &&(key != 'w' && key != 's')) {
println("no");
speedY =0;
}
}
void movement() {
x = x + speedX;
y = y + speedY;
}