From 781aa8c639a8a92fff78d751d8dd0208ec771141 Mon Sep 17 00:00:00 2001 From: elin-winter Date: Thu, 10 Oct 2024 12:57:34 -0300 Subject: [PATCH] Logica de niveles a la mitad --- assets/f_door.png | Bin 0 -> 5820 bytes assets/w_door.png | Bin 0 -> 5751 bytes characters.wlk | 4 +- config.wlk | 93 +++++++++++++++++++++++++++++----- elements.wlk | 33 ++++++++++++ main.wpgm | 124 ++-------------------------------------------- 6 files changed, 119 insertions(+), 135 deletions(-) create mode 100644 assets/f_door.png create mode 100644 assets/w_door.png diff --git a/assets/f_door.png b/assets/f_door.png new file mode 100644 index 0000000000000000000000000000000000000000..50176835dd3ab3f48d21c59274a55b0b9c7b18bc GIT binary patch literal 5820 zcmbtY`9IVT(BECwO?J7rdd_v@o)>-6M6cxFO zSnJMFl#u((`FQ??=b6`Q=KY$PUuWh$Gmngo^f}oC*kCXiCl0G;dW_U#ea*sjY<;|a zBaQ*?W2&zUAL+z|A3Ln~u~t4X7(37ZDjb%P#Sep>w#Vt|m8H1kSzVgA zxZ@Nr?6oiO*GYIeD0`ScIDWDAy;q(8`!KO#w$|tqJP3825Pej8Cu{a8Qp}}%ZZR8ha02xk|ICKeC=O`JE9sKh|b`vD#P--pUt`X+ixmZ0GaW7-x$0dzohOo1uwbvb}o)BWSkL-OY|CZ9ta2z zw|%i3GOG!W={Wq{m8|p3_CJsowX!V223cLtHtix2?LJuN=r1=l`eB5&wfx6YMVWsW@~&R_&$&He z^uMC3;e@S4!|Mx|M8!s$+);ID_zR~Lp@B4cMh$MK+;A!QBX(ji@Ur}5U-ZLNjCCtm z)s@ERJ@@l72l{1*BJ?Vi)`ZU_f)k?y1B2jCasCcAEaFVQZE}u{mSG5$UHv~ zzbI0x2(5_=kcD_2{L>Z~dH43Tj6r{%tj+c2N(+m2g!&SECI(f(DW+mz`Uc*B9=_-~ zLRNr&l(_-F_+OUB%UHH9q{@G@$h=YhNAy4BYOw(=X{h*ZeuSr=1ybQSV9!-|5=+fh zWk(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T~aUQVz9TpJEg&5&f|-q@eaHh#@oDjp>FD)y=CwfT0P+P?0{6taeia z+H;!ni%%^1re>+dU zc^RmPDn}Jrs{seLY*^~JA=@qabWSYwb66|xbwHoRnEdHwsa`kf z8+kxKCswjXZx4c$>FLNwGNCI*dD>lj{`>1M+flc5Zmk73yO}_Ehr#DG3i5>4%DvF( zX(lW*74k{BT{@8;Aqb(AxjM;0!{XW{VBVrW(6ax;w^+}jBZc|T_J1s^VOT)LD1;H2 z*{ee-=$~vmYs9i$_S4|?taIidY2BZ}r)4pC#9g1SDoFt^!_`($74%DFKlO}Paknq@ zphQVWC=O#c?|D3JgU~ecQZN@BCd*}PtF>7bI zhw8n(T3f%mbQqb#x%8=0=W$KHJ`?EW5ys9)9{vjp; lVXw_K_}@%beaZcc&Ri#bIIi!`U-KBEc~@7hSj9T*{{VOwoJs%y literal 0 HcmV?d00001 diff --git a/characters.wlk b/characters.wlk index 12022ed..78f45a2 100644 --- a/characters.wlk +++ b/characters.wlk @@ -64,7 +64,7 @@ class Fireboy inherits Character { override method tipo() = fuego override method image() { - return "fireboy.png" + return "Fireboy.png" } } @@ -73,7 +73,7 @@ class Watergirl inherits Character { override method tipo() = agua override method image() { - return "watergirl.png" + return "Watergirl.png" } } diff --git a/config.wlk b/config.wlk index 9b0f224..3e60ddd 100644 --- a/config.wlk +++ b/config.wlk @@ -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) } + } +} diff --git a/elements.wlk b/elements.wlk index a868ade..e1eb7b1 100644 --- a/elements.wlk +++ b/elements.wlk @@ -59,6 +59,39 @@ class DiamanteVerde inherits Diamante { } */ + + +// ------------------- Puerta + +class Puerta { + const posX + const posY + const image + const tipo + + method position() = game.at(posX, posY) + + method esAtravesable() = true + + method image() = image + + method tipo() = tipo + + method colision() { + + /* + game.showMessage("¡Nivel completado! Pasando al siguiente nivel...") + game.wait(2) // Esperar 2 segundos antes de pasar al siguiente nivel + + */ + } +} + + + + + + /* // ------------------ Obstaculos diff --git a/main.wpgm b/main.wpgm index 39dc34d..e77c276 100644 --- a/main.wpgm +++ b/main.wpgm @@ -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) - } - } -} - - - */ } \ No newline at end of file