Skip to content

Commit

Permalink
0.7.16: ahora se puede reiniciar el nivel con la R, el circulo o dand…
Browse files Browse the repository at this point in the history
…o clic al boton de reiniciar
  • Loading branch information
martinlacorrona committed Nov 26, 2019
1 parent d7ced39 commit 1a0b73b
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 15 deletions.
Binary file added res/boton_reiniciar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/Globales.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var version ="v0.7.14";
var version ="v0.7.16";

var pulsaciones = []; // actuales registradas

Expand Down
1 change: 1 addition & 0 deletions src/Res.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ var imagenes = {
mensaje_perderVida : "res/mensaje_perderVida.png",
boton_jugar : "res/boton_jugar.png",
boton_pausa : "res/boton_pausa.png",
boton_reiniciar : "res/boton_reiniciar.png",
boton_disparo : "res/boton_disparo.png",
boton_salto : "res/boton_salto.png",
boton_jugar : "res/boton_jugar.png",
Expand Down
7 changes: 6 additions & 1 deletion src/controles/EventosGamePad.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function actualizarOrdenes(){
valorYJoystickIzquierdo = 0;
controles.moverY = parseFloat(valorYJoystickIzquierdo).toFixed( 2 );

if(gP1.buttons[0].pressed) { // 1 es el botón A
if(gP1.buttons[0].pressed) { // 0 es el botón A
if ( botonesPulsados[0] == false ) {
botonesPulsados[0] = true;
controles.disparo = true;
Expand All @@ -58,6 +58,11 @@ function actualizarOrdenes(){
botonesPulsados[9] = true;
controles.continuar = false;
controles.pausa = true;
} else if(gP1.buttons[1].pressed) { //boton B
botonesPulsados[1] = true;
controles.continuar = false;
controles.pausa = false;
controles.reiniciar = true;
} else {
botonesPulsados[0] = false;
botonesPulsados[9] = false;
Expand Down
5 changes: 4 additions & 1 deletion src/controles/EventosTeclado.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ function onKeyDown( event) {
case 27:
controles.pausa = true;
break;
case 82:
controles.reiniciar = true;
break;
}

}
Expand All @@ -45,8 +48,8 @@ function onKeyUp( event) {
teclas.splice( posicion, 1);
switch ( event.keyCode ){
case 32:
controles.disparo = false;
controles.continuar = false;
controles.disparo = false;
break;
}

Expand Down
41 changes: 29 additions & 12 deletions src/layers/GameLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ class GameLayer extends Layer {

this.puntuacionFinal = undefined;

this.disparado = false;

this.iniciar();
}

iniciar() {
this.version = new Texto(version,480*0.90,320*0.99, undefined, "8px Arial");
this.botonDisparo = new Boton(imagenes.boton_disparo,480*0.87,320*0.55, 0.5, 0.5);
this.botonPausa = new Boton(imagenes.boton_pausa,480*0.97,320*0.065, 0.5, 0.5);
this.botonReiniciar = new Boton(imagenes.boton_reiniciar,480*0.97,320*0.14, 0.5, 0.5);
this.pad = new Pad(480*0.75,320*0.8);
this.fondo = new Fondo(imagenes.fondo, 480*0.5,320*0.5);
this.gui = new Fondo(imagenes.gui, 480*0.5,320*0.5);
Expand Down Expand Up @@ -291,6 +290,7 @@ class GameLayer extends Layer {
this.balas.dibujar();
this.nivel.dibujar();
this.botonPausa.dibujar();
this.botonReiniciar.dibujar();
this.version.dibujar();
if(this.controladorJuego.fueGeneradoBoss)
this.jefeFinalGenerado.dibujar();
Expand Down Expand Up @@ -319,19 +319,20 @@ class GameLayer extends Layer {
this.pausa = false;
}

if (controles.reiniciar){
controles.reiniciar = false;
this.reinciarTodo();
}

// disparar
if ( controles.disparo ){
if(!this.disparado) {
let nuevoDisparo = this.jugador.disparar();
if (nuevoDisparo != null) {
this.espacio.agregarCuerpoDinamico(nuevoDisparo);
this.disparosJugador.push(nuevoDisparo);
this.controladorAudio.playDisparar();
}
this.disparado = true;
let nuevoDisparo = this.jugador.disparar();
if (nuevoDisparo != null) {
this.espacio.agregarCuerpoDinamico(nuevoDisparo);
this.disparosJugador.push(nuevoDisparo);
this.controladorAudio.playDisparar();
controles.disparo = false;
}
} else {
this.disparado = false;
}

// Eje X
Expand Down Expand Up @@ -509,6 +510,7 @@ class GameLayer extends Layer {
// Suponemos botones no estan pulsados
this.botonDisparo.pulsado = false;
this.botonPausa.pulsado = false;
this.botonReiniciar.pulsado = false;
// suponemos que el pad está sin tocar
controles.moverX = 0;
controles.moverY = 0;
Expand Down Expand Up @@ -552,6 +554,12 @@ class GameLayer extends Layer {
controles.pausa = true;
}
}
if (this.botonReiniciar.contienePunto(pulsaciones[i].x , pulsaciones[i].y) ){
this.botonReiniciar.pulsado = true;
if ( pulsaciones[i].tipo == tipoPulsacion.inicio) {
controles.reiniciar = true;
}
}

}
if(controles.pausa)
Expand Down Expand Up @@ -604,6 +612,14 @@ class GameLayer extends Layer {
this.pausa = true;
}

reinciarTodo() {
this.controladorJuego.reiniciarControlador();
this.iniciar();
this.mensaje = new Boton(imagenes.mensaje_como_jugar, 480/2, 320/2);
this.pausa = true;

}

reiniciarNivel() {
this.controladorJuego.reiniciarNivel();
this.iniciar();
Expand All @@ -613,6 +629,7 @@ class GameLayer extends Layer {

comerBala(x, y) {
this.jugador.balas++;
console.log("bala comida")
this.puntosImagenes.push(
new PuntosImagen(x, y, imagenes.puntos_1, 100));
this.controladorJuego.recolectablesRestantes--;
Expand Down

0 comments on commit 1a0b73b

Please sign in to comment.