- [NEW] aux_textfile()

- Implementant la càrrega del nivell
This commit is contained in:
2023-10-18 16:18:57 +02:00
parent 3f203fee62
commit fdc604be3c
4 changed files with 112 additions and 21 deletions

View File

@@ -1,6 +1,6 @@
#include "proc_mapa.h"
#include "jgame.h"
#include <stdio.h>
#include "aux_textfile.h"
namespace mapa
{
@@ -38,30 +38,30 @@ namespace mapa
void carregar()
{
FILE *f = file::getFilePointer("mapes.txt");
textfile::open("mapes.txt");
//const int fase = game::getConfig("fase");
int val;
do {
fscanf(f, "LEVEL %i", &val);
} while (val != game::getConfig("fase"));
textfile::searchToken("LEVEL");
} while (std::stoi(textfile::getNextToken()) != game::getConfig("fase"));
int tileset=0;
fscanf(f, "tileset = %i", &tileset);
fscanf(f, "orientacio = %i", &arounders::orientacio_inicial);
fscanf(f, "arounders = %i", &arounders::totals);
fscanf(f, "necessaris = %i", &arounders::necessaris);
const int tileset = textfile::getIntValue("tileset");
arounders::orientacio_inicial = textfile::getIntValue("orientacio");
arounders::totals = textfile::getIntValue("arounders");
arounders::necessaris = textfile::getIntValue("necessaris");
fscanf(f, "parar = %i", &accions::parar);
fscanf(f, "cavar = %i", &accions::cavar);
fscanf(f, "escalar = %i", &accions::escalar);
fscanf(f, "perforar = %i", &accions::perforar);
fscanf(f, "escalera = %i", &accions::escalera);
fscanf(f, "pasarela = %i", &accions::pasarela);
fscanf(f, "corda = %i", &accions::corda);
accions::parar = textfile::getIntValue("parar");
accions::cavar = textfile::getIntValue("cavar");
accions::escalar = textfile::getIntValue("escalar");
accions::perforar = textfile::getIntValue("perforar");
accions::escalera = textfile::getIntValue("escalera");
accions::pasarela = textfile::getIntValue("pasarela");
accions::corda = textfile::getIntValue("corda");
fscanf(f, "inici = %i %i", &ini_x, &ini_y);
fscanf(f, "final = %i %i", &fin_x, &fin_y);
ini_x = textfile::getIntValue("inici");
ini_y = std::stoi(textfile::getNextToken());
fin_x = textfile::getIntValue("final");
fin_y = std::stoi(textfile::getNextToken());
//int tilemap[200];
//for (int y=0; y<10; ++y) for (int x=0; x<10; ++x) fscanf(f, "%i", &tilemap[x+y*20]);
@@ -82,7 +82,7 @@ namespace mapa
draw::freeSurface(tiles);
fclose(f);
textfile::fclose();
draw::surface *marcador = draw::loadSurface("marcador.gif");
draw::setSource(marcador);