103 lines
2.5 KiB
C++
103 lines
2.5 KiB
C++
#include "proc_mapa.h"
|
|
#include "jgame.h"
|
|
#include "aux_textfile.h"
|
|
|
|
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()
|
|
{
|
|
textfile::open("mapes.txt");
|
|
|
|
do {
|
|
textfile::searchToken("LEVEL");
|
|
} while (std::stoi(textfile::getNextToken()) != game::getConfig("fase"));
|
|
|
|
const int tileset = textfile::getIntValue("tileset");
|
|
arounders::orientacio_inicial = textfile::getIntValue("orientacio");
|
|
arounders::totals = textfile::getIntValue("arounders");
|
|
arounders::necessaris = textfile::getIntValue("necessaris");
|
|
|
|
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");
|
|
|
|
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]);
|
|
|
|
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);
|
|
|
|
textfile::fclose();
|
|
|
|
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);
|
|
|
|
} |