From aa6b79c9acbefc5577ca7de482d11a370e09dc6f Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Mon, 16 Oct 2023 18:58:27 +0200 Subject: [PATCH] - Treballant en gamestate_play --- .gitignore | 3 ++- source/gamestate_play.cpp | 45 +++++++++++++++++++++++++++++++++++- source/gamestate_prefase.cpp | 17 ++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 092a0bb..6d3641b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vscode/* *.exe arounders -arounders_debug \ No newline at end of file +arounders_debug +*.dll \ No newline at end of file diff --git a/source/gamestate_play.cpp b/source/gamestate_play.cpp index f7c96ee..ba38f50 100644 --- a/source/gamestate_play.cpp +++ b/source/gamestate_play.cpp @@ -6,6 +6,49 @@ namespace gamestate { namespace play { - + draw::surface *fondo = nullptr; + draw::surface *mapa = nullptr; + + void carregarMapa(); + + void init() + { + // 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; + fondo = draw::loadSurface(arxiuFondo, true); + + // Carregar la paleta estandar + uint32_t *pal = draw::loadPalette("tiles.gif"); + 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(); + } + + void carregarMapa() + { + FILE *f = file::getFilePointer("mapes.txt"); + + 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); + + fclose(f); + } } } \ No newline at end of file diff --git a/source/gamestate_prefase.cpp b/source/gamestate_prefase.cpp index 89608c1..958abe6 100644 --- a/source/gamestate_prefase.cpp +++ b/source/gamestate_prefase.cpp @@ -39,6 +39,8 @@ namespace gamestate bool loop() { + static bool salir = false; + const int x = input::mouseX(); const int y = input::mouseY(); @@ -63,6 +65,21 @@ namespace gamestate draw::render(); + if (draw::isfading()) return true; + + if (salir) + { + salir = false; + gamestate::play::init(); + return true; + } + + if (input::anyKeyPressed() || input::mouseBtn(1)) + { + draw::fadeout(); + salir = true; + return true; + } return true; }