Skip to content

Commit

Permalink
perseguidores casi completado
Browse files Browse the repository at this point in the history
  • Loading branch information
MateoGiuffra committed Oct 19, 2023
1 parent ae6da51 commit 36441e8
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 4 deletions.
58 changes: 58 additions & 0 deletions src/enemigos.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,64 @@ class Guardia {

}

class GuardiaPerseguidor inherits Guardia{

const personajes = #{harry, sirius}
var property danio = 10

method perseguir(){
if (self.veAlgunIntruso()){
self.avanzarHacia(self.intrusoMasCercano().position())
}
}

method veAlgunIntruso(){
return personajes.any({personaje => self.puedoVerlo(personaje)})
}

method intrusoMasCercano(){
return personajes.find({personaje => self.puedoVerlo(personaje)})
}



method verAInfiltrado(){
return 3

}

method avanzarHacia(destino){
position = game.at (
position.x() + (destino.x() - position.x()) / 2,
position.y() + (destino.y() - position.y()) / 2
)
}

method puedoVerlo(personaje){

return
self.verAInfiltrado() >= self.position().x() - personaje.position().x() or
self.verAInfiltrado() >= self.position().y() - personaje.position().y()

}



method distanciaEntre(personaje){
return self.position().x() - personaje.position().x()
}

override method colisionarCon(personaje){
personaje.quitarVida(self.danio())
game.say(personaje, personaje.vida().toString() )
}


}




object listaGuardias{
const property guardias = #{}

Expand Down
10 changes: 7 additions & 3 deletions src/juego.wpgm
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ program juego {
game.height(18)
game.boardGround("background2.png")

//game.addVisual(harry)
//game.addVisual(sirius)
const guardia = new GuardiaPerseguidor()
game.addVisual(harry)
game.addVisual(sirius)
game.addVisual(guardia)

game.onTick(500, "", {guardia.perseguir()})

game.onTick(1000, "caminataGuardias", {listaGuardias.caminar()})

nivelx.generar()
//nivelx.generar()

keyboard.up().onPressDo({ harry.mover(arriba) })
keyboard.down().onPressDo({ harry.mover(abajo) })
Expand Down
18 changes: 18 additions & 0 deletions src/nivelx.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,21 @@ object s{
}
}


//object nivel2{
//
// method generar(){
// (0..game.width() -1).forEach({x=>
// (0..game.height() -1).forEach({y=>
// self.generarCelda(x,y)})
// })
//
//
// }
//
// method generarCelda(x,y){
// const celda = celdas.get(y).get(x)
// celda.forEach({objeto => objeto.generar(game.at(x,y))})
// }
//}

17 changes: 16 additions & 1 deletion src/personajes.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,29 @@ class Personaje {

var property estado = self.estadoHabitual()
var property position = game.at(0, 0)

var property vida = 100
method transformacion()
method estadoHabitual()
method puedePasar(puerta)
method entrarEnZonaGuardias()
method image() = estado.image() + ".png"
method colisionarCon(personaje) {
}
method quitarVida(vidaQuitada){
vida -= vidaQuitada
self.verSiPerdi()

}

method verSiPerdi(){
if (vida <= 0) self.perder()

}

method perder(){
self.volverAlPrincipio()
game.say(self, "me mataron")
}

method transformarse() {
estado = self.transformacion()
Expand Down

0 comments on commit 36441e8

Please sign in to comment.