Skip to content

Commit

Permalink
menu niveles
Browse files Browse the repository at this point in the history
  • Loading branch information
brisabrussa28 committed Oct 13, 2024
1 parent ffafbb7 commit 9b67566
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 40 deletions.
Binary file added assets/bloqueado.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/nivel_s.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/niveles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 88 additions & 38 deletions mainExample.wpgm
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,91 @@ object siSeleccionado{
method image() = "si.png"
}

object menuNiveles{
var property position = game.origin()
method image() = "niveles.png"
}

object seleccion{
var property position = game.at(1, 11)
method image() = "nivel_s.png"
}

program BadIceCreamGame {
game.cellSize(40) //ancho del helado
game.title("Bad Ice Cream")
game.height(18)
game.width(18)
//dibujar menu de personajes
var inicio = false
game.addVisual(menuPersonajes)
game.addVisual(noSeleccionado)
game.addVisual(siSeleccionado)
//Personalización
//Mundo
juego.menuPersonajes()
//inicio
game.start()
//menu selección de personajes
var comenzar = 1
if(!inicio){

//Juego puntos
keyboard.r().onPressDo({
const nuevaFruta = interactuador.obtenerPrimerElemento("r"," sobre una fruta para recolectarla")
if(nuevaFruta.esFruta()){
jugador.recolectar(nuevaFruta)
points.sumarFrutas()
}
if(points.frutasObtenidas() == 10 || points.frutasObtenidas() == 20){
spawn.dibujarFrutas()
}
if(points.frutasObtenidas() == 30){
game.removeVisual(jugador)
game.addVisual(fondo_de_pausa)
game.addVisual(ganaste)
game.stop()
}
})
}

object juego{
method menuNiveles(){
var x = seleccion.position().x()
var y = seleccion.position().y()
keyboard.a().onPressDo({
if(seleccion.position().x() >= 1){
seleccion.position(game.at(x-2,y))
}
})
keyboard.d().onPressDo({
if(seleccion.position().x() < 14){
seleccion.position(game.at(x+2,y))
}
})
keyboard.w().onPressDo({
if(seleccion.position().y() < 11){
seleccion.position(game.at(x,y+2))
}
})
keyboard.s().onPressDo({
if(seleccion.position().y() > 3){
seleccion.position(game.at(x,y-2))
}
})
keyboard.enter().onPressDo({
if(seleccion.position() == game.at(1,11)){ //Seleccionado nivel 1
escenario.generarLista(0)
} else if(seleccion.position() == game.at(3,11)){ //Seleccionado nivel 2
escenario.generarLista(1)
}
game.removeVisual(menuNiveles)
game.removeVisual(seleccion)
self.jugar()
})
}

method menuPersonajes(){
keyboard.a().onPressDo({
noSeleccionado.direccion(0)
siSeleccionado.direccion(1)
})
})
keyboard.d().onPressDo({
noSeleccionado.direccion(1)
siSeleccionado.direccion(0)
Expand All @@ -71,41 +137,25 @@ program BadIceCreamGame {
game.removeVisual(menuPersonajes)
game.removeVisual(noSeleccionado)
game.removeVisual(siSeleccionado)
if(comenzar == 1){
//dibujar muros
muros.crearLaterales()
//dibujar escenario
escenario.generarEscenario()
//dibujar frutas
spawn.dibujarFrutas()
//dibujar puntos
game.addVisual(points)
//dibujar jugador
game.addVisualCharacter(jugador)
game.showAttributes(jugador)
comenzar = 0
inicio = true
}
game.addVisual(menuNiveles)
game.addVisual(seleccion)
self.menuNiveles()
})
}

//Juego
keyboard.r().onPressDo({
const nuevaFruta = interactuador.obtenerPrimerElemento("r"," sobre una fruta para recolectarla")
if(nuevaFruta.esFruta()){
jugador.recolectar(nuevaFruta)
points.sumarFrutas()
}
if(points.frutasObtenidas() == 10 || points.frutasObtenidas() == 20){
spawn.dibujarFrutas()
}
if(points.frutasObtenidas() == 30){
game.removeVisual(jugador)
game.addVisual(fondo_de_pausa)
game.addVisual(ganaste)
game.stop()
}
})

method jugar(){
//dibujar muros
muros.crearLaterales()
//dibujar escenario
escenario.generarEscenario()
//dibujar frutas
spawn.dibujarFrutas()
//dibujar puntos
game.addVisual(points)
//dibujar jugador
game.addVisualCharacter(jugador)
game.showAttributes(jugador)
}
}

object interactuador{
Expand Down
26 changes: 24 additions & 2 deletions muros.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ object muros{
}

object escenario{
const listan = [game.at(2,6), game.at(2,7), game.at(7,7), game.at(7,6), game.at(7,4), game.at(2,4), game.at(4,2), game.at(5,2), game.at(3,3), game.at(6,3)]

var listan = []

method generarLista(indice){
listan = niveles.get(indice)
}

method generarEscenario(){
listan.forEach({cosa => new Bloque().ubicarYDibujar(cosa)})
}
Expand All @@ -37,4 +41,22 @@ object escenario{
method quitarObjeto(cosa){
listan.remove(cosa)
}

const niveles = [
//Nivel 1
[game.at(2,12), game.at(2,13), game.at(2,14), game.at(2,15), game.at(3,15), game.at(4,12), game.at(4,13), game.at(4,14), game.at(4,15), //ojo I
game.at(13,12), game.at(13,13), game.at(13,14), game.at(13,15), game.at(14,15), game.at(15,12), game.at(15,13), game.at(15,14), game.at(15,15), //ojo D
game.at(7,10), game.at(8,10), game.at(9,10), game.at(10,10), game.at(8,9), game.at(9,9), //nariz
game.at(3,5), game.at(4,4), game.at(5,4), game.at(6,3), game.at(7,3), game.at(8,4), game.at(9,4), game.at(10,3), game.at(11,3), game.at(12,4), game.at(13,4), game.at(14,5), game.at(8,5), game.at(8,6), game.at(8,7), game.at(9,5), game.at(9,6), game.at(9,7)], //boca]
//Nivel 2
[game.at(2,13), game.at(3,13), game.at(4,14), game.at(5,14), game.at(6,15), game.at(7,15), game.at(8,15), game.at(9,15), game.at(10,15), game.at(11,15), game.at(12,15), game.at(13,15), game.at(14,14), game.at(15,12),
game.at(2,12), game.at(3,4), game.at(4,11), game.at(5,11), game.at(6,12), game.at(7,13), game.at(8,13), game.at(9,13), game.at(10,13), game.at(11,13), game.at(12,13), game.at(13,11), game.at(14,13), game.at(15,11),
game.at(2,11), game.at(3,2), game.at(4,10), game.at(5,6), game.at(6,9), game.at(7,10), game.at(8,11), game.at(9,11), game.at(10,11), game.at(11,10), game.at(12,12), game.at(13,10), game.at(14,4), game.at(15,10),
game.at(2,10), game.at(4,9), game.at(5,4), game.at(6,8), game.at(7,8), game.at(8,8), game.at(9,9), game.at(10,7), game.at(11,9), game.at(12,6), game.at(13,9), game.at(15,9),
game.at(2,9), game.at(4,8), game.at(5,2), game.at(6,6), game.at(7,6), game.at(8,6), game.at(9,6), game.at(10,4), game.at(11,8), game.at(12,3), game.at(13,8), game.at(15,8),
game.at(2,8), game.at(4,7), game.at(6,4), game.at(7,4), game.at(8,4), game.at(9,4), game.at(10,2), game.at(11,5), game.at(13,7), game.at(15,7),
game.at(2,7), game.at(4,6), game.at(6,2), game.at(7,2), game.at(8,2), game.at(9,2), game.at(11,3), game.at(13,6), game.at(15,6),
game.at(2,6), game.at(4,4), game.at(13,4), game.at(15,5),
game.at(2,5), game.at(4,2)]
]
}

0 comments on commit 9b67566

Please sign in to comment.