-
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
d876ba4
commit ec6efec
Showing
5 changed files
with
141 additions
and
60 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
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 |
---|---|---|
@@ -1,47 +1,10 @@ | ||
import wollok.game.* | ||
import comida.* | ||
import homero.* | ||
import niveles.* | ||
import tableros.* | ||
|
||
program homeroGame{ | ||
game.title("Homero en Springfield") | ||
game.height(12) | ||
game.width(18) | ||
game.cellSize(100) | ||
|
||
game.boardGround("springfield.png") | ||
game.addVisual(puntosHomero) | ||
game.addVisual(homero) | ||
game.addVisual(rosquilla) | ||
game.addVisual(banana) | ||
game.addVisual(plutonio) | ||
game.addVisual(choripan) | ||
game.addVisual(mate) | ||
game.addVisual(te) | ||
game.addVisual(ensalada) | ||
game.addVisual(guiso) | ||
|
||
|
||
game.onTick(500, "baja", {rosquilla.bajar()}) | ||
game.onTick(500, "baja", {banana.bajar()}) | ||
game.onTick(500, "baja", {plutonio.bajar()}) | ||
game.onTick(500, "baja", {cerveza.bajar()}) | ||
game.onTick(500, "baja", {choripan.bajar()}) | ||
game.onTick(500, "baja", {mate.bajar()}) | ||
game.onTick(500, "baja", {te.bajar()}) | ||
game.onTick(500, "baja", {ensalada.bajar()}) | ||
game.onTick(500, "baja", {guiso.bajar()}) | ||
|
||
|
||
keyboard.a().onPressDo({homero.moverseIzquierda()}) | ||
keyboard.d().onPressDo({homero.moverseDerecha()}) | ||
|
||
keyboard.space().onPressDo{ | ||
const colliders = game.colliders(homero) | ||
colliders.head().interactua(homero) | ||
homero.alterarPuntos(colliders.head().puntos()) | ||
homero.alterarVelocidad(colliders.head().velocidad()) | ||
game.removeVisual(colliders.head()) | ||
} | ||
|
||
game.start() | ||
nivel1.inciarFondo() | ||
keyboard.space().onPressDo{nivel1.iniciarNivel()} | ||
} |
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,69 @@ | ||
import homero.* | ||
import comida.* | ||
import tableros.* | ||
import wollok.game.* | ||
|
||
object nivel1 { | ||
method inciarFondo(){ | ||
game.title("Homero en Springfield") | ||
game.height(12) | ||
game.width(18) | ||
game.cellSize(100) | ||
|
||
game.boardGround("springfield.png") | ||
game.addVisual(puntosHomero) | ||
game.addVisual(mensajes) | ||
game.addVisual(homero) | ||
game.addVisual(tiempo) | ||
|
||
game.start() | ||
|
||
if(tiempo.timer() == 0 || homero.puntos() > 200){ | ||
game.addVisual(mensajeVictoria) | ||
game.stop() | ||
}else if (tiempo.timer() == 0){ | ||
game.addVisual(mensajeDerrota) | ||
game.stop() | ||
} | ||
} | ||
|
||
method iniciarNivel(){ | ||
game.removeVisual(mensajes) | ||
game.onTick(1000, "descontar tiempo", {tiempo.restarSegundo()}) | ||
game.onTick(1000, "tiempo en 0", {if(tiempo.timer() == 0) game.removeTickEvent("descontar tiempo")}) | ||
game.onTick(1000, "tiempo en 0", {if(tiempo.timer() == 0) game.removeTickEvent("baja")}) | ||
game.onTick(1000, "gano o no", {if(homero.puntos() > 200) game.addVisual(mensajeVictoria) else game.addVisual(mensajeDerrota)}) | ||
|
||
comidas.forEach({comida => game.addVisual(comida)}) | ||
|
||
game.onTick(500, "baja", {rosquilla.bajar()}) | ||
game.onTick(1000, "baja", {banana.bajar()}) | ||
game.onTick(750, "baja", {plutonio.bajar()}) | ||
game.onTick(1250, "baja", {cerveza.bajar()}) | ||
game.onTick(250, "baja", {choripan.bajar()}) | ||
game.onTick(1500, "baja", {mate.bajar()}) | ||
game.onTick(1750, "baja", {te.bajar()}) | ||
game.onTick(2000, "baja", {ensalada.bajar()}) | ||
game.onTick(2250, "baja", {guiso.bajar()}) | ||
|
||
|
||
keyboard.a().onPressDo({homero.moverseIzquierda()}) | ||
keyboard.d().onPressDo({homero.moverseDerecha()}) | ||
|
||
keyboard.space().onPressDo{ | ||
const colliders = game.colliders(homero) | ||
colliders.head().interactua(homero) | ||
homero.alterarPuntos(colliders.head().puntos()) | ||
homero.alterarVelocidad(colliders.head().velocidad()) | ||
game.removeVisual(colliders.head()) | ||
} | ||
|
||
if(tiempo.timer() == 0 || homero.puntos() > 200){ | ||
game.removeTickEvent("descontar tiempo") | ||
game.removeTickEvent("baja") | ||
} | ||
|
||
} | ||
|
||
} | ||
|
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,49 @@ | ||
import homero.* | ||
object puntosHomero { | ||
const hom = homero | ||
const position = new MutablePosition(x=9, y=10) | ||
|
||
method position() = position | ||
|
||
method text () = "Puntos: " + hom.puntos() + " Velocidad: " + hom.velocidad() | ||
|
||
} | ||
|
||
object mensajes { | ||
const position = new MutablePosition(x=9, y=8) | ||
|
||
method position() = position | ||
|
||
method text() = "Bienvenido a Homero en Springfield, presione espacio para comenzar!" | ||
} | ||
|
||
object tiempo { | ||
var timer = 5 * 60 | ||
const position = new MutablePosition(x=9, y=9) | ||
|
||
method position() = position | ||
|
||
method text() = "Tiempo: " + timer | ||
|
||
method timer() = timer | ||
|
||
method restarSegundo(){ | ||
timer -= 1 | ||
} | ||
} | ||
|
||
object mensajeVictoria{ | ||
const position = new MutablePosition(x=9, y=8) | ||
|
||
method position() = position | ||
|
||
method text() = "Ganaste!" | ||
} | ||
|
||
object mensajeDerrota{ | ||
const position = new MutablePosition(x=9, y=8) | ||
|
||
method position() = position | ||
|
||
method text() = "Perdiste!" | ||
} |