//clase jugador--------------------------------------
class Jugador extends Padre{
private float x,y,velocidad;
private PImage grafico = loadImage("jugador.png");
private Disparo disparo1;
private int contador;
public Jugador(){
super();
imageMode(CENTER);
this.x = 320;
this.y = 400;
this.velocidad = 5;
this.contador = 0;
}
public void draw(){
mover();
disparar();
image(grafico,x,y);
}
private void mover(){
if(keyPressed && key == CODED && keyCode == LEFT){
x -= velocidad;
}else if(keyPressed && key == CODED && keyCode == RIGHT){
x += velocidad;
}
if(keyPressed && key == CODED && keyCode == UP){
y -= velocidad;
}else if(keyPressed && key == CODED && keyCode == DOWN){
y += velocidad;
}
}
private void disparar(){
contador++;
if(keyPressed && key == 'z' && contador > 5){
disparo1 = new Disparo(x,y);
contador = 0;
}
}
} //fin clase jugador------------------------------------
In the move method I am moving the player with the keys but if I press two keys like up and left it does not move diagonally, as it would.