From c5499bf549f2bc832a9996b2c34c117b6eae25f2 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Wed, 18 Oct 2023 19:00:56 +0200 Subject: [PATCH] =?UTF-8?q?-=20Seguim=20amb=20l'implementaci=C3=B3=20del?= =?UTF-8?q?=20modul=20de=20mapa=20i=20el=20gamestate=5Fplay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/gamestate_play.cpp | 60 ++++++++++++++++++++++++++++----------- source/proc_mapa.cpp | 58 +++++++++++++++++++++++++++++++++---- 2 files changed, 96 insertions(+), 22 deletions(-) diff --git a/source/gamestate_play.cpp b/source/gamestate_play.cpp index ba38f50..67355de 100644 --- a/source/gamestate_play.cpp +++ b/source/gamestate_play.cpp @@ -1,6 +1,8 @@ #include "gamestates.h" #include "jgame.h" #include +#include "aux_font.h" +#include "proc_mapa.h" namespace gamestate { @@ -9,13 +11,18 @@ namespace gamestate draw::surface *fondo = nullptr; draw::surface *mapa = nullptr; - void carregarMapa(); + uint32_t arounderCount; + uint32_t startTicks; + + bool loop(); + void draw(); void init() { + const int fase = game::getConfig("fase"); // Carregar el fondo que toque i la seua paleta (que nomes usa els colors del 128 al 255) char arxiuFondo[10] = "BKG00.GIF"; - arxiuFondo[4] = (game::getConfig("fase") % 10) + 48; + arxiuFondo[4] = (fase % 10) + 48; fondo = draw::loadSurface(arxiuFondo, true); // Carregar la paleta estandar @@ -23,32 +30,51 @@ namespace gamestate draw::setPalette(pal, 128); // [TODO] Carreagar la resta de gifs que facen falta - //font1 = drawManager->LoadFont("fuente1.gif"); //cursor = drawManager->LoadFont("cursor.gif"); - //puerta = drawManager->LoadFont("puerta.gif"); - //marca = drawManager->LoadFont("marca.gif"); //menu = drawManager->LoadFont("menu.gif"); // [TODO] CREAR AIGUA PROCESSOR // [TODO] CREAR MARCADOR PROCESSOR - carregarMapa(); + // [TODO] Crear el primer Arounder + mapa::arounders::eixits++; + // arounder_seleccionat = primerArounders + + audio::loadMusic((fase+1) % 5 == 0 ? "mus6.ogg" : "mus4.mp3"); + audio::playMusic(); + + play::arounderCount = play::startTicks = game::getTicks(); + + draw::fadein(); + game::setState(gamestate::play::loop); } - void carregarMapa() + bool loop() { - FILE *f = file::getFilePointer("mapes.txt"); + play::draw(); + } - const int fase = game::getConfig("fase"); - int val; - do { - fscanf(f, "LEVEL %i", &val); - } while (val != fase); - - int tileset=0; - fscanf(f, "tileset = %i", &tileset); + void draw() + { + draw::setSource(play::fondo); + draw::draw(); - fclose(f); + int accio = -1; + int prevista = -1; + // [TODO] if (arounders::seleccionat) { accio = arounders::seleccionat->accio; prevista = arounders::seleccionat->prevista; } + // [QUESTION] Potser lo del seleccionat se deuria mirar dins de "mapa"? + mapa::pintar(0, 0); // [TODO] if (arounders::seleccionat) existeix, pillar la accio i la prevista de ell + + // [TODO] aigua::pintar(); + // [TODO] arounders::pintar(); + + // [TODO] de fet, pintar la marca en el modul "arounders" + /* + if (arounders::seleccionat) { + draw::setSource(marca); + draw::draw(arounderSeleccionat->X-3, arounderSeleccionat->Y-3); + } + */ } } } \ No newline at end of file diff --git a/source/proc_mapa.cpp b/source/proc_mapa.cpp index 48b96a8..fe462ba 100644 --- a/source/proc_mapa.cpp +++ b/source/proc_mapa.cpp @@ -1,7 +1,7 @@ #include "proc_mapa.h" #include "jgame.h" #include "aux_textfile.h" - +#include "aux_font.h" namespace mapa { namespace arounders @@ -31,8 +31,8 @@ namespace mapa int velocitat; draw::surface *mapa = nullptr; - - //SDL_Surface *boto; + draw::surface *porta = nullptr; + draw::surface *boto = nullptr; int contador; @@ -89,12 +89,60 @@ namespace mapa draw::draw(0, 165, marcador->w, marcador->h, 0, 0); draw::freeSurface(marcador); + font::selectFont(font::type::normal); + font::print(188,188, game::getConfig("fase")+1); + font::print(7,188, "XX"); + font::print(135,188, "XX"); + font::print(151,188, "XX"); + font::print(224,171, "ACTIUS"); + font::print(224,177, "TOTAL"); + font::print(224,183, "NECESSARIS"); + font::print(224,189, "ARRIVATS"); + draw::setDestination(nullptr); + + if (mapa::porta == nullptr) mapa::porta = draw::loadSurface("puerta.gif"); + if (mapa::boto == nullptr) mapa::boto = draw::loadSurface("boto.gif"); } - char *formatejar(int numero); + void pintar(int accio, int prevista) + { + draw::draw(mapa); + draw::setSource(porta); + draw::draw(ini_x*16, ini_y*16); + draw::draw(fin_x*16, fin_y*16); + + font::print(23,188, mapa::accions::parar); + font::print(39,188, mapa::accions::cavar); + font::print(55,188, mapa::accions::escalar); + font::print(71,188, mapa::accions::perforar); + font::print(87,188, mapa::accions::escalera); + font::print(103,188, mapa::accions::pasarela); + font::print(119,188, mapa::accions::corda); + + font::print(301,171, mapa::arounders::eixits-mapa::arounders::arrivats-mapa::arounders::morts); + font::print(301,177, mapa::arounders::totals); + font::print(301,183, mapa::arounders::necessaris); + font::print(301,189, mapa::arounders::arrivats); + + if (accio >= 10) accio = 0; + if (prevista >= 10) prevista = 0; + draw::setSource(boto); + draw::draw((accio*16)+5, 171); + + if (prevista != accio && prevista != 0) { + if ((game::getTicks()-contador) <= 200) { + draw::draw((prevista*16)+5, 171); + } else { + if ((game::getTicks()-contador) >= 400) contador = game::getTicks(); + } + } + + if (velocitat < 70) { + draw::draw((9*16)+5, 171); // Pintar el botó de accelerat com pulsat + } + } - void pintar(int accio, int prevista); int procesar(int mousex, int mousey); void setAroundersNum(const int orient, const int total, const int necessaris);