diff --git a/.gitignore b/.github/.gitignore similarity index 100% rename from .gitignore rename to .github/.gitignore diff --git a/README.md b/README.md index 4a885a1..a8d5dcf 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,62 @@ -# (reemplazar nombre de juego acá) +# EL REINO DE LAS ARENAS UTN - Facultad Regional Buenos Aires - Materia Paradigmas de Programación ## Equipo de desarrollo: -- completar... -- completar... - - +- Juan Jose Nogueira +- Fabricio Lopez Garro + ## Capturas -![pepita](assets/golondrina.png) +![Pantalla de carga](assets/pantallaDeCarga.png) +![PersonajePrincipal] (assets/peque.png) +![Puerta] (assets/puerta1.png) +![Pinchos] (assets/pinchosDefinitivo.png) +![FondoDelJuego] (assets/nive.l.png) +![Bicho] (assets/enemigo.png) +![Reja] (asssets/reja2.png) ## Reglas de Juego / Instrucciones -(completar...) +Se necesitan llaves para pasar a las otras puertas +Las pociones suman vida +Cada enemigo y obstáculo resta vida + +Si el nivel de vida llega a 0, se termina el juego + +- Isaac es el personaje (OBJETO) principal de este juego, quien tiene que llegar hasta la salida del templo. Para ganar el juego hay que pasar por todas las habitaciones. +- Es necesario obtener las llaves para poder avanzar. +- Isaac no está solo, lo acompañan varias CLASES, que obstaculizaran el entorno de nuestro personaje. +- Por un lado los obstaculos fijos, que no tienen movimiento alguno. Los pinchos restan 5 puntos de vida al acercarse a ellos. Las rejas no hacen daño pero no se pueden atravesar. +- Por otro lado tambien hay enemigos que se mueven. Los bichos restan 10 de vida. Los magos atacan con un veneno que va restando vida en un tiempo determinado. Los fantasmas restan 15 de vida y aparte le sacan la armadura a Isaac +- Las pociones son importantes para no perder tanta vida. ## Controles: -- `W` para... +- `Up` `Down` `Left` `Right` para moverse en el juego +- `S` para iniciar + +## Teoria: + +![Escenario](assets/nivel.png) + +El juego inicia con una pantalla de carga que te muestra el título del juego. Lo primero que se inicia es el objeto nivel, que contiene las constantes del ancho y largo de la pantalla. También tiene una variable llamada escenarioActual, el cual indica el escenario en el que estamos. Al apretar el boton `S` se inicia el juego y se carga el primer nivel. + +![Peque](assets/peque.png) + +El personaje principal es isaac, es un objeto ya que no va a haber otro personaje como él. Las variables mas importantes son la de posicion, las de vida y la de tieneLlave. Isaac es el que entiende el método moverse(nuevaPosicion), esta nueva posición se envía desde el objeto nivel, y se activa cada vez que se presiona las letras `Up` `Down` `Left` `Right`. Asimismo Isaac, al ser el personaje que avanza en los escenarios, es el que entiende el mensaje avanzarNivel(). Cada vez que se colisiona con una puerta se envía desde el personaje el mensaje cambiarEscenario() a nivel, para que se cambie el escenario. Cada vez que él se acerca a un cofre, este le otorga a isaac una armadura y +20 de vida. También al acercarse a las pociones se le suma +20 de vida. Isaac tambien tiene otro método que es danio(cant), que reduce una cantidad de vida al personaje, si la vida llega a 0, entonces se envia a nivel el mensaje del game over. Este mensaje va a ser enviado desde los enemigos y obstaculos que dañen a isaac. Todos los elementos que interactuen con Isaac comparten el método interactuar(). + +![Bicho](assets/enemigo.png) + +Los enemigos están codificados como una clase, no solo porque va a haber varios de ellos sino que algunos van a heredar algunos métodos relacionados con el movimiento. Los enemigos pueden tener un movimiento vertical u horizontal en un espacio determinado. El enemigo mas común es el bicho, lo único que hace al chocarse con Isaac es restarle 10 puntos de daño. Otro enemigo es el mago, el cual le aplica un veneno al personaje y le va restando una unidad de vida en un tiempo de 600ms. Por último se encuentra el fantasma, el cual le infringe 15 de daño y despoja al héroe de sus armaduras. Si Isaac pierde sus armaduras puede aumentar su nivel de daño. El bicho le hace 15 de daño y el mago alarga su tiempo de efecto a 900ms. + +![Pincho](assets/cofre.png) + +Otros elementos importantes del juego son los obstáculos, objetos (clases) inmóviles que se encuentran en el escenario. Estos carecen de movimiento por lo que no van a entender el mensaje moverse() pero si el mensaje interactuar(). Cuando un pincho toca a isaac este le reduce 5 puntos de vida. Cuando una puerta interactua con isaac no le hace nada, su configuracion de colisión se encuentra en el objeto nivel. Las rejas lo bloquean si quiere avanzar hacia un sentido. + +![Juego](assets/puerta1.png) + +Cada nivel es un escenario el cual está representado en una clase Escenario. En este juego disponemos de 3 niveles para completar. Esta contiene la posición de las llaves en cada nivel, el método para agregar a isaac al mapa y un metodo visuales() abstracto. Cada escenario que hereda estos comportamientos utiliza visuales para agregar sus propias imagenes, ya que cada uno es diferente al otro. +![Diagrama](assets/diagramaFinal.png) \ No newline at end of file diff --git a/assets/cofre.png b/assets/cofre.png new file mode 100644 index 0000000..5f4e737 Binary files /dev/null and b/assets/cofre.png differ diff --git a/assets/cofreAbierto.png b/assets/cofreAbierto.png new file mode 100644 index 0000000..8293b39 Binary files /dev/null and b/assets/cofreAbierto.png differ diff --git a/assets/cura.png b/assets/cura.png new file mode 100644 index 0000000..277a2c8 Binary files /dev/null and b/assets/cura.png differ diff --git a/assets/diagramaFinal.png b/assets/diagramaFinal.png new file mode 100644 index 0000000..075bc8c Binary files /dev/null and b/assets/diagramaFinal.png differ diff --git a/assets/enemigo.png b/assets/enemigo.png new file mode 100644 index 0000000..ae69dbb Binary files /dev/null and b/assets/enemigo.png differ diff --git a/assets/fantasma.png b/assets/fantasma.png new file mode 100644 index 0000000..7aca5cb Binary files /dev/null and b/assets/fantasma.png differ diff --git a/assets/fondoMusica.mp3 b/assets/fondoMusica.mp3 new file mode 100644 index 0000000..d3c7baf Binary files /dev/null and b/assets/fondoMusica.mp3 differ diff --git a/assets/golondrina.png b/assets/golondrina.png deleted file mode 100644 index 1660f61..0000000 Binary files a/assets/golondrina.png and /dev/null differ diff --git a/assets/isaacConArmadura.png b/assets/isaacConArmadura.png new file mode 100644 index 0000000..8fecebc Binary files /dev/null and b/assets/isaacConArmadura.png differ diff --git a/assets/llavePuerta.png b/assets/llavePuerta.png new file mode 100644 index 0000000..418b3f9 Binary files /dev/null and b/assets/llavePuerta.png differ diff --git a/assets/mago.png b/assets/mago.png new file mode 100644 index 0000000..46b919a Binary files /dev/null and b/assets/mago.png differ diff --git a/assets/nivel.png b/assets/nivel.png new file mode 100644 index 0000000..7ecbc98 Binary files /dev/null and b/assets/nivel.png differ diff --git a/assets/pantallaDeCarga.png b/assets/pantallaDeCarga.png new file mode 100644 index 0000000..2a1027b Binary files /dev/null and b/assets/pantallaDeCarga.png differ diff --git a/assets/peque.png b/assets/peque.png new file mode 100644 index 0000000..4e8e903 Binary files /dev/null and b/assets/peque.png differ diff --git a/assets/perdi.png b/assets/perdi.png new file mode 100644 index 0000000..a372ae8 Binary files /dev/null and b/assets/perdi.png differ diff --git a/assets/pinchosDefinitivo.png b/assets/pinchosDefinitivo.png new file mode 100644 index 0000000..9e8cd4e Binary files /dev/null and b/assets/pinchosDefinitivo.png differ diff --git a/assets/puerta1.png b/assets/puerta1.png new file mode 100644 index 0000000..9623e31 Binary files /dev/null and b/assets/puerta1.png differ diff --git a/assets/puertaAbierta.png b/assets/puertaAbierta.png new file mode 100644 index 0000000..5c8e07a Binary files /dev/null and b/assets/puertaAbierta.png differ diff --git a/assets/reja1.png b/assets/reja1.png new file mode 100644 index 0000000..998d98d Binary files /dev/null and b/assets/reja1.png differ diff --git a/assets/reja2.png b/assets/reja2.png new file mode 100644 index 0000000..313ebfb Binary files /dev/null and b/assets/reja2.png differ diff --git a/assets/reja3.png b/assets/reja3.png new file mode 100644 index 0000000..678c8cb Binary files /dev/null and b/assets/reja3.png differ diff --git a/assets/sinArmadura.png b/assets/sinArmadura.png new file mode 100644 index 0000000..160ccd6 Binary files /dev/null and b/assets/sinArmadura.png differ diff --git a/assets/win.png b/assets/win.png new file mode 100644 index 0000000..2af8c88 Binary files /dev/null and b/assets/win.png differ diff --git a/bicho.wlk b/bicho.wlk new file mode 100644 index 0000000..247c500 --- /dev/null +++ b/bicho.wlk @@ -0,0 +1,102 @@ +import wollok.game.* +import isaac.* +import nivel.* +import obstaculos.* + +class Enemigo{ + + var subiendo = true + var horizontal = true + var property moverse = true + var property position = game.at(20,3) + + const limiteSuperior = 15 + const limiteInferior = 3 + const limiteDerecho = 15 + const limiteIzquierdo = 3 + + method image() = "enemigo.png" + + method moverse() = + if(moverse && subiendo){ + game.onTick(400, "movimiento", {self.movimientoVertical()}) + moverse = false + } + else if (moverse && horizontal){ + game.onTick(400, "movimiento", {self.movimientoHorizontal()}) + moverse = false + } + + method movimientoVertical(){ + if(position.y() limiteInferior){ + subiendo=false + } + if(position.y() == limiteInferior){ + subiendo = true + } + } + } + + method movimientoHorizontal(){ + if(position.x()< limiteDerecho and horizontal){ + position = position.right(1) + }else{ + position = position.left(1) + if(position.x()> limiteIzquierdo){ + horizontal = false + } + if(position.x() == limiteIzquierdo){ + horizontal = true + } + } + } + method interactuar(){ + isaac.danio(10) + } +} + +class Mago inherits Enemigo{ + var contador = 0 + + override method image() = "mago.png" + + override method interactuar(){ + game.onTick(650 ,"danio", {self.ataque()}) + } + + method ataque(){ + isaac.danio(1) + contador = contador + 1 + + if(contador == 10){ + game.removeTickEvent("danio") + contador = 0 + } + } +} + + +class Fantasma inherits Enemigo{ + override method image() = "fantasma.png" + + override method interactuar(){ + isaac.danio(15) + isaac.image("sinArmadura.png") + } +} + + +const bicho1 = new Enemigo(subiendo = false, limiteDerecho = 28 , limiteIzquierdo = 1, position = game.at(15,6)) +const bicho2 = new Enemigo(horizontal = false, limiteSuperior = 18, limiteInferior = 1, position = game.at(20,1)) +const bicho3 = new Enemigo(horizontal = false, limiteSuperior= 18, limiteInferior = 1,position = game.at(16,17)) +const bicho4 = new Enemigo(subiendo = false, limiteDerecho = 28, limiteIzquierdo = 1, position = game.at(15,16)) +const bicho5 = new Enemigo(horizontal = false, limiteSuperior = 18, limiteInferior = 12, position = game.at(12,16)) +const mago1 = new Mago(subiendo = false, limiteDerecho = 24 , limiteIzquierdo = 10, position = game.at(10,10)) +const mago2 = new Mago(subiendo = false, limiteDerecho = 22 , limiteIzquierdo = 12, position = game.at(12,6)) +const mago3 = new Mago(subiendo = false, limiteDerecho = 22, limiteIzquierdo = 14, position = game.at(14,10)) +const fantasma1 = new Fantasma(horizontal = false, limiteSuperior = 15 , limiteInferior = 1, position = game.at(24,3)) +const fantasma2 = new Fantasma(horizontal = false, limiteSuperior = 9 , limiteInferior = 1, position = game.at(12,3)) diff --git a/isaac.wlk b/isaac.wlk new file mode 100644 index 0000000..f585b16 --- /dev/null +++ b/isaac.wlk @@ -0,0 +1,50 @@ +import wollok.game.* +import nivel.* +import obstaculos.* + +object isaac{ + + var property vida = 100 + + var property image = "peque.png" + + var property position = game.at(2,2) + + var property tieneLlave = false + + method moverse(nuevaPosicion) { + // Define los límites del área de juego + const limiteX = 30 + const limiteY = 18 + const minimoX = 1 + const minimoY = 1 + + // Solo actualiza la posición si está dentro de los límites + if (nuevaPosicion.x() >= minimoX && nuevaPosicion.x() <= limiteX && + nuevaPosicion.y() >= minimoY && nuevaPosicion.y() <= limiteY) { + position = nuevaPosicion + } + } + + method avanzarNivel(escenario){ + if (tieneLlave && nivel.escenarioActual() != escenario) + nivel.cambiarEscenario(escenario) + else game.say(self, "Necesito la llave") + } + + method danio(n) { + vida = vida -n + + if(self.vida() == 0){ + nivel.muerte() + } + else{ + game.say(self, "me queda "+ self.vida() + " de vida") + } + } + + method terminarJuego(){ + if(tieneLlave && nivel.escenarioActual() == nivel3) + nivel.finalizar() + } +} \ No newline at end of file diff --git a/log/wollok.log b/log/wollok.log new file mode 100644 index 0000000..138b7b1 --- /dev/null +++ b/log/wollok.log @@ -0,0 +1 @@ +{"failures":[],"level":"info","message":"🧪 Test runner executed on c:\\Users\\fabri\\Downloads\\TePe\\2024-o-tpjuego-lambda","result":{"failed":0,"ok":7},"timeElapsed":1075,"timestamp":"2024-11-14T00:55:17.642Z"} diff --git a/log/wollok1.log b/log/wollok1.log new file mode 100644 index 0000000..226738b --- /dev/null +++ b/log/wollok1.log @@ -0,0 +1,69 @@ +{"level":"info","message":"⌛ Building environment","timeElapsed":135,"timestamp":"2024-11-14T02:01:41.316Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":109,"timestamp":"2024-11-14T02:01:41.426Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":188,"timestamp":"2024-11-14T02:01:42.518Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":280,"timestamp":"2024-11-14T02:01:42.800Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":123,"timestamp":"2024-11-14T02:01:42.923Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":122,"timestamp":"2024-11-14T02:01:43.055Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":271,"timestamp":"2024-11-14T02:01:44.403Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":145,"timestamp":"2024-11-14T02:01:44.555Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":170,"timestamp":"2024-11-14T02:01:44.726Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":143,"timestamp":"2024-11-14T02:01:44.871Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":161,"timestamp":"2024-11-14T02:01:45.033Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":117,"timestamp":"2024-11-14T02:01:45.160Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":199,"timestamp":"2024-11-14T02:01:52.857Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":106,"timestamp":"2024-11-14T02:01:52.965Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":162,"timestamp":"2024-11-14T02:01:53.372Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":113,"timestamp":"2024-11-14T02:01:53.486Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":228,"timestamp":"2024-11-14T02:04:20.272Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":165,"timestamp":"2024-11-14T02:04:20.438Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":109,"timestamp":"2024-11-14T02:04:20.548Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":135,"timestamp":"2024-11-14T02:04:20.683Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":114,"timestamp":"2024-11-14T02:04:20.798Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":114,"timestamp":"2024-11-14T02:04:20.913Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":179,"timestamp":"2024-11-14T02:04:21.093Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":120,"timestamp":"2024-11-14T02:04:21.217Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":153,"timestamp":"2024-11-14T02:04:21.373Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":149,"timestamp":"2024-11-14T02:04:21.530Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":142,"timestamp":"2024-11-14T02:04:21.680Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":119,"timestamp":"2024-11-14T02:04:21.798Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":122,"timestamp":"2024-11-14T02:04:21.921Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":129,"timestamp":"2024-11-14T02:04:22.051Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":110,"timestamp":"2024-11-14T02:04:22.162Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":122,"timestamp":"2024-11-14T02:04:22.285Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":149,"timestamp":"2024-11-14T02:04:22.437Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":155,"timestamp":"2024-11-14T02:04:22.600Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":158,"timestamp":"2024-11-14T02:04:22.758Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":115,"timestamp":"2024-11-14T02:04:22.874Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":132,"timestamp":"2024-11-14T02:04:23.007Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":112,"timestamp":"2024-11-14T02:04:23.125Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":128,"timestamp":"2024-11-14T02:04:23.253Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":164,"timestamp":"2024-11-14T02:04:23.418Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":124,"timestamp":"2024-11-14T02:04:23.543Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":114,"timestamp":"2024-11-14T02:04:23.657Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":131,"timestamp":"2024-11-14T02:04:23.787Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":112,"timestamp":"2024-11-14T02:04:23.900Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":128,"timestamp":"2024-11-14T02:04:24.029Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":134,"timestamp":"2024-11-14T02:04:24.164Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":126,"timestamp":"2024-11-14T02:04:24.294Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":125,"timestamp":"2024-11-14T02:04:24.424Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":152,"timestamp":"2024-11-14T02:04:24.577Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":211,"timestamp":"2024-11-14T02:04:24.793Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":118,"timestamp":"2024-11-14T02:04:24.917Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":163,"timestamp":"2024-11-14T02:04:25.081Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":135,"timestamp":"2024-11-14T02:04:25.230Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":107,"timestamp":"2024-11-14T02:04:25.338Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":142,"timestamp":"2024-11-14T02:04:25.480Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":101,"timestamp":"2024-11-14T02:04:25.585Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":185,"timestamp":"2024-11-14T02:04:40.000Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":129,"timestamp":"2024-11-14T02:04:40.131Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":182,"timestamp":"2024-11-14T02:04:40.630Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":153,"timestamp":"2024-11-14T02:04:41.482Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":114,"timestamp":"2024-11-14T02:04:41.598Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":196,"timestamp":"2024-11-14T02:04:42.512Z"} +{"level":"info","message":"⌛ Validating nivel.wlk","timeElapsed":126,"timestamp":"2024-11-14T02:04:42.643Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":139,"timestamp":"2024-11-14T02:04:44.486Z"} +{"level":"info","message":"⌛ Validating isaac.wlk","timeElapsed":106,"timestamp":"2024-11-14T02:04:44.595Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":170,"timestamp":"2024-11-14T02:04:49.908Z"} +{"level":"info","message":"⌛ Validating obstaculos.wlk","timeElapsed":137,"timestamp":"2024-11-14T02:04:50.047Z"} +{"level":"info","message":"⌛ Building environment","timeElapsed":189,"timestamp":"2024-11-14T02:04:50.906Z"} +{"level":"info","message":"⌛ Validating obstaculos.wlk","timeElapsed":125,"timestamp":"2024-11-14T02:04:51.035Z"} diff --git a/main.wpgm b/main.wpgm index 4337325..2181cba 100644 --- a/main.wpgm +++ b/main.wpgm @@ -1,16 +1,16 @@ import wollok.game.* +import isaac.* +import nivel.* +import obstaculos.* -import pepita.* -program PepitaGame { - game.title("Pepita") - game.height(10) - game.width(10) - game.cellSize(100) - - game.addVisual(pepita) - - keyboard.w().onPressDo({ pepita.fly(1) }) +program isaacGame { + + const musica = game.sound("fondoMusica.mp3") + musica.shouldLoop(true) + game.schedule(500, { musica.play()} ) + nivel.inicio() game.start() } + diff --git a/nivel.wlk b/nivel.wlk new file mode 100644 index 0000000..0ecf1fe --- /dev/null +++ b/nivel.wlk @@ -0,0 +1,207 @@ +import wollok.game.* +import isaac.* +import visuales.* +import bicho.* +import obstaculos.* + +object nivel{ + + const anchoTotal = 33 + const altoTotal = 23 + const celdaSize = 27 + + var escenarioActual = nivel1 + + method escenarioActual() = escenarioActual + + method inicio(){ + + self.configuracion() + + game.title("El reino de las arenas") + game.height(altoTotal) + game.width(anchoTotal) + game.cellSize(celdaSize) + game.addVisual(inicioDelJuego) + + keyboard.s().onPressDo({self.cambiarEscenario(nivel1)}) + } + + method clearGame(){ + isaac.tieneLlave(false) + game.allVisuals().forEach({visual => game.removeVisual(visual)}) + } + + method cambiarEscenario(nivel){ + escenarioActual = nivel + self.clearGame() + game.addVisual(fondoDelJuego) + isaac.moverse(game.at(2,2)) + llave.cambiarPosicion(nivel.posicionLlave()) + escenarioActual.aniadirIsaac() + escenarioActual.visuales() + } + + method configuracion(){ //Configuracion del juego + + //Movimiento de Isaac + keyboard.up().onPressDo{isaac.moverse(isaac.position().up(1))} + keyboard.down().onPressDo{isaac.moverse(isaac.position().down(1))} + keyboard.left().onPressDo{isaac.moverse(isaac.position().left(1))} + keyboard.right().onPressDo{ isaac.moverse(isaac.position().right(1))} + + //interactuar + game.whenCollideDo(isaac, {obstaculo => obstaculo.interactuar()}) + } + + method muerte(){ + self.clearGame() + game.addVisual(gameOver) + isaac.vida(100) + isaac.image("peque.png") + } + + method finalizar(){ + self.clearGame() + game.addVisual(finDelJuego) + isaac.vida(100) + isaac.image("peque.png") + cofre.abierto(false) + } +} + +class Escenario{ + const property posicionLlave + method aniadirIsaac(){ + game.addVisual(isaac) + } + method visuales() +} + +class Escenario1 inherits Escenario{ + override method visuales(){ + + game.addVisual(puerta1) + game.addVisual(cofre) + game.addVisual(pincho1) + game.addVisual(pincho2) + game.addVisual(pincho3) + game.addVisual(pincho4) + game.addVisual(pincho5) + game.addVisual(pincho6) + game.addVisual(reja1) + game.addVisual(reja2) + game.addVisual(reja3) + game.addVisual(reja4) + game.addVisual(reja5) + game.addVisual(reja6) + game.addVisual(reja7) + game.addVisual(reja8) + game.addVisual(reja9) + game.addVisual(reja10) + game.addVisual(reja11) + game.addVisual(reja12) + game.addVisual(hitbox1) + game.addVisual(hitbox2) + game.addVisual(hitbox3) + game.addVisual(hitbox4) + game.addVisual(hitbox5) + game.addVisual(hitbox6) + game.addVisual(hitbox7) + game.addVisual(hitbox8) + game.addVisual(hitbox9) + game.addVisual(hitbox10) + + + game.addVisual(cura) + game.addVisual(llave) + game.addVisual(bicho1) + game.addVisual(bicho2) + game.addVisual(mago1) + + mago1.moverse() + bicho1.moverse() + bicho2.moverse() + + game.whenCollideDo(puerta1, {nivel => nivel.avanzarNivel(nivel2)}) + } +} + +class Escenario2 inherits Escenario{ + override method visuales(){ + game.addVisual(puerta2) + + game.addVisual(reja13) + game.addVisual(reja14) + game.addVisual(reja15) + game.addVisual(reja16) + game.addVisual(reja17) + game.addVisual(reja18) + game.addVisual(reja19) + game.addVisual(hitbox11) + game.addVisual(hitbox12) + game.addVisual(hitbox13) + game.addVisual(hitbox14) + game.addVisual(hitbox15) + game.addVisual(hitbox16) + + game.addVisual(cura) + game.addVisual(llave) + game.addVisual(pincho7) + game.addVisual(pincho8) + game.addVisual(pincho9) + game.addVisual(pincho10) + game.addVisual(pincho11) + game.addVisual(pincho12) + game.addVisual(pincho13) + game.addVisual(pincho14) + game.addVisual(pincho15) + game.addVisual(pincho16) + game.addVisual(pincho17) + game.addVisual(pincho18) + game.addVisual(pincho19) + game.addVisual(pincho20) + + game.addVisual(mago2) + game.addVisual(bicho3) + game.addVisual(bicho4) + + mago2.moverse() + bicho3.moverse() + bicho4.moverse() + + game.whenCollideDo(puerta2, {nivel => nivel.avanzarNivel(nivel3)}) + } +} + +class Escenario3 inherits Escenario{ + override method visuales(){ + game.addVisual(puerta3) + + game.addVisual(cura) + game.addVisual(llave) + + game.addVisual(pincho21) + game.addVisual(pincho22) + game.addVisual(pincho23) + game.addVisual(pincho24) + game.addVisual(pincho25) + game.addVisual(pincho26) + + game.addVisual(mago3) + game.addVisual(fantasma1) + game.addVisual(fantasma2) + game.addVisual(bicho5) + + fantasma1.moverse() + fantasma2.moverse() + mago3.moverse() + bicho5.moverse() + + game.whenCollideDo(puerta3, {nivel => nivel.terminarJuego()}) + } +} + +const nivel1 = new Escenario1(posicionLlave= game.at(30,3)) +const nivel2 = new Escenario2(posicionLlave= game.at(4,10)) +const nivel3 = new Escenario3(posicionLlave= game.at(3,17)) \ No newline at end of file diff --git a/obstaculos.wlk b/obstaculos.wlk new file mode 100644 index 0000000..3d629f7 --- /dev/null +++ b/obstaculos.wlk @@ -0,0 +1,154 @@ +import wollok.game.* +import isaac.* +import visuales.* +import bicho.* +import nivel.* + +class Pinchos{ + + method image() = "pinchosDefinitivo.png" + + var property position = game.at(6,1) + + method interactuar(){ + isaac.danio(5) + } +} + +class Puerta{ + + method image() = "puerta1.png" + + method interactuar() {} + + var property position = game.at(15,18) +} + +class Reja{ + var property position = game.at(6,12) + + const imagen = "reja2.png" + + method image() = imagen + + method interactuar() { + isaac.moverse(game.at(isaac.position().x() , isaac.position().y() - 1)) + } +} + +object llave { + var property position = game.at(21,10) + + method image() = "llavePuerta.png" + + method interactuar() { + isaac.tieneLlave(true) + game.removeVisual(self) + } + method cambiarPosicion(nuevaPosicion){ + self.position(nuevaPosicion) + } +} + +object cura{ + var property position = game.at(29,14) + + method image() = "cura.png" + + method interactuar(){ + isaac.vida(isaac.vida() + 40) + game.say(isaac, "Ahora tengo " + isaac.vida() + " de vida") + game.removeVisual(self) + } +} + +object cofre{ + var property position = game.at(3,16) + var property abierto = false + var property image = "cofre.png" + + method interactuar(){ + self.image("cofreAbierto.png") + if(!abierto){ + isaac.vida(isaac.vida() + 20) + game.say(isaac, "Ahora tengo " + isaac.vida() + " de vida") + isaac.image("isaacConArmadura.png") + abierto = true + } + } +} + +class Hitbox{ + var property position = game.at(7,12) + method interactuar() { + isaac.moverse(game.at(isaac.position().x() , isaac.position().y() - 1)) + } +} + +const reja1 = new Reja(imagen = "reja1.png") +const hitbox1 = new Hitbox() +const reja2 = new Reja(position = game.at(8,12)) +const hitbox2 = new Hitbox(position = game.at(9,12)) +const reja3 = new Reja(position = game.at(10,12)) +const hitbox3 = new Hitbox(position = game.at(11,12)) +const reja4 = new Reja(position = game.at(12,12)) +const hitbox4 = new Hitbox(position = game.at(13,12)) +const reja5 = new Reja(position = game.at(14,12)) +const hitbox5 = new Hitbox(position = game.at(15,12)) +const reja6 = new Reja(position = game.at(16,12)) +const hitbox6 = new Hitbox(position = game.at(17,12)) +const reja7 = new Reja(imagen = "reja3.png",position = game.at(18,12)) +const reja8 = new Reja(imagen = "reja1.png",position = game.at(22,12)) +const hitbox7 = new Hitbox(position = game.at(23,12)) +const reja9 = new Reja(position = game.at(24,12)) +const hitbox8 = new Hitbox(position = game.at(25,12)) +const reja10 = new Reja(position = game.at(26,12)) +const hitbox9 = new Hitbox(position = game.at(27,12)) +const reja11 = new Reja(position = game.at(28,12)) +const hitbox10 = new Hitbox(position = game.at(29,12)) +const reja12 = new Reja(imagen = "reja3.png", position = game.at(30,12)) + +const reja13 = new Reja(imagen = "reja1.png",position = game.at(2,4)) +const hitbox11 = new Hitbox(position = game.at(3,4)) +const reja14 = new Reja(position = game.at(4,4)) +const hitbox12 = new Hitbox(position = game.at(5,4)) +const reja15 = new Reja(position = game.at(6,4)) +const hitbox13 = new Hitbox(position = game.at(7,4)) +const reja16 = new Reja(position = game.at(8,4)) +const hitbox14 = new Hitbox(position = game.at(9,4)) +const reja17 = new Reja(position = game.at(10,4)) +const hitbox15 = new Hitbox(position = game.at(11,4)) +const reja18 = new Reja(position = game.at(12,4)) +const hitbox16 = new Hitbox(position = game.at(13,4)) +const reja19 = new Reja(imagen = "reja3.png",position = game.at(14,4)) + +const pincho1 = new Pinchos() +const pincho2 = new Pinchos(position= game.at(6,3)) +const pincho3 = new Pinchos(position= game.at(6,8)) +const pincho4 = new Pinchos(position= game.at(6,10)) +const pincho5 = new Pinchos(position = game.at(6,14)) +const pincho6 = new Pinchos(position = game.at(6,16)) +const pincho7 = new Pinchos(position = game.at(10,6)) +const pincho8 = new Pinchos(position = game.at(10,8)) +const pincho9 = new Pinchos(position = game.at(10,10)) +const pincho10 = new Pinchos(position = game.at(10,12)) +const pincho11 = new Pinchos(position = game.at(10,14)) +const pincho12 = new Pinchos(position = game.at(18,4)) +const pincho13 = new Pinchos(position = game.at(20,4)) +const pincho14 = new Pinchos(position = game.at(22,4)) +const pincho15 = new Pinchos(position = game.at(24,4)) +const pincho16 = new Pinchos(position = game.at(24,6)) +const pincho17 = new Pinchos(position = game.at(24,8)) +const pincho18 = new Pinchos(position = game.at(24,10)) +const pincho19 = new Pinchos(position = game.at(24,12)) +const pincho20 = new Pinchos(position = game.at(24,14)) +const pincho21 = new Pinchos(position = game.at(2,10)) +const pincho22 = new Pinchos(position = game.at(4,10)) +const pincho23 = new Pinchos(position = game.at(6,10)) +const pincho24 = new Pinchos(position = game.at(8,10)) +const pincho25 = new Pinchos(position = game.at(10,10)) +const pincho26 = new Pinchos(position = game.at(12,10)) + +const puerta1 = new Puerta() +const puerta2 = new Puerta(position = game.at(6,18)) +const puerta3 = new Puerta(position = game.at(20,18)) \ No newline at end of file diff --git a/pepita.wlk b/pepita.wlk deleted file mode 100644 index 8763973..0000000 --- a/pepita.wlk +++ /dev/null @@ -1,16 +0,0 @@ -object pepita { - var energy = 100 - const position = new MutablePosition(x=0, y=0) - - method image() = "golondrina.png" - method position() = position - - method energy() = energy - - method fly(minutes) { - energy = energy - minutes * 3 - position.goRight(minutes) - position.goUp(minutes) - } - -} \ No newline at end of file diff --git a/pruebas.wtest b/pruebas.wtest index 7342cd1..fdf0c2e 100644 --- a/pruebas.wtest +++ b/pruebas.wtest @@ -1,9 +1,44 @@ -import pepita.* +import wollok.game.* +import isaac.* +import bicho.* +import nivel.* +import obstaculos.* -describe "group of tests for pepita" { +describe "tests para isaac" { + test "isaac al tocar un pinche se le restan 5 pts de vida" { + pincho1.interactuar() + assert.equals(95, isaac.vida()) + } + test "isaac al tocar un bicho se le restan 10 pts de vida" { + bicho1.interactuar() + assert.equals(90, isaac.vida()) + } - test "pepita has initial energy" { - assert.equals(100, pepita.energy()) + test "isaac al agarrar una pocion se cura 40 de vida"{ + isaac.vida(50) + cura.interactuar() + assert.equals(90,isaac.vida()) } + test "el fantasma toca a isaac y lo despoja de sus armaduras"{ + fantasma1.interactuar() + assert.equals(85, isaac.vida()) + assert.equals("sinArmadura.png", isaac.image()) + } + + test "isaac al abrir el cofre se cura 20 de vida y se pone armadura"{ + isaac.vida(80) + cofre.interactuar() + assert.equals(100, isaac.vida()) + assert.equals("isaacConArmadura.png", isaac.image()) + } + test "isaac al pasar por la puerta pasa de nivel (con llave)"{ + isaac.tieneLlave(true) + isaac.avanzarNivel(nivel2) + assert.equals(nivel2, nivel.escenarioActual()) + } + test "isaac no pasa por la puerta sin la llave"{ + isaac.avanzarNivel(nivel2) + assert.equals(nivel1, nivel.escenarioActual()) + } } \ No newline at end of file diff --git a/visuales.wlk b/visuales.wlk new file mode 100644 index 0000000..3eac6b6 --- /dev/null +++ b/visuales.wlk @@ -0,0 +1,30 @@ +import isaac.* +import nivel.* +import wollok.game.* + +class Visual{ + var property image + var property position = game.origin() +} + +const inicioDelJuego = new Visual( + image = "pantallaDeCarga.png", + position = game.at(0,0) +) + +const fondoDelJuego = new Visual( + image = "nivel.png", + position = game.at(0,0) +) + +const finDelJuego = new Visual( + image = "win.png", + position = game.at(0,0) +) + +const gameOver = new Visual( + image = "perdi.png", + position = game.at(0,0) +) + +