Mejor uso del Singleton

This commit is contained in:
2025-02-06 20:30:28 +01:00
parent 497b40a6e7
commit 6d8e6e519b
3 changed files with 5 additions and 12 deletions

View File

@@ -119,7 +119,7 @@ public class Arkanoid {
for (int i = 0; i < Ladrillo.colores.length; i++) { for (int i = 0; i < Ladrillo.colores.length; i++) {
for (int j = 0; j < numLadrillosPorLinea; j++) { for (int j = 0; j < numLadrillosPorLinea; j++) {
actores.add(new Ladrillo(anchoLadrillos, 10, i, j, separacionBloques)); actores.add(new Ladrillo(anchoLadrillos, 10, i, j, separacionBloques, altoVentana/12));
} }
} }
@@ -175,11 +175,4 @@ public class Arkanoid {
return canvas; return canvas;
} }
public static int getAltoVentana() {
return altoVentana;
}
public static int getAnchoVentana() {
return anchoVentana;
}
} }

View File

@@ -27,13 +27,13 @@ public class Jugador extends Actor {
@Override @Override
public void actua() { public void actua() {
if (movIzq && this.x > 0) this.x -= velocidadX; if (movIzq && this.x > 0) this.x -= velocidadX;
if (movDer && this.x + this.ancho < Arkanoid.getAnchoVentana()) this.x += velocidadX; if (movDer && this.x + this.ancho < Arkanoid.getInstance().getCanvas().getWidth()) this.x += velocidadX;
} }
public void movimientoRaton(int x, int y) { public void movimientoRaton(int x, int y) {
x = (x - ancho / 2); x = (x - ancho / 2);
if (x > 0 && x < Arkanoid.getAnchoVentana() - this.ancho) this.x = x; if (x > 0 && x < Arkanoid.getInstance().getCanvas().getWidth() - this.ancho) this.x = x;
} }
public void movimientoTecladoDerecha(boolean derecha) { public void movimientoTecladoDerecha(boolean derecha) {

View File

@@ -10,13 +10,13 @@ public class Ladrillo extends Actor {
int fila; int fila;
public Ladrillo(int ancho, int alto, int fila, int columna, int separacion) { public Ladrillo(int ancho, int alto, int fila, int columna, int separacion, int separacionSuperior) {
this.setAncho(ancho); this.setAncho(ancho);
this.setAlto(alto); this.setAlto(alto);
this.fila = fila; this.fila = fila;
this.x = separacion + (columna * ancho) + (separacion * columna); this.x = separacion + (columna * ancho) + (separacion * columna);
this.y = separacion + (fila * alto) + (separacion * fila) + (Arkanoid.getAltoVentana()/12); this.y = separacion + (fila * alto) + (separacion * fila) + separacionSuperior;
} }
@Override @Override