Skip to content

Commit

Permalink
cambios en tests y juego en gnrl
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroGianola committed Oct 17, 2024
1 parent e3f45e5 commit ed892e3
Show file tree
Hide file tree
Showing 5 changed files with 299 additions and 25 deletions.
23 changes: 21 additions & 2 deletions elementos.wlk
Original file line number Diff line number Diff line change
@@ -1,41 +1,60 @@
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() {}
}
object boton
{
var property position = game.at(5,7)
method image() = "boton.png"
method tratarColision() {}
}

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

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

object palanca
{
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)
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)
method image() = "puertaAgua.png"
method tratarColision(watergirl) {self.puertaAguaAbierta(true); if(self.puertaAguaAbierta()){game.say(watergirl,"Ganaste!")}}
method tratarColision() {}
}

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

}
13 changes: 12 additions & 1 deletion main.wpgm
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,20 @@ program FireboyAndWatergirl {
keyboard.d().onPressDo({watergirl.movDerecha()})

game.whenCollideDo(fireboy, {elemento =>

elemento.tratarColision(fireboy)
})

game.whenCollideDo(watergirl, {elemento =>
elemento.tratarColision(watergirl)
})



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

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

game.start()


}
61 changes: 52 additions & 9 deletions mapa.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import elementos.*
object mapa
{
method crearBloques(y, xi, xf, fabrica)
//method que crea bloques de un tipo en una misma fila o valor de y de un punto x inicial a uno x final
{
(xi..xf).forEach({ x =>
const nuevoBloque = fabrica.crearBloque()
Expand All @@ -11,6 +12,8 @@ object mapa
})
}



method agregarElementos()
{
game.addVisual(boton)
Expand All @@ -25,13 +28,48 @@ object mapa
method crearBloquesDeTierra()
{
self.crearBloques(1, 0, 2, fabricaBloqueTierra)
self.crearBloques(1, 13, 15, fabricaBloqueTierra)
self.crearBloques(1, 13, 14, fabricaBloqueTierra)
self.crearBloques(2, 6, 11, fabricaBloqueTierra)
self.crearBloques(3, 0, 4, fabricaBloqueTierra)
self.crearBloques(6, 2, 15, fabricaBloqueTierra)
self.crearBloques(6, 2, 14, fabricaBloqueTierra)
self.crearBloques(9, 0, 12, fabricaBloqueTierra)
self.crearBloques(12, 0, 1, fabricaBloqueTierra)
self.crearBloques(13, 3, 15, 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 Down Expand Up @@ -62,6 +100,10 @@ object fabricaBloqueFuego {

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

class Bloque
Expand All @@ -76,37 +118,38 @@ class BloqueTierra

method tratarColision(personaje)
{
if(personaje.posicionAnt().y() < position.y()) personaje.retroceder()
else if(personaje.posicionAnt().y() > position.y()) personaje.quedarse(position.y())
personaje.retroceder()
}
}

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

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

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

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

}

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

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

85 changes: 72 additions & 13 deletions personajes.wlk
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
object fireboy
{
var property position = game.at(0,0)
var property posicionAnt = null
var property position = game.at(1,0)
var property posicionAnt = game.at(1,0)
var cantSaltos = 0

method image() = "fireboy6.png"

method movIzquierda()
{
posicionAnt = position
self.actualizarPosicionAnt()
position = position.left(1)
}

method movDerecha()
{
posicionAnt = position
self.actualizarPosicionAnt()
position = position.right(1)
}

method movSaltar()
{
if(cantSaltos < 2)
{
posicionAnt = position
self.actualizarPosicionAnt()
position = position.up(1)
cantSaltos += 1
game.schedule(800, {
Expand All @@ -27,38 +31,93 @@ object fireboy
})
}
}
method retroceder() {
position = game.at(position.x(), 0.max(position.y()-1))
}
method quedarse(nuevaY)
{
position = game.at(position.x(), nuevaY+1)

method retroceder() {
position = self.posicionAnt()
}

method actualizarPosicionAnt(){
posicionAnt = position
}

method caer() {
self.actualizarPosicionAnt()
position = position.down(1)
}

method tratarColision(watergirl) {
self.kill()
watergirl.kill()
}

method kill(){
position = game.at(1,0)
posicionAnt = game.at(1,0)
game.say(watergirl,"Jaja ripeo el otro")
game.say(self,"wahhhah me MORI")

}

method tratarColisionBloqueFuego() {}
method tratarColisionBloqueAgua() {self.kill()}
}

object watergirl
{
var property position = game.at(0,2)
var property position = game.at(1,2)
var property posicionAnt = game.at(1,2)
var cantSaltos = 0
method image() = "watergirl3.png"
method movIzquierda()
{
self.actualizarPosicionAnt()
position = position.left(1)
}
method movDerecha()
{
self.actualizarPosicionAnt()
position = position.right(1)
}
method movSaltar()
{
if(cantSaltos < 2)
{
self.actualizarPosicionAnt()
position = position.up(1)
cantSaltos += 1
game.schedule(800, {
position = position.down(1)
if(cantSaltos==2) cantSaltos = 0
})
}
}
method actualizarPosicionAnt(){
posicionAnt = position
}
method retroceder() {
position = self.posicionAnt()
}

method caer() {
self.actualizarPosicionAnt()
position = position.down(1)
}

method tratarColision(fireboy) {
self.kill()
fireboy.kill()
}



method kill(){
position = game.at(1,2)
posicionAnt = game.at(1,2)
game.say(fireboy,"Jaja ripeo la otra")
game.say(self,"wahhhah me MORI")

}

method tratarColisionBloqueFuego() {self.kill()}
method tratarColisionBloqueAgua() {}

}
Loading

0 comments on commit ed892e3

Please sign in to comment.