Mejor comprobación del movimiento de la nave
This commit is contained in:
@@ -28,17 +28,23 @@ public class Jugador extends Actor {
|
||||
public void actua() {
|
||||
if (movIzq && this.x > 0) this.x -= velocidadX;
|
||||
if (movDer && this.x + this.ancho < Arkanoid.getInstance().getCanvas().getWidth()) this.x += velocidadX;
|
||||
|
||||
// Comprobaciones adicionales para evitar que se pase fuera del borde
|
||||
if (this.x < 0) this.x = 0;
|
||||
if (this.x + this.ancho > Arkanoid.getInstance().getCanvas().getWidth())
|
||||
this.x = Arkanoid.getInstance().getCanvas().getWidth() - this.ancho;
|
||||
}
|
||||
|
||||
public void movimientoRaton(int x, int y) {
|
||||
x = (x - ancho / 2);
|
||||
x = x - (this.ancho / 2);
|
||||
|
||||
if (x > 0 && x < Arkanoid.getInstance().getCanvas().getWidth() - this.ancho) this.x = x;
|
||||
if (x >= 0 && x <= Arkanoid.getInstance().getCanvas().getWidth() - this.ancho) this.x = x;
|
||||
}
|
||||
|
||||
public void movimientoTecladoDerecha(boolean derecha) {
|
||||
this.movDer = derecha;
|
||||
}
|
||||
|
||||
public void movimientoTecladoIzquierda(boolean izquierda) {
|
||||
this.movIzq = izquierda;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user