Refactor if statements
parent
7914a78522
commit
1a37787012
|
@ -29,22 +29,10 @@ public class GenericSprite extends Rectangle{
|
|||
//updates the direction of the ball based on user input
|
||||
//if the keyboard input isn't any of the options (d, a, w, s), then nothing happens
|
||||
public void keyPressed(KeyEvent e){
|
||||
if(e.getKeyChar() == 'd'){
|
||||
rightPressed = true;
|
||||
|
||||
}
|
||||
if(e.getKeyChar() == 'a'){
|
||||
leftPressed = true;
|
||||
|
||||
}
|
||||
if(e.getKeyChar() == 'w'){
|
||||
upPressed = true;
|
||||
|
||||
}
|
||||
if(e.getKeyChar() == 's'){
|
||||
downPressed = true;
|
||||
|
||||
}
|
||||
rightPressed = e.getKeyChar() == 'd';
|
||||
leftPressed = e.getKeyChar() == 'a';
|
||||
upPressed = e.getKeyChar() == 'w';
|
||||
downPressed = e.getKeyChar() == 's';
|
||||
move();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue