Skip to content

Commit

Permalink
cree menu de inicio
Browse files Browse the repository at this point in the history
  • Loading branch information
NahuelMarek committed Nov 19, 2024
1 parent dc5d21d commit 30a9c96
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 9 deletions.
111 changes: 108 additions & 3 deletions administradorDeJuego.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import proyectil.*
class MyException inherits wollok.lang.Exception {}
object administradorDeJuego {
var property pausado = false
var property usuarioEnMenu = false
var property usuarioEnMenu = true



Expand Down Expand Up @@ -127,7 +127,7 @@ object sonidoPartida{
method iniciarMusica() {
musica.shouldLoop(true)
game.schedule(1500, { musica.play() })
musica.volume(0.5)
musica.volume(1)
}
method detenerMusica(){
musica.stop()
Expand Down Expand Up @@ -161,7 +161,7 @@ object configuracion {
method iniciarMusica() {sonidoPartida.iniciarMusica()}
// Método para detener la música de fondo
method detenerMusica() {
musica.stop()
sonidoPartida.detenerMusica()
}
// Método para agregar elementos visuales y configurar teclas de control
method agregarVisuals() {
Expand Down Expand Up @@ -239,3 +239,108 @@ object configuracion {
// Método para eliminar todos los eventos programados de actualización (ticks)

}


object menuInicial{
var imagen="MenuInicial.png"
method position()=new MutablePosition(x=0,y=0)
method image() = imagen
var botonSeleccionado = 0
var property botones=[botonDeInicio,botonMutearMusica]
method iniciarMenu(){
botones.forEach({boton=>game.addVisual(boton)})

}
method finalizarMenu(){
botones.forEach({boton=>game.removeVisual(boton)})
administradorDeJuego.usuarioEnMenu(false)
game.removeVisual(self)
}
method moverseEntreBotones(){
keyboard.right().onPressDo({ if(administradorDeJuego.usuarioEnMenu() && botonSeleccionado<botones.size()-1)
{ self.deseleccionarBoton()
botonSeleccionado+=1
self.seleccionarBoton() }})
keyboard.left().onPressDo({ if(administradorDeJuego.usuarioEnMenu() && botonSeleccionado>0 )
{ self.deseleccionarBoton()
botonSeleccionado-=1
self.seleccionarBoton()}})

}

method seleccionarBoton(){
botones.get(botonSeleccionado).cambiarEstadoDeSeleccion(true)
}

method deseleccionarBoton(){
botones.get(botonSeleccionado).cambiarEstadoDeSeleccion(false)
}
method activarBoton(){
keyboard.enter().onPressDo({ if(administradorDeJuego.usuarioEnMenu()){
botones.get(botonSeleccionado).accion()}})
}
}
object botonDeInicio{
var imagen="botonInicioSeleccionado.png"
method image()=imagen
method position()= new MutablePosition(x=4,y=1)
method accion(){
configuracion.agregarVisuals()
configuracion.crearTicks()
menuInicial.finalizarMenu()
}

method cambiarEstadoDeSeleccion(estado){
if(estado){
self.ponerMarcoDeSeleccion()
}
else{self.quitarMarcoDeSeleccion()}
}
method ponerMarcoDeSeleccion(){
imagen="botonInicioSeleccionado.png"
}
method quitarMarcoDeSeleccion(){
imagen="botonInicio.png"
}

}

object botonMutearMusica{
var imagen="botonMuteo.png"
method image()=imagen
method position()= new MutablePosition(x=13,y=1)
var muteada=true
method accion(){
if (muteada){
configuracion.iniciarMusica()
imagen="botonDesmuteoSeleccionado.png"
muteada=false
}
else {
configuracion.detenerMusica()
imagen="botonMuteoSeleccionado.png"
muteada=true
}
}

method cambiarEstadoDeSeleccion(estado){
if(estado){
self.ponerMarcoDeSeleccion()
}
else{self.quitarMarcoDeSeleccion()}
}
method ponerMarcoDeSeleccion(){
if(muteada){
imagen="botonMuteoSeleccionado.png"
}
else imagen="botonDesmuteoSeleccionado.png"
}
method quitarMarcoDeSeleccion(){
if(muteada){
imagen="botonMuteo.png"
}
else imagen="botonDesmuteo.png"

}

}
Binary file added assets/MenuInicial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/botonDesmuteo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/botonDesmuteoSeleccionado.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/botonInicio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/botonInicioSeleccionado.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/botonMuteo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/botonMuteoSeleccionado.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/pantallaPausa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 7 additions & 4 deletions main.wpgm
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ program juego {
/* game.addVisual(pantalla)
game.schedule(100, {pantalla.reproducirSonido()}) */
//

game.removeVisual(pantalla)
game.addVisual(menuInicial)
menuInicial.iniciarMenu()
menuInicial.moverseEntreBotones()
menuInicial.activarBoton()
//game.removeVisual(pantalla)

configuracion.agregarVisuals()
/* configuracion.agregarVisuals()
configuracion.crearTicks()
configuracion.iniciarMusica()
configuracion.iniciarMusica() */
//administradorDeJuego.pausado()
//})
/*
Expand Down
2 changes: 0 additions & 2 deletions slime.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@ class Slime {
}
method estaMuerto()= {slime=>
if (slime.llegoACasa()||slime.position().y()>4||slime.position().y()<0) {
game.sound("m.deathScreen.mp3").play()
casa.recibirDanio(slime.position().y())
slime.eliminar()
} else if (slime.sinVida()) {
game.sound("m.explosion.mp3").play()
slime.eliminar()
}
return slime.sinVida() || slime.llegoACasa()
Expand Down

0 comments on commit 30a9c96

Please sign in to comment.