I´m working on a game in wich i have two balls. Both Balls should be movable at the same time, the first one with w,a,s,d and the second one with the arrow keys. My problem is that i can always only move one object. Are there some fundamental steps i missed out? please help me!
// Ball 1 movement
void draw(){
if(keyPressed){
if (key == 'w' ){
ballY1 = ballY1 - 3;
}
if (key == 's' ){
ballY1 =ballY1 + 3;
}
if (key == 'a'){
ballX1 = ballX1 - 3;
}
if (key == 'd' ){
ballX1 = ballX1 + 3;
}
// Ball 2 movement
if(keyPressed){
if (keyCode == UP ){
ballY2 = ballY2 -3;
}
if (keyCode == DOWN ){
ballY2 = ballY2 + 3;
}
if (keyCode == LEFT){
ballX2 = ballX2 - 3;
}
if (keyCode == RIGHT){
ballX2 = ballX2 + 3;
}
}
This is not my whole code!!! I left out all the other code like drawing the ellipses or the variables because it might be distracting and i only need help with this specific thing.