Skip to content

Commit

Permalink
Refactor personajes y colisiones de tierra,fuego,agua
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin-Sosa committed Oct 17, 2024
1 parent ed892e3 commit e9f68ae
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 184 deletions.
39 changes: 14 additions & 25 deletions elementos.wlk
Original file line number Diff line number Diff line change
@@ -1,60 +1,49 @@
import personajes.*

object ayudaTexto{

method position() = game.at(0,14)
method text()="Salta en tu lugar antes de cualquier salto para sacar el timing"
method textcolor() = "00FF00FF"
method tratarColision() {}
class Elemento
{
var property position
method tipo() = "Elemento"
}
object boton

object boton inherits Elemento (position = game.at(5, 7))
{
var property position = game.at(5,7)
method image() = "boton.png"
method tratarColision() {}
}

object elevadorPorPalanca
object elevadorPorPalanca inherits Elemento (position = game.at(0, 6))
{
var property position = game.at(0,6)
method image() = "elevador2.png"
method tratarColision() {}
}

object elevadorPorBoton
object elevadorPorBoton inherits Elemento (position = game.at(14, 9))
{
var property position = game.at(14,9)
method image() = "elevador2.png"
method tratarColision() {}
}

object palanca
object palanca inherits Elemento (position = game.at(3, 4))
{
var property position = game.at(3,4)
method image() = "palanca.png"
method tratarColision() {}
}

object puertaFuego
{ var property puertaFuegoAbierta = false
var property position = game.at(12,14)
object puertaFuego inherits Elemento (position = game.at(12, 14))
{
method image() = "puertaFuego.png"
method tratarColision(fireboy) {self.puertaFuegoAbierta(true);if(puertaAgua.puertaAguaAbierta()){game.say(fireboy,"Ganaste!")} }
method tratarColision() {}
}

object puertaAgua
{ var property puertaAguaAbierta=false
var property position = game.at(8,14)
object puertaAgua inherits Elemento (position = game.at(8, 14))
{
method image() = "puertaAgua.png"
method tratarColision(watergirl) {self.puertaAguaAbierta(true); if(self.puertaAguaAbierta()){game.say(watergirl,"Ganaste!")}}
method tratarColision() {}
}

object cubo
object cubo inherits Elemento (position = game.at(6, 10))
{
var property position = game.at(6,10)
method image() = "cubo.png"
method tratarColision() {}

}
16 changes: 2 additions & 14 deletions main.wpgm
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ import personajes.*


program FireboyAndWatergirl {
game.title("Fireboy and Watergirl")
game.height(16)
game.width(15)
game.cellSize(50)
game.boardGround("bg.png")

mapa.inciar()
game.addVisual(fireboy)
game.addVisual(watergirl)
mapa.inciar()

keyboard.left().onPressDo({fireboy.movIzquierda()})
keyboard.right().onPressDo({fireboy.movDerecha()})
Expand All @@ -30,13 +26,5 @@ program FireboyAndWatergirl {
elemento.tratarColision(watergirl)
})



game.onTick(500, "caeWaterGirl", {watergirl.caer()})

game.onTick(500, "caeFireBoy", {fireboy.caer()})

game.start()


}
68 changes: 17 additions & 51 deletions mapa.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ object mapa
nuevoBloque.position(game.at(x, y))
game.addVisual(nuevoBloque)
})
}


}

method agregarElementos()
{
Expand All @@ -35,41 +33,6 @@ object mapa
self.crearBloques(9, 0, 12, fabricaBloqueTierra)
self.crearBloques(12, 0, 1, fabricaBloqueTierra)
self.crearBloques(13, 3, 14, fabricaBloqueTierra)

//de aca pa abajo son los limites despues lo vamos a hacer mas lindo pero por ahora funciona
self.crearBloques(-1, 0, 14, fabricaBloqueTierra)
self.crearBloques(0, -1, -1, fabricaBloqueTierra)
self.crearBloques(1, -1, -1, fabricaBloqueTierra)
self.crearBloques(2, -1, -1, fabricaBloqueTierra)
self.crearBloques(3, -1, -1, fabricaBloqueTierra)
self.crearBloques(4, -1, -1, fabricaBloqueTierra)
self.crearBloques(5, -1, -1, fabricaBloqueTierra)
self.crearBloques(6, -1, -1, fabricaBloqueTierra)
self.crearBloques(7, -1, -1, fabricaBloqueTierra)
self.crearBloques(8, -1, -1, fabricaBloqueTierra)
self.crearBloques(9, -1, -1, fabricaBloqueTierra)
self.crearBloques(10, -1, -1, fabricaBloqueTierra)
self.crearBloques(11, -1, -1, fabricaBloqueTierra)
self.crearBloques(12, -1, -1, fabricaBloqueTierra)
self.crearBloques(13, -1, -1, fabricaBloqueTierra)
self.crearBloques(14, -1,-1, fabricaBloqueTierra)
self.crearBloques(0,15,15,fabricaBloqueTierra)
self.crearBloques(1,15,15,fabricaBloqueTierra)
self.crearBloques(2,15,15,fabricaBloqueTierra)
self.crearBloques(3,15,15,fabricaBloqueTierra)
self.crearBloques(4,15,15,fabricaBloqueTierra)
self.crearBloques(5,15,15,fabricaBloqueTierra)
self.crearBloques(6,15,15,fabricaBloqueTierra)
self.crearBloques(7,15,15,fabricaBloqueTierra)
self.crearBloques(8,15,15,fabricaBloqueTierra)
self.crearBloques(9,15,15,fabricaBloqueTierra)
self.crearBloques(10,15,15,fabricaBloqueTierra)
self.crearBloques(11,15,15,fabricaBloqueTierra)
self.crearBloques(12,15,15,fabricaBloqueTierra)
self.crearBloques(13,15,15,fabricaBloqueTierra)
self.crearBloques(14,15,15,fabricaBloqueTierra)


}

method crearBloquesEspeciales()
Expand All @@ -81,10 +44,16 @@ object mapa

method inciar()
{
game.title("Fireboy and Watergirl")
game.height(16)
game.width(15)
game.cellSize(50)
game.boardGround("bg.png")
self.crearBloquesDeTierra()
self.crearBloquesEspeciales()
self.agregarElementos()
}

}
object fabricaBloqueTierra {
method crearBloque() = new BloqueTierra()
Expand All @@ -100,45 +69,40 @@ object fabricaBloqueFuego {

object fabricaBloqueAcido {
method crearBloque() = new BloqueAcido()
method tratarColision(personaje)
{
personaje.kill()
}
}

class Bloque
{
var property position = game.at(0,0)
}

class BloqueTierra
{
var property position = game.at(0,0)
method image() = "bloqueTierra2.png"

method tipo() = "BloqueTierra"
method tratarColision(personaje)
{
personaje.retroceder()
}
}

class BloqueFuego
{
var property position = game.at(0,0)
method image() = "bloqueDeFuego.png"
method tipo() = "BloqueFuego"

method tratarColision(personaje)
{
personaje.tratarColisionBloqueFuego()
personaje.tocarFuego()
}
}

class BloqueAgua
{
var property position = game.at(0,0)
method image() = "bloqueDeAgua.png"
method tipo() = "BloqueAgua"

method tratarColision(personaje)
{
personaje.tratarColisionBloqueAgua()
personaje.tocarAgua()
}

}
Expand All @@ -147,9 +111,11 @@ class BloqueAcido
{
var property position = game.at(0,0)
method image() = "acido46.png"
method tipo() = "BloqueAcido"

method tratarColision(personaje)
{
personaje.kill()
personaje.morir()
}
}

Loading

0 comments on commit e9f68ae

Please sign in to comment.