diff --git a/source/proc_mapa.cpp b/source/proc_mapa.cpp new file mode 100644 index 0000000..0255dd9 --- /dev/null +++ b/source/proc_mapa.cpp @@ -0,0 +1,103 @@ +#include "proc_mapa.h" +#include "jgame.h" +#include + +namespace mapa +{ + namespace arounders + { + int orientacio_inicial {0}; + int totals {0}; + int necessaris {0}; + + int arrivats {0}; + int eixits {0}; + int morts {0}; + } + + namespace accions + { + int parar {0}; + int cavar {0}; + int escalar {0}; + int perforar {0}; + int escalera {0}; + int pasarela {0}; + int corda {0}; + } + + int ini_x, ini_y; + int fin_x, fin_y; + int velocitat; + + draw::surface *mapa = nullptr; + + //SDL_Surface *boto; + + int contador; + + void carregar() + { + FILE *f = file::getFilePointer("mapes.txt"); + + //const int fase = game::getConfig("fase"); + int val; + do { + fscanf(f, "LEVEL %i", &val); + } while (val != 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); + + 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); + + fscanf(f, "inici = %i %i", &ini_x, &ini_y); + fscanf(f, "final = %i %i", &fin_x, &fin_y); + + //int tilemap[200]; + //for (int y=0; y<10; ++y) for (int x=0; x<10; ++x) fscanf(f, "%i", &tilemap[x+y*20]); + + draw::surface *tiles = draw::loadSurface("tiles.gif"); + draw::setSource(tiles); + + if (mapa) draw::freeSurface(mapa); + mapa = draw::createSurface(320, 200); + draw::setDestination(mapa); + + for (int y=0; y<10; ++y) + for (int x=0; x<10; ++x) + { + int tile; fscanf(f, "%i", &tile); + if (tile > 0) draw::draw(x*16, y*16, 16, 16, (tile-1)*16, tileset*16); + } + + draw::freeSurface(tiles); + + fclose(f); + + draw::surface *marcador = draw::loadSurface("marcador.gif"); + draw::setSource(marcador); + draw::draw(0, 165, marcador->w, marcador->h, 0, 0); + draw::freeSurface(marcador); + + + } + + char *formatejar(int numero); + + void pintar(int accio, int prevista); + int procesar(int mousex, int mousey); + + void setAroundersNum(const int orient, const int total, const int necessaris); + void setActions(const int parar, const int cavar, const int escalar, const int perforar, const int escalera, const int pasarela, const int corda); + +} \ No newline at end of file diff --git a/source/proc_mapa.h b/source/proc_mapa.h new file mode 100644 index 0000000..341aa5e --- /dev/null +++ b/source/proc_mapa.h @@ -0,0 +1,35 @@ +#pragma once + +namespace mapa +{ + namespace arounders + { + extern int orientacio_inicial; + extern int totals; + extern int necessaris; + + extern int arrivats; + extern int eixits; + extern int morts; + } + + namespace accions + { + extern int parar; + extern int cavar; + extern int escalar; + extern int perforar; + extern int escalera; + extern int pasarela; + extern int corda; + } + + void carregar(); + + void pintar(int accio, int prevista); + int procesar(int mousex, int mousey); + + void setAroundersNum(const int orient, const int total, const int necessaris); + void setActions(const int parar, const int cavar, const int escalar, const int perforar, const int escalera, const int pasarela, const int corda); + +} \ No newline at end of file diff --git a/source/proc_marcador.cpp b/source/proc_marcador.cpp deleted file mode 100644 index c391bcf..0000000 --- a/source/proc_marcador.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "proc_marcador.h" - -namespace marcador -{ - int orientacioInicial; - int numArounders; - int AroundersNec; - - int numAroundersArrivats; - int numAroundersEixits; - int numAroundersMorts; - - int numParar; - int numCavar; - int numEscalar; - int numPerforar; - int numEscalera; - int numPasarela; - int numCorda; - - int velocitat; - - - //SDL_Surface *boto; - - int contador; - - char *formatejar(int numero); - - void pintar(int accio, int prevista); - int procesar(int mousex, int mousey); - - void setAroundersNum(const int orient, const int total, const int necessaris); - void setActions(const int parar, const int cavar, const int escalar, const int perforar, const int escalera, const int pasarela, const int corda); - -} \ No newline at end of file diff --git a/source/proc_marcador.h b/source/proc_marcador.h deleted file mode 100644 index 0b15b3b..0000000 --- a/source/proc_marcador.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -namespace marcador -{ - void pintar(int accio, int prevista); - int procesar(int mousex, int mousey); - - void setAroundersNum(const int orient, const int total, const int necessaris); - void setActions(const int parar, const int cavar, const int escalar, const int perforar, const int escalera, const int pasarela, const int corda); - -} \ No newline at end of file