Skip to content

Commit

Permalink
Agrego pausar con "P"
Browse files Browse the repository at this point in the history
  • Loading branch information
FeliPampin committed Oct 17, 2024
1 parent 80f2e8f commit 6720571
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions juegoAjedrez2.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ object juegoAjedrez2{

var juegoPausado = false
method estaPausado() = juegoPausado
const verdadero = true
const falso = false

method iniciar(){
game.height(5)
Expand All @@ -17,19 +19,20 @@ object juegoAjedrez2{
keyboard.w().onPressDo({reyNegro.moverArriba()})
keyboard.s().onPressDo({reyNegro.moverAbajo()})
keyboard.space().onPressDo({reyNegro.disparar()})
keyboard.p().onPressDo({ self.pausarJuego() })
keyboard.r().onPressDo({ self.reiniciarJuego() })

// keyboard.r().onPressDo({ if(juegoPausado) self.reiniciarJuego() }) No funca esto
}


method pausarJuego() {
juegoPausado = true
game.say(self, "Presione R para reiniciar el juego")
reyNegro.elJugadorPauso(verdadero)
}
method reiniciarJuego() {
juegoPausado = false
reyNegro.reiniciarPersonaje()
game.clear()
self.iniciar()
reyNegro.elJugadorPauso(falso)
}

}
Expand All @@ -40,25 +43,26 @@ object reyNegro {
var position = game.at(0,2)

var cooldown = 1
var elJugadorPauso = false

method vida() = vida
method image() = "reyNegro.png"
method puntaje() = puntaje

method moverArriba() {
if(position != game.at(0,4)) {
if(position != game.at(0,4) && !elJugadorPauso ) {
position = position.up(1)
}
}
method moverAbajo() {
if(position != game.at(0,0)) {
if(position != game.at(0,0) && !elJugadorPauso) {
position = position.down(1)
}
}
method position() = position

method disparar() {
if(cooldown == 1){
if(cooldown == 1 && !elJugadorPauso){
const balaNueva = new Bala()
cooldown = 0
game.addVisual(balaNueva)
Expand Down Expand Up @@ -95,6 +99,10 @@ object reyNegro {
puntaje = 0
position = game.at(0,2)
}

method elJugadorPauso(booleano){
elJugadorPauso = booleano
}
}

object puntajeFinal {
Expand Down

0 comments on commit 6720571

Please sign in to comment.