-
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.
- Loading branch information
1 parent
6524cf0
commit 0d4b43b
Showing
6 changed files
with
86 additions
and
12 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.
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,22 @@ | ||
import zombie.* | ||
object generadorDeEnemigos { | ||
var nombreEnemigo = 0 | ||
const enemigo = #{} | ||
|
||
method nombre() = nombreEnemigo | ||
method sumarEnemigo() { | ||
nombreEnemigo+=1 | ||
} | ||
method generarEnemigo(numero){ | ||
if (numero==1) { | ||
var nombreParaEnemigo = self.nombre() | ||
nombreParaEnemigo = new ZombiesNormales() | ||
enemigo.add(nombreParaEnemigo) | ||
return game.addVisual(nombreParaEnemigo) | ||
} | ||
return 0 | ||
} | ||
method moverEnemigos() { | ||
enemigo.forEach({zombie => zombie.movete()}) | ||
} | ||
} |
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,30 @@ | ||
import wollok.game.* | ||
|
||
import pepita.* | ||
|
||
import zombie.* | ||
import fantasma.* | ||
import generadorDeEnemigos.* | ||
program PepitaGame { | ||
game.title("Pepita") | ||
game.height(10) | ||
game.width(10) | ||
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(7000, "generar nuevo Enemigo", {generadorDeEnemigos.generarEnemigo(1) | ||
generadorDeEnemigos.sumarEnemigo()}) | ||
game.onTick(7000, "mover enemigo", {generadorDeEnemigos.moverEnemigos()}) | ||
|
||
keyboard.w().onPressDo({ pepita.fly(1) }) | ||
game.whenCollideDo(pepita, { elemento => | ||
elemento.estado("frenado") | ||
}) | ||
|
||
|
||
|
||
game.start() | ||
} |
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,20 @@ | ||
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) | ||
method moverseDerecha(casillas) { | ||
position.goRight(casillas) | ||
} | ||
method moverseIzquierda(casillas) { | ||
position.goLeft(casillas) | ||
} | ||
method moverseArriba(casillas) { | ||
position.goUp(casillas) | ||
} | ||
method moverseAbajo(casillas) { | ||
position.goDown(casillas) | ||
} | ||
|
||
} |
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,18 @@ | ||
|
||
class ZombiesNormales { | ||
const position = new MutablePosition(x=10, y=0.randomUpTo(5).truncate(0)) | ||
var property estado= "movil" | ||
method position() = position | ||
var property imagen = "golondrina.png" | ||
method image() = imagen | ||
|
||
method movete() { | ||
if(self.estado()=="movil") | ||
return position.goLeft(1) | ||
else self.estado("frenado") | ||
} | ||
method moveteDerecha() { | ||
return position.goRight(1) | ||
} | ||
} | ||
|