Skip to content

Commit

Permalink
agregue para que si una cierta cantidad de
Browse files Browse the repository at this point in the history
enemigos llegan a el lado izquierdo de la pantalla,
el jugador pierda
  • Loading branch information
NahuelMarek committed Oct 16, 2024
1 parent 5ee18ac commit 2ba8c95
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 4 deletions.
Binary file added assets/fin.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions casa.wlk
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
object casa {
var property vida = 3
method recibirDanio() {
self.vida(self.vida()-1)
}
method terminarJuego() = if (self.vida()==0) {

game.addVisual(pantallaFinal)
game.schedule(500,{game.stop()})
}
}

class HitboxCasa {
const position
method position() = position
method queSoy() = "casa"
}

const hitbox1 = new HitboxCasa(position = game.at(0, 0))
const hitbox2 = new HitboxCasa(position = game.at(0, 1))
const hitbox3 = new HitboxCasa(position = game.at(0, 2))
const hitbox4 = new HitboxCasa(position = game.at(0, 3))
const hitbox5 = new HitboxCasa(position = game.at(0, 4))

object pantallaFinal {
method position()=game.at(0,0)
method image()= "fin.jpg"
}
/* game.addVisual(hitbox1)
game.addVisual(hitbox2)
game.addVisual(hitbox3)
game.addVisual(hitbox4)
game.addVisual(hitbox5)
game.onCollideDo(hitbox1, {elemento => elemento.daniarCasa()})
game.onCollideDo(hitbox2, {elemento => elemento.daniarCasa()})
game.onCollideDo(hitbox3, {elemento => elemento.daniarCasa()})
game.onCollideDo(hitbox4, {elemento => elemento.daniarCasa()})
game.onCollideDo(hitbox5, {elemento => elemento.daniarCasa()}) */
15 changes: 14 additions & 1 deletion main.wpgm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import wollok.game.*

import cursor.*
import zombie.*
import fantasma.*
import casa.*
import menu.*
import generadorDeEnemigos.*
import puntaje.*
Expand All @@ -24,6 +24,17 @@ program cursorGame {
cursor.accion()
menu.iniciarTienda()

game.addVisual(hitbox1)
game.addVisual(hitbox2)
game.addVisual(hitbox3)
game.addVisual(hitbox4)
game.addVisual(hitbox5)
game.onCollideDo(hitbox1, {elemento => elemento.daniarCasa()})
game.onCollideDo(hitbox2, {elemento => elemento.daniarCasa()})
game.onCollideDo(hitbox3, {elemento => elemento.daniarCasa()})
game.onCollideDo(hitbox4, {elemento => elemento.daniarCasa()})
game.onCollideDo(hitbox5, {elemento => elemento.daniarCasa()})

// metodos generador de enemigos
game.onTick(3000, "generar nuevo Enemigo", {generadorDeEnemigos.sumarEnemigo()
generadorDeEnemigos.generarEnemigo(1)})/*suma 1 a nombreEnemigo para poder crear el siguiente, y genera un enemigo,
Expand All @@ -46,6 +57,8 @@ program cursorGame {
game.onTick(1000, "moverDisparos", {administradorDeProyectiles.moverProyectiles()})
game.onTick(250, "impactarDisparos", {administradorDeProyectiles.impactarProyectiles()})



//game.schedule(6000,{generadorDeMagos.disparar()}) esto estaba para probar los tiros perforantes
/*
const musica = game.sound("musica.mp3")
Expand Down
2 changes: 1 addition & 1 deletion pruebas.wtest
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe "group of tests for Slimes" {
describe "group of tests for Puntaje" {

test "Puntaje Suma"{
var cantPuntos = puntaje.puntos()
const cantPuntos = puntaje.puntos()
puntaje.sumarPuntos()
assert.that(cantPuntos < puntaje.puntos())
}
Expand Down
8 changes: 6 additions & 2 deletions zombie.wlk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import generadorDeEnemigos.*
import adminProyectiles.*

import casa.*
import colisionExtra.Colision
class SlimeBasico inherits Colision{
const position
Expand Down Expand Up @@ -34,14 +34,18 @@ class SlimeBasico inherits Colision{
}

method estaMuerto(){
if (vida <= 0 || position.x() <= 0){
if (vida <= 0 || position.x() < 0){
game.removeVisual(self)
generadorDeEnemigos.eliminarEnemigo(self)
}
return vida <= 0 || position.x() <= 0

}

method daniarCasa(){
casa.recibirDanio()
casa.terminarJuego()
}
}

//const jose = new SlimeBasico(position= new MutablePosition(x=10, y=0.randomUpTo(5).truncate(0)))
Expand Down

0 comments on commit 2ba8c95

Please sign in to comment.