-
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
Showing
8 changed files
with
193 additions
and
113 deletions.
There are no files selected for viewing
Binary file not shown.
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
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,105 @@ | ||
import example.* | ||
|
||
object contador { | ||
var puntos = 0 | ||
const property celeste = "279df5cc" | ||
|
||
method position () = game.at(7, 11) | ||
|
||
method aumentarPuntos() { | ||
puntos += 10 | ||
} | ||
|
||
method text() = " Puntos: " + puntos | ||
method textColor() = celeste | ||
|
||
} | ||
|
||
object contadorNafta { | ||
var nafta = 100 | ||
|
||
method perderNafta() { | ||
if (nafta > 0){ | ||
nafta = nafta - 2 | ||
} else { | ||
game.stop() | ||
} | ||
|
||
} | ||
|
||
method agregarNafta(cantidad) { | ||
nafta = nafta + cantidad | ||
} | ||
|
||
const property celeste = "279df5cc" | ||
|
||
method position () = game.at(0, 0) | ||
|
||
method text() = " Nafta: " + nafta | ||
method textColor() = celeste | ||
|
||
} | ||
|
||
object manejadorAutos { | ||
const autos = new List() | ||
|
||
method agregarAutosFilaSuperior() { | ||
const nuevoAuto = new AutoEnemigo () | ||
autos.add(nuevoAuto) | ||
game.addVisual(nuevoAuto) | ||
} | ||
|
||
method paraCadaAuto() { | ||
autos.forEach{autoEnemigo => autoEnemigo.moverseHaciaAbajo()} | ||
} | ||
} | ||
|
||
object manejadorObstaculos { | ||
const obstaculos = new List() | ||
|
||
method agregarObstaculos() { | ||
const nuevoObstaculo = new Obstaculo () | ||
obstaculos.add(nuevoObstaculo) | ||
game.addVisual(nuevoObstaculo) | ||
} | ||
|
||
method paraCadaObstaculo() { | ||
obstaculos.forEach{obstaculo => obstaculo.moverseHaciaAbajo()} | ||
} | ||
} | ||
|
||
object manejadorColisiones { | ||
method iniciar(){ | ||
game.onTick(300, "moverAutos", { manejadorAutos.paraCadaAuto() }) | ||
game.onTick(300, "moverGasolina", { gasolina.moverseHaciaAbajo() }) | ||
game.onTick(300, "moverObstaculos", { manejadorObstaculos.paraCadaObstaculo() }) | ||
game.onTick(100, "contadores", { contador.aumentarPuntos() }) | ||
game.onTick(1000, "contadores", { contadorNafta.perderNafta() }) | ||
game.onCollideDo(auto, {visual => visual.chocar()}) | ||
} | ||
|
||
} | ||
|
||
/*object sonidoExplosion{ | ||
method play(){ | ||
game.sound("explosion.wav").play() | ||
} | ||
} | ||
object cartelFinal{ | ||
var position = game.center() | ||
method image() = "gameover.png" | ||
method text () = "GAME OVER" | ||
method iniciar(){ | ||
game.addVisual(self) | ||
sonidoExplosion.play() | ||
game.stop() | ||
} | ||
} | ||
program soundProgram { | ||
const rain = game.sound("light-rain.mp3") | ||
rain.shouldLoop(true) | ||
game.schedule(500, { rain.play()} ) | ||
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,15 +1,14 @@ | ||
import wollok.game.* | ||
import example.* | ||
import handlers.* | ||
import visuales.* | ||
|
||
|
||
program juego { | ||
juegoDeAutos.iniciar() | ||
cargarVisuales.iniciar() | ||
manejadorColisiones.iniciar() | ||
juegoDeAutos.configurarTeclado() | ||
game.start() | ||
|
||
game.onTick(300, "moverAutos", { manejadorAutos.paraCadaAuto() }) | ||
game.onTick(300, "moverGasolina", { gasolina.moverseHaciaAbajo() }) | ||
game.onTick(300, "moverObstaculos", { manejadorObstaculos.paraCadaObstaculo() }) | ||
game.onTick(100, "contadores", { contador.aumentarPuntos() }) | ||
game.onTick(1000, "contadores", { contadorNafta.perderNafta() }) | ||
game.onTick(1000, "verificarNafta", {if (contadorNafta.nafta <= 0) game.stop()}) | ||
} |
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,9 +1,26 @@ | ||
/*import pepita.* | ||
/*import example.* | ||
import handlers.* | ||
|
||
describe "group of tests for pepita" { | ||
describe "group of tests for auto" { | ||
|
||
test "pepita has initial energy" { | ||
assert.equals(100, pepita.energy()) | ||
test "auto has nafta" { | ||
assert.equals(100, contadorNafta.nafta) | ||
} | ||
|
||
}*/ | ||
test "auto pierde nafta " { | ||
|
||
} | ||
|
||
test "auto choca " { | ||
|
||
} | ||
|
||
test "posicion inicial auto" { | ||
auto.position() shouldBe game.at(1, 2) | ||
auto.moverDerecha() | ||
auto.position() shouldBe game.at(2, 2) | ||
} | ||
|
||
} | ||
|
||
*/ |
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,45 @@ | ||
import example.* | ||
import wollok.game.* | ||
import handlers.* | ||
|
||
object cargarVisuales { | ||
method iniciar() { | ||
game.addVisualCharacter(auto) | ||
game.addVisual(contador) | ||
game.addVisual(contadorNafta) | ||
|
||
game.schedule(300, {manejadorAutos.agregarAutosFilaSuperior() | ||
manejadorAutos.agregarAutosFilaSuperior() | ||
manejadorAutos.agregarAutosFilaSuperior() | ||
manejadorAutos.agregarAutosFilaSuperior() | ||
}) | ||
|
||
game.schedule(1200, {manejadorAutos.agregarAutosFilaSuperior() | ||
manejadorAutos.agregarAutosFilaSuperior() | ||
manejadorAutos.agregarAutosFilaSuperior() | ||
manejadorAutos.agregarAutosFilaSuperior() | ||
}) | ||
|
||
game.schedule(2100, {manejadorAutos.agregarAutosFilaSuperior() | ||
manejadorAutos.agregarAutosFilaSuperior() | ||
manejadorAutos.agregarAutosFilaSuperior() | ||
manejadorAutos.agregarAutosFilaSuperior() | ||
}) | ||
|
||
game.schedule(3000, {manejadorAutos.agregarAutosFilaSuperior() | ||
manejadorAutos.agregarAutosFilaSuperior() | ||
manejadorAutos.agregarAutosFilaSuperior() | ||
manejadorAutos.agregarAutosFilaSuperior() | ||
}) | ||
|
||
game.schedule(3300, {game.addVisual(gasolina)}) | ||
|
||
game.schedule(1500, {manejadorObstaculos.agregarObstaculos() | ||
manejadorObstaculos.agregarObstaculos() | ||
}) | ||
|
||
game.schedule(3300, {manejadorObstaculos.agregarObstaculos() | ||
manejadorObstaculos.agregarObstaculos() | ||
}) | ||
} | ||
} |