From 13e0e89aa84fe24e03114a5387132bdb1605c011 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Thu, 16 Oct 2025 22:42:10 +0200 Subject: [PATCH] =?UTF-8?q?-=20[NEW]=20L'explosi=C3=B3=20puja=20m=C3=A9s?= =?UTF-8?q?=20alta,=20que=20ara=20tots=20els=20pixels=20anaven=20cap=20ava?= =?UTF-8?q?ll=20-=20[NEW]=20Comentaris=20i=20pijades=20en=20el=20modul=20p?= =?UTF-8?q?lay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/entities/explosio.cpp | 2 +- source/gamestates/play.cpp | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/source/entities/explosio.cpp b/source/entities/explosio.cpp index 901ea99..ee667b7 100644 --- a/source/entities/explosio.cpp +++ b/source/entities/explosio.cpp @@ -34,7 +34,7 @@ namespace explosio exp[numexp].pix[i].x = x; exp[numexp].pix[i].y = y; exp[numexp].pix[i].xa = float((rand()%expansio) - (expansio >> 1))/1000.0f; - exp[numexp].pix[i].ya = float((rand()%expansio) - (expansio >> 1))/1000.0f; + exp[numexp].pix[i].ya = -float((rand()%expansio))/1000.0f; exp[numexp].pix[i].g = 0.05; exp[numexp].pix[i].c = rand()%60; } diff --git a/source/gamestates/play.cpp b/source/gamestates/play.cpp index dffa6c1..75e9ccc 100644 --- a/source/gamestates/play.cpp +++ b/source/gamestates/play.cpp @@ -31,7 +31,7 @@ namespace gamestate int aigua_frame1 = 0; int aigua_frame2 = 5; - int exit = 0; + int exit = play::eixir::no; bool loop(); @@ -182,68 +182,92 @@ namespace gamestate arounders::abortarAccio(); } + // Si pulsem el botó de l'esquerra... pos es més complicat! Anem pas per pas... if (input::mouseClk(input::mouse::button::left)) { + // Si al pulsar no havem seleccionat cap arounder (o siga, no havem fet click sobre un arounder)... if (!arounders::seleccionar()) { + // Si no havem pulsat en la zona de baix dels botons, i hi ha un arounder seleccionat, i està caminant... if (input::mouseY()<165 && arounders::seleccionat != nullptr && arounders::seleccionat->accio == arounders::accions::caminar) { + // Fem que camine en la direcció en que està el cursor arounders::seleccionat->orientacio = input::mouseX() > arounders::seleccionat->x ? arounders::orientacions::dreta : arounders::orientacions::esquerra; } } - + + // Mirem si havem pulsat un botó... (si el botó està a 0, no conta com a pulsat) const int botoPulsat = mapa::procesar(); + // Si havem pulsat un botó i tenim un arounder seleccionat... if (botoPulsat != -1 && arounders::seleccionat != nullptr) { + // Si el botó pulsat se correspon en la accio encolada if (botoPulsat == arounders::seleccionat->prevista) { + // La desencolem arounders::seleccionat->prevista = arounders::seleccionat->accio; } else { + // Pero si no, la encolem (atenció, moltes accions comencen instantàneament) arounders::seleccionat->prevista = botoPulsat; } } } + // Si ha passat el temps suficient, actualitzem els arounders (i les ones) + // Açò pot ser mes tard o mes prompte depenent de si havem accelerat el temps currentTicks = game::getTicks() - startTicks; if( currentTicks >= mapa::velocitat ) { startTicks = game::getTicks(); aigua_frame1 = (aigua_frame1+1)%10; aigua_frame2 = (aigua_frame2+1)%10; + // Ací passa quasi tot lo interessant!!! No t'ho perdes!! arounders::procesar(); } + // Si ha passat el temps suficient... + // (també depen de si havem pulsat el botó de passar rapid el temps) if ( (game::getTicks() - arounderCount) >= mapa::velocitat*58) { + // I encara queden arounders per eixir... if (mapa::arounders::eixits < mapa::arounders::totals) { + // Traguem un nou arounder per la porta arounders::afegir(); mapa::arounders::eixits++; arounderCount = game::getTicks(); } } + // Si tots els arounders ja han arribat o han mort... if (mapa::arounders::arrivats + mapa::arounders::morts == mapa::arounders::totals) { + // Si han arribat els necessaris... if (mapa::arounders::arrivats >= mapa::arounders::necessaris) { + // Pujem el numero de fase en el config i anem a la postfase game::setConfig("fase", game::getConfig("fase")+1); draw::fadeout(); audio::fadeOutMusic(); - play::exit = 1; + play::exit = play::eixir::postfase; } else { + // Sino, anem a la pantalla de mort draw::fadeout(); audio::fadeOutMusic(); - play::exit = 2; + play::exit = play::eixir::mort; } } return true; } + // Mentres estem en pausa, este es el bucle principal bool loop_pause() { + // Consisteix en pintar la surface sobre la que havem pintat la foto del que hi havia en pantalla draw::draw(faded); + // ...I el cursor... draw::setSource(cursor); draw::draw(input::mouseX(), input::mouseY()); draw::render(); + // I mirem si s'ha polsat P o ESC, per a tornat al bucle principal del mòdul de joc if (input::keyPressed(SDL_SCANCODE_P) || input::keyPressed(SDL_SCANCODE_ESCAPE)) { play::backToLoop(); @@ -251,10 +275,14 @@ namespace gamestate return true; } + // Mentres estem en el menú, este es el bucle principal bool loop_menu() { + // Si havem triat eixir... if (play::exit) { + // esperem a que acabe el fade... if (!draw::isfading()) { + // I quan acabe play::finalize(); if (exit==1) { mapa::carregar();