From f9d2ac66e87f86e161db22967b0a1fe797782d0d Mon Sep 17 00:00:00 2001 From: JailDoctor Date: Thu, 19 Oct 2023 20:01:54 +0200 Subject: [PATCH] =?UTF-8?q?-=20Crec=20que=20ja=20est=C3=A0=20tot=20prepara?= =?UTF-8?q?t=20per=20a=20implementar...=20EL=20M=C3=92DUL=20"AROUNDERS"!!!?= =?UTF-8?q?!=20WOOOO!!!!!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/gamestate_play.cpp | 91 +++++++++++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 13 deletions(-) diff --git a/source/gamestate_play.cpp b/source/gamestate_play.cpp index 7bcdd69..db64a61 100644 --- a/source/gamestate_play.cpp +++ b/source/gamestate_play.cpp @@ -30,6 +30,8 @@ namespace gamestate bool loop_pause(); bool loop_menu(); + void backToLoop(); + void draw(); void draw_aigua(); @@ -54,7 +56,6 @@ namespace gamestate play::aigua = draw::loadSurface("aigua.gif"); play::faded = draw::createSurface(320, 200); - // [TODO] CREAR AIGUA PROCESSOR // [TODO] CREAR MARCADOR PROCESSOR // [TODO] Crear el primer Arounder @@ -72,10 +73,21 @@ namespace gamestate bool loop() { + if (play::exit) { + if (!draw::isfading()) { + play::finalize(); + if (exit==1) gamestate::postfase::init(); + // [TODO] if (exit==2) gamestate::mort::init(); + } + draw::render(); + return true; + } + play::draw(); - if (input::keyPressed(SDL_SCANCODE_P) || input::mouseClk(2) || !game::windowHasFocus) + if (input::keyPressed(SDL_SCANCODE_P) || input::mouseClk(input::mouse::button::middle) || !game::windowHasFocus) { + arounderCount = game::getTicks() - arounderCount; draw::setSource(nullptr); draw::setDestination(play::faded); draw::draw(); @@ -97,6 +109,7 @@ namespace gamestate if (input::keyPressed(SDL_SCANCODE_ESCAPE)) { + arounderCount = game::getTicks() - arounderCount; draw::setSource(nullptr); draw::setDestination(play::faded); draw::draw(); @@ -124,14 +137,64 @@ namespace gamestate draw::setSource(cursor); draw::draw(input::mouseX(), input::mouseY()); - draw::render(); + if (input::mouseClk(input::mouse::button::right)) + { + // [TODO] arounders::abortarAccio(); + } + + if (input::mouseClk(input::mouse::button::left)) + { + /* [TODO] + if (!arounders::seleccionar()) + { + if (input::mouseY()<165 && arounders::seleccionat != nullptr && arounders::seleccionat->accio == arounders::accions::caminar) + { + arounders::seleccionat->orientacio = input::mouseX() > arounders::seleccionat->x ? arounders::orientacions::dreta : arounders::orientacions::esquerra; + } + } + + const int botoPulsat = mapa::procesar(); + if (botoPulsat != -1 && arounders::seleccionat != nullptr) + { + if (botoPulsat == arounders::seleccionat->prevista) { + arounders::seleccionat->prevista = arounders::seleccionat->accio; + } else { + arounders::seleccionat->prevista = botoPulsat; + } + }*/ + } + currentTicks = game::getTicks() - startTicks; if( currentTicks >= mapa::velocitat ) { startTicks = game::getTicks(); aigua_frame1 = (aigua_frame1+1)%10; aigua_frame2 = (aigua_frame2+1)%10; + + // [TODO] arounders::update(); + } + + /* [TODO] + if ( (game::getTicks() - arounderCount) >= mapa::velocitat*58) { + if (mapa::arounders::eixits < mapa::arounders::totals) { + arounders::afegir(); + mapa::arounders::eixits++; + arounderCount = game::getTicks(); + } + }*/ + + if (mapa::arounders::arrivats + mapa::arounders::morts == mapa::arounders::totals) { + if (mapa::arounders::arrivats >= mapa::arounders::necessaris) { + game::setConfig("fase", game::getConfig("fase")+1); + draw::fadeout(); + audio::fadeoutMusic(); + play::exit = 1; + } else { + draw::fadeout(); + audio::fadeoutMusic(); + play::exit = 2; + } } return true; @@ -147,9 +210,7 @@ namespace gamestate if (input::keyPressed(SDL_SCANCODE_P) || input::keyPressed(SDL_SCANCODE_ESCAPE)) { - draw::setPalette(play::original_palette, 256); - free(play::original_palette); - game::setState(gamestate::play::loop); + play::backToLoop(); } return true; } @@ -174,18 +235,14 @@ namespace gamestate if (input::keyPressed(SDL_SCANCODE_ESCAPE)) { - draw::setPalette(play::original_palette, 256); - free(play::original_palette); - game::setState(gamestate::play::loop); + play::backToLoop(); } - if (input::mouseClk(1)) + if (input::mouseClk(input::mouse::button::left)) { if (input::mouseX() >= 97 && input::mouseX() <= 223) { if (input::mouseY() >= 60 && input::mouseY() <= 65) { - draw::setPalette(play::original_palette, 256); - free(play::original_palette); - game::setState(gamestate::play::loop); + play::backToLoop(); } if (input::mouseY() >= 71 && input::mouseY() <= 76) { free(play::original_palette); @@ -208,6 +265,14 @@ namespace gamestate return true; } + void backToLoop() + { + draw::setPalette(play::original_palette, 256); + free(play::original_palette); + game::setState(gamestate::play::loop); + arounderCount = game::getTicks() - arounderCount; + } + void draw() { draw::draw(play::fondo);