-
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.
Agregue eventos a las colisiones y musica
- Loading branch information
Showing
11 changed files
with
125 additions
and
18 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class Fantasmas { | ||
const position = new MutablePosition() | ||
var property estado= "movil" | ||
var property zombie = "zombie" | ||
|
||
method position() = position | ||
|
||
method movete() { | ||
if(self.estado()=="movil") | ||
position.goLeft(1) | ||
else zombie.moveteDerecha() | ||
} | ||
method moveteDerecha() { | ||
position.goRight(1) | ||
} | ||
} |
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,26 @@ | ||
import zombie.* | ||
object generadorDeEnemigos { | ||
var nombreEnemigo = 0 /*asigno el nombre a los enemigos que voy creando segun numeros, asi puedo crear nombres nuevos | ||
automaticamente*/ | ||
|
||
const enemigo = #{}/*contiene cada enemigo que fue creando*/ | ||
|
||
method nombre() = nombreEnemigo /*para poder consultar el ultimo nombre usado*/ | ||
method sumarEnemigo() { /*suma 1 a nombre enemigo para asi crear enemigos nuevos, luego hay que hacer la funcion | ||
para que reste 1 cuando maten a un enemigo*/ | ||
nombreEnemigo+=1 | ||
} | ||
method generarEnemigo(numero){/*segun el numero ingresado, se generara un tipo de enemigo distinto*/ | ||
if (numero==1) {/*generara un zombie normal*/ | ||
var nombreParaEnemigo = self.nombre() /* esto esta hecho porque sino wollok se enoja, | ||
para poder crear un enemigo*/ | ||
nombreParaEnemigo = new ZombiesNormales() | ||
enemigo.add(nombreParaEnemigo)/*se añade a la lista de enemigos activos*/ | ||
return game.addVisual(nombreParaEnemigo)/*muestra al enemigo en el juego*/ | ||
} | ||
return 0 | ||
} | ||
method moverEnemigos() { | ||
enemigo.forEach({zombie => zombie.movete()})/*aplica la funcion movete a cada enemigo de la coleccion*/ | ||
} | ||
} |
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 |
---|---|---|
@@ -1,18 +1,46 @@ | ||
import wollok.game.* | ||
|
||
import pepita.* | ||
|
||
import zombie.* | ||
import fantasma.* | ||
import generadorDeEnemigos.* | ||
program PepitaGame { | ||
game.title("Pepita") | ||
game.height(18) | ||
game.width(25) | ||
game.cellSize(50) | ||
|
||
game.height(5) | ||
game.width(15) | ||
game.cellSize(100) | ||
/*game.addVisual(Fantasmas)*/ | ||
game.addVisual(pepita) | ||
|
||
keyboard.d().onPressDo({ pepita.moverseDerecha(1) }) | ||
keyboard.a().onPressDo({ pepita.moverseIzquierda(1) }) | ||
keyboard.w().onPressDo({ pepita.moverseArriba(1) }) | ||
keyboard.s().onPressDo({ pepita.moverseAbajo(1) }) | ||
game.onTick(3000, "generar nuevo Enemigo", {generadorDeEnemigos.sumarEnemigo() | ||
generadorDeEnemigos.generarEnemigo(1)})/*suma 1 a nombreEnemigo para poder crear el siguiente, y genera un enemigo, | ||
se hace en este orden ya que si se crea el primer enemigo, luego un segundo, y antes de que que se genere el | ||
tercero el jugador elimina el primero, habra dos enemigos con el nombre "2" */ | ||
|
||
game.onTick(3000, "mover enemigo", {generadorDeEnemigos.moverEnemigos()})/*cada cierto tiempo hace que se muevan | ||
los enemigos*/ | ||
|
||
keyboard.w().onPressDo({ pepita.fly(1) }) | ||
game.whenCollideDo(pepita, { elemento => | ||
elemento.moverse(false) | ||
})/*cuando chocan con pepita, frenan, a futuro seria que cuando un zombie choca con una planta, frena y empieza a | ||
atacar*/ | ||
|
||
|
||
|
||
game.start() | ||
|
||
game.onCollideDo(pepita, {elemento => game.say(elemento, "Duro de Cojones")}) | ||
game.onCollideDo(pepita, {elemento => pepita.perderVida(elemento.danio())}) | ||
|
||
game.onTick(3000, "matar pepita", {if (pepita.noEstaViva()){pepita.morir()}}) | ||
|
||
game.start() | ||
const musica = game.sound("musica.mp3") | ||
musica.shouldLoop(true) | ||
game.schedule(100,{musica.play()}) | ||
musica.volume(0.4) | ||
} | ||
|
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 |
---|---|---|
@@ -1,16 +1,31 @@ | ||
import wollok.game.* | ||
|
||
object pepita { | ||
var energy = 100 | ||
const position = new MutablePosition(x=2, y=2) | ||
const position = new MutablePosition(x=0, y=0) | ||
|
||
method image() = "golondrina.png" | ||
method position() = position | ||
var property vida = 3 // Le doy una propiedad vida para que reciba daño cuando choca con un zombie | ||
|
||
method energy() = energy | ||
method perderVida(danio) { vida -= danio} | ||
|
||
method fly(minutes) { | ||
energy = energy - minutes * 3 | ||
position.goRight(minutes) | ||
position.goUp(minutes) | ||
method image() = "marcoRojo.png" | ||
method position() = position | ||
|
||
method moverseDerecha(casillas) { | ||
position.goRight(casillas) | ||
} | ||
method moverseIzquierda(casillas) { | ||
position.goLeft(casillas) | ||
} | ||
method moverseArriba(casillas) { | ||
position.goUp(casillas) | ||
} | ||
method moverseAbajo(casillas) { | ||
position.goDown(casillas) | ||
} | ||
|
||
} | ||
method noEstaViva() = vida < 0 | ||
|
||
method morir(){ | ||
if (self.noEstaViva()){ game.say(self, "Durisimo Helmano")} // Delego la resonsabilidad de morir a pepita | ||
} | ||
} |
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,22 @@ | ||
|
||
class ZombiesNormales { | ||
const position = new MutablePosition(x=10, y=0.randomUpTo(5).truncate(0)) | ||
var property moverse = true /*va a servir para hacer que deje de avanzar*/ | ||
method position() = position | ||
var property imagen = "durisimoHelmano.gif" | ||
method image() = imagen | ||
|
||
method movete() { | ||
if(self.moverse()) | ||
return position.goLeft(1) | ||
else self.moverse(false) | ||
} | ||
method moveteDerecha() { | ||
return position.goRight(1) | ||
} | ||
|
||
var property danio = 1 | ||
|
||
} | ||
|
||
const pepe = new ZombiesNormales() |