-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
los magos tiran golondrinas ... es un avance(?
- Loading branch information
Showing
9 changed files
with
176 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import game.* | ||
import proyectil.* | ||
|
||
object administradorDeProyectiles { | ||
var nombreProyectil = 10000 /*asigno el nombre a los enemigos que voy creando segun numeros, asi puedo crear nombres nuevos | ||
automaticamente*/ | ||
|
||
const proyectiles = #{}/*contiene cada enemigo que fue creando*/ | ||
method proyectiles() = proyectiles | ||
|
||
method nombre() = nombreProyectil /*para poder consultar el ultimo nombre usado*/ | ||
method sumarProyectil() { /*suma 1 a nombre mago para asi crear magos nuevos, luego hay que hacer la funcion para que reste 1 cuando maten a un enemigo*/ | ||
nombreProyectil+=1 | ||
} | ||
|
||
method generarProyectil(posicion, tipoProyectil){ // metodo para no usar los if anidados | ||
var nombreParaProyectil = self.nombre() | ||
//console.println("el nombre es: " + nombreParaProyectil) | ||
nombreParaProyectil = new Proyectil(position = posicion, tipo = tipoProyectil) | ||
// console.println("el objeto es: " + nombreParaProyectil) | ||
proyectiles.add(nombreParaProyectil) | ||
self.sumarProyectil() | ||
// console.println("proyectiles: " + proyectiles) | ||
return game.addVisual(nombreParaProyectil) | ||
} | ||
|
||
method moverProyectiles(){ | ||
proyectiles.forEach({proyectil => proyectil.mover()}) | ||
} | ||
method impactarProyectiles(){ | ||
proyectiles.forEach({proyectil => proyectil.colisionar()}) | ||
} | ||
method destruirProyectil(proyectil) { | ||
proyectiles.remove(proyectil) | ||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import adminProyectiles.* | ||
import game.* | ||
|
||
class Proyectil { | ||
const tipo | ||
const position = new MutablePosition() | ||
method position() = position | ||
const danio = tipo.danio() | ||
//const imagen = tipo.imagen() | ||
method image() = "golondrina.png" | ||
method mover(){ | ||
position.goRight(1) | ||
if (position.x() >= 12){ | ||
game.removeVisual(self) | ||
administradorDeProyectiles.destruirProyectil(self) | ||
} | ||
} | ||
method queSoy() = "proyectil" | ||
method colisionar(){ | ||
const posicionEnFrente = game.at(position.x() +1 ,position.y()) | ||
const objetoEnfrente = game.getObjectsIn(posicionEnFrente).filter({ objeto => objeto.queSoy() == "zombie" }) | ||
if (!objetoEnfrente.isEmpty()) { | ||
if (objetoEnfrente.first().queSoy() == "cursor") objetoEnfrente.remove(objetoEnfrente.first()) | ||
} | ||
if (!objetoEnfrente.isEmpty()) { | ||
const objetivo = objetoEnfrente.first() | ||
objetivo.recibeDanio(danio) | ||
console.println("el objetivo: " + objetivo + " recibe daño: " + danio) | ||
self.destruirse() | ||
} | ||
} | ||
|
||
method destruirse(){ | ||
if (tipo.destruirse()){ | ||
game.removeVisual(self) | ||
administradorDeProyectiles.destruirProyectil(self) | ||
} | ||
} | ||
|
||
} | ||
|
||
object proyectilNormal{ | ||
var property imagen = "bolaDeFuego.png" | ||
method imagen() = imagen | ||
const danio = 50 | ||
method danio() = danio | ||
|
||
method destruirse() = true | ||
} | ||
|
||
object proyectilPenetrante{ | ||
var property imagen = "proyecticDeMetal.png" | ||
method imagen() = imagen | ||
|
||
const danio = 30 | ||
method danio() = danio | ||
|
||
method destruirse() = false | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters