-
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
elin-winter
committed
Oct 10, 2024
1 parent
b846e21
commit 781aa8c
Showing
6 changed files
with
119 additions
and
135 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.
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,19 +1,88 @@ | ||
import invisible_objects.* | ||
import characters.* | ||
import elements.* | ||
|
||
object settings { | ||
method init (){ | ||
game.title("FireBoyWaterGirlGame") | ||
game.boardGround("nivel_1.png") | ||
game.height(29) | ||
game.width(39) | ||
game.cellSize(36) // 1404x1044 / 39x29 = 36px | ||
} | ||
|
||
method init (background, height, width, cellSize){ | ||
game.title("FireBoyWaterGirlGame") | ||
game.boardGround(background) | ||
game.height(height) | ||
game.width(width) | ||
game.cellSize(cellSize) // 1404x1044 // 39x29 = 36px | ||
} | ||
method generarMarco(){ | ||
(0..38).forEach { x => game.addVisual(new Border(posX = x, posY = 0))} | ||
(0..38).forEach { x => game.addVisual(new Border(posX = x, posY = 28))} | ||
(0..28).forEach{ y => game.addVisual(new Border(posX = 0, posY = y))} | ||
(0..28).forEach{ y => game.addVisual(new Border(posX = 38, posY = y))} | ||
(0..38).forEach { x => game.addVisual(new Border(posX = x, posY = 0))} | ||
(0..38).forEach { x => game.addVisual(new Border(posX = x, posY = 28))} | ||
(0..28).forEach{ y => game.addVisual(new Border(posX = 0, posY = y))} | ||
(0..28).forEach{ y => game.addVisual(new Border(posX = 38, posY = y))} | ||
} | ||
} | ||
|
||
class Level { | ||
|
||
// ---------------- REFERENCIAS | ||
const fireboy = new Fireboy(positionX = 3, positionY = 1) | ||
const watergirl = new Watergirl(positionX = 1, positionY = 1) | ||
const puertaFireboy = new Puerta(posX = 30, posY = 22, image = "f_door.png", tipo = fuego) | ||
const puertaWatergirl = new Puerta(posX = 34, posY = 22, image = "w_door.png", tipo = agua) | ||
const diamantes = [] | ||
|
||
// ---------------- JUEGO PRINCIPAL | ||
|
||
method start(nroNivel) { | ||
self.setupCharacters() | ||
self.setupControls() | ||
self.setupCollisions() | ||
self.setupDoors() | ||
self.setupDiamonds(nroNivel) | ||
|
||
game.start() | ||
} | ||
method setupCharacters() { | ||
game.addVisual(fireboy) | ||
game.addVisual(watergirl) | ||
} | ||
|
||
method setupControls() { | ||
// Controles para Watergirl | ||
keyboard.a().onPressDo({ watergirl.moveLeft() }) | ||
keyboard.d().onPressDo({ watergirl.moveRight() }) | ||
keyboard.w().onPressDo({ watergirl.jump() }) | ||
|
||
// Controles para Fireboy | ||
keyboard.left().onPressDo({ fireboy.moveLeft() }) | ||
keyboard.right().onPressDo({ fireboy.moveRight() }) | ||
keyboard.up().onPressDo({ fireboy.jump() }) | ||
} | ||
method setupCollisions() { | ||
game.onCollideDo(fireboy, {element => element.colision(fireboy)}) | ||
game.onCollideDo(watergirl, {element => element.colision(watergirl)}) | ||
} | ||
|
||
method setupDoors() { | ||
game.addVisual(puertaFireboy) | ||
game.addVisual(puertaWatergirl) | ||
} | ||
method setupDiamonds(nroNivel) { | ||
|
||
diamantes.clear() | ||
|
||
if (nroNivel == 1) { | ||
diamantes.add(new DiamanteRojo(posX = 28, posY = 3)) | ||
diamantes.add(new DiamanteRojo(posX = 9, posY = 14)) | ||
diamantes.add(new DiamanteRojo(posX = 10, posY = 25)) | ||
diamantes.add(new DiamanteRojo(posX = 22, posY = 23)) | ||
diamantes.add(new DiamanteAzul(posX = 24, posY = 13)) | ||
diamantes.add(new DiamanteAzul(posX = 20, posY = 3)) | ||
diamantes.add(new DiamanteAzul(posX = 4, posY = 22)) | ||
diamantes.add(new DiamanteAzul(posX = 18, posY = 23)) | ||
} else if (nroNivel == 2) { | ||
diamantes.add(new DiamanteRojo(posX = 28, posY = 3)) | ||
// agregar mas, lo puse solo para que no saltara error | ||
|
||
} | ||
|
||
diamantes.forEach { diamante => game.addVisual(diamante) } | ||
} | ||
} | ||
|
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,132 +1,14 @@ | ||
import wollok.game.* | ||
import characters.* | ||
import elements.* | ||
import invisible_objects.* | ||
import config.* | ||
|
||
program FireBoyWaterGirlGame { | ||
|
||
// Juego | ||
|
||
settings.init() | ||
settings.init("nivel_1.png", 29, 39, 36) | ||
settings.generarMarco() | ||
|
||
// Personajes | ||
|
||
const fireboy = new Fireboy(positionX = 3, positionY = 1) | ||
const watergirl = new Watergirl(positionX = 1, positionY = 1) | ||
|
||
game.addVisual(fireboy) | ||
game.addVisual(watergirl) | ||
|
||
// Diamantes | ||
|
||
const diamantes = [ | ||
new DiamanteRojo(posX = 28, posY = 3), | ||
new DiamanteRojo(posX = 9, posY = 14), | ||
new DiamanteRojo(posX = 10, posY = 25), | ||
new DiamanteRojo(posX = 22, posY = 23), | ||
new DiamanteAzul(posX = 24, posY = 13), | ||
new DiamanteAzul(posX = 20, posY = 3), | ||
new DiamanteAzul(posX = 4, posY = 22), | ||
new DiamanteAzul(posX = 18, posY = 23) | ||
] | ||
|
||
// Agregar todos los diamantes al juego | ||
diamantes.forEach {diamante => game.addVisual(diamante)} | ||
|
||
// Movimientos | ||
|
||
keyboard.a().onPressDo({ watergirl.moveLeft()}) | ||
keyboard.d().onPressDo({ watergirl.moveRight() }) | ||
keyboard.w().onPressDo({ watergirl.jump() }) | ||
|
||
keyboard.left().onPressDo({ fireboy.moveLeft() }) | ||
keyboard.right().onPressDo({ fireboy.moveRight() }) | ||
keyboard.up().onPressDo({ fireboy.jump() }) | ||
|
||
// Manejar Colisiones () | ||
|
||
game.onCollideDo(fireboy, {element => element.colision(fireboy)}) | ||
game.onCollideDo(watergirl, {element => element.colision(watergirl)}) | ||
|
||
game.start() | ||
|
||
|
||
|
||
/* | ||
|
||
//////////////////// ELI, NO TOCAR | ||
|
||
// Inicializar Juego | ||
|
||
settings.init() | ||
settings.generarMarco() | ||
|
||
// Empezar con nivel 1 | ||
|
||
const nivel1 = new Level() | ||
nivel1.start("nivel_1.png", 1) | ||
|
||
|
||
//////////////////// | ||
|
||
class Level { | ||
const fireboy = new Fireboy(positionX = 3, positionY = 1) | ||
const watergirl = new Watergirl(positionX = 1, positionY = 1) | ||
const diamantes = [] | ||
|
||
method start(background, nroNivel) { | ||
game.clear() | ||
game.boardGround(backgroundImage) | ||
nivel1.start(1) | ||
|
||
setupCharacters() | ||
setupDiamonds(nroNivel) | ||
setupControls() | ||
setupCollisions() | ||
// FALTA PONER QUE HACER CUANDO TERMINA EL NIVEL, POR EJ PASAR AL | ||
|
||
game.start() | ||
} | ||
|
||
method setupCharacters() { | ||
game.addVisual(fireboy) | ||
game.addVisual(watergirl) | ||
} | ||
|
||
method setupControls() { | ||
// Controles para Watergirl | ||
keyboard.a().onPressDo({ watergirl.moveLeft() }) | ||
keyboard.d().onPressDo({ watergirl.moveRight() }) | ||
keyboard.w().onPressDo({ watergirl.jump() }) | ||
|
||
// Controles para Fireboy | ||
keyboard.left().onPressDo({ fireboy.moveLeft() }) | ||
keyboard.right().onPressDo({ fireboy.moveRight() }) | ||
keyboard.up().onPressDo({ fireboy.jump() }) | ||
} | ||
|
||
method setupCollisions(onComplete) { | ||
game.onCollideDo(fireboy, { element => colision(fireboy, element) }) | ||
game.onCollideDo(watergirl, { element => colision(watergirl, element) }) | ||
} | ||
|
||
method setupDiamonds(nroNivel) { | ||
|
||
if(nroNivel == 1) | ||
const diamantes = [ | ||
new DiamanteRojo(posX = 28, posY = 3), | ||
new DiamanteRojo(posX = 9, posY = 14), | ||
new DiamanteAzul(posX = 24, posY = 13) | ||
] | ||
else if(nroNivel == 2) | ||
// conf diamantes nivel 2 | ||
|
||
diamantes.forEach { diamante => | ||
game.addVisual(diamante) | ||
} | ||
} | ||
} | ||
|
||
|
||
*/ | ||
} |