Skip to content

Commit

Permalink
Funcionamiento del cubo
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin-Sosa committed Nov 6, 2024
1 parent 327b675 commit e65cf01
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
15 changes: 11 additions & 4 deletions elementos.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class Elemento
method puedeSerAtravesado() = true
method puedeSerPresionado() = false
method puedePresionarBoton() = false
method puedeSerMovido() = false
method tratarColision(personaje) {}
}
class Elevador
{
Expand Down Expand Up @@ -40,7 +42,6 @@ const elevadorPorPalanca = new Elevador (posicionInicial = game.at(0, 6))
class Boton inherits Elemento
{
method image() = "boton2.png"
method tratarColision(personaje) {}

method estaPresionado()
{
Expand All @@ -65,7 +66,6 @@ object palanca inherits Elemento (position = game.at(3, 4))
{
method image() = "palanca.png"
override method puedeSerPresionado() = true
method tratarColision(personaje){}

method activar() {
if(elevadorPorPalanca.activado()) elevadorPorPalanca.cambiarEstado(false)
Expand All @@ -79,16 +79,23 @@ object cubo inherits Elemento (position = game.at(6, 10))
method image() = "cubo.png"
override method puedeSerAtravesado() = false
override method puedePresionarBoton() = true
override method puedeSerMovido() = true

method moverse(desplazamiento)
{
position = game.at(position.x() + desplazamiento, position.y())
game.sound("bloque.ogg").play()
}
}

object puertaFuego inherits Elemento (position = game.at(12, 14))
{
method image() = "puertaFuego.png"
method tratarColision(personaje) {}
override method tratarColision(personaje) {}
}

object puertaAgua inherits Elemento (position = game.at(8, 14))
{
method image() = "puertaAgua.png"
method tratarColision(personaje) {}
override method tratarColision(personaje) {}
}
1 change: 1 addition & 0 deletions mapa.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class Bloque
const property position
method puedeSerPresionado() = false
method puedeSerAtravesado() = true
method puedeSerMovido() = false

}

Expand Down
16 changes: 14 additions & 2 deletions personajes.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class Personaje {
method tratarColision(personaje) {}
method puedeSerAtravesado() = true
method puedePresionarBoton() = true
method puedeSerMovido() = false
method puedeSerPresionado() = false

method moverse(nuevaPosicion)
{
Expand Down Expand Up @@ -78,8 +80,8 @@ object fireboy inherits Personaje (position = game.at(0, 0)) {

method presionar()
{
const presionable = game.getObjectsIn(self.position()).head()
if(presionable.puedeSerPresionado()) presionable.activar()
const elemento = game.getObjectsIn(self.position()).head()
if(elemento.puedeSerPresionado()) elemento.activar()
}
}

Expand All @@ -90,5 +92,15 @@ object watergirl inherits Personaje (position = game.at(0, 2)) {

method moverElemento()
{
const elementosIzquierda = game.getObjectsIn(self.position().left(1))
const elementosDerecha = game.getObjectsIn(self.position().right(1))
if(elementosIzquierda.size() > 0)
{
elementosIzquierda.forEach({elemento => if(elemento.puedeSerMovido()) elemento.moverse(-1)})
}
else if(elementosDerecha.size() > 0)
{
elementosDerecha.forEach({elemento => if(elemento.puedeSerMovido()) elemento.moverse(1)})
}
}
}

0 comments on commit e65cf01

Please sign in to comment.