Compare commits
3 Commits
11d3309c82
...
8918c25b4e
| Author | SHA1 | Date | |
|---|---|---|---|
| 8918c25b4e | |||
| bcd38a5a06 | |||
| c1bbcace85 |
59
source/aux_font.cpp
Normal file
59
source/aux_font.cpp
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
#include "aux_font.h"
|
||||||
|
#include "jgame.h"
|
||||||
|
|
||||||
|
namespace font
|
||||||
|
{
|
||||||
|
static draw::surface *font1 = nullptr;
|
||||||
|
static draw::surface *font2 = nullptr;
|
||||||
|
static int mode = font::type::normal;
|
||||||
|
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
font::font1 = draw::loadSurface("fuente1.gif");
|
||||||
|
font::font2 = draw::loadSurface("fuente2.gif");
|
||||||
|
}
|
||||||
|
|
||||||
|
void selectFont(const int which)
|
||||||
|
{
|
||||||
|
font::mode = which;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setColor(const int color)
|
||||||
|
{
|
||||||
|
switch (color) {
|
||||||
|
case font::color::white: draw::setPaletteEntry(63, 255, 255, 255); break;
|
||||||
|
case font::color::red: draw::setPaletteEntry(63, 255, 0, 0); break;
|
||||||
|
case font::color::green: draw::setPaletteEntry(63, 0, 255, 0); break;
|
||||||
|
case font::color::blue: draw::setPaletteEntry(63, 0, 0, 255); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(const int x, const int y, const std::string text)
|
||||||
|
{
|
||||||
|
draw::setSource(font::mode == font::type::colored ? font::font2 : font::font1);
|
||||||
|
draw::setTrans(0);
|
||||||
|
|
||||||
|
if (font::mode == font::type::fade) for (int i=64;i<=67;++i) draw::swapcol(i, i+4);
|
||||||
|
|
||||||
|
const int len = text.length();
|
||||||
|
for (int i=0;i<len;++i)
|
||||||
|
{
|
||||||
|
char chr = text[i];
|
||||||
|
if (font::mode == font::type::colored)
|
||||||
|
draw::draw(x+i*7, y, 6, 6, (int(chr)-32)*7, 0);
|
||||||
|
else
|
||||||
|
draw::draw(x+i*7, y, 5, 5, (int(chr)-32)*7, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=64;i<=67;++i) draw::restorecol(i);
|
||||||
|
|
||||||
|
draw::setTrans(255);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(const int x, const int y, const int num)
|
||||||
|
{
|
||||||
|
const char txt[3] = { char(num/10 + 48), char(num%10 + 48), 0 };
|
||||||
|
print(x, y, txt);
|
||||||
|
}
|
||||||
|
}
|
||||||
28
source/aux_font.h
Normal file
28
source/aux_font.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace font
|
||||||
|
{
|
||||||
|
namespace type
|
||||||
|
{
|
||||||
|
const int normal = 0;
|
||||||
|
const int colored = 1;
|
||||||
|
const int fade = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace color
|
||||||
|
{
|
||||||
|
const int white = 0;
|
||||||
|
const int red = 1;
|
||||||
|
const int green = 2;
|
||||||
|
const int blue = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
void init();
|
||||||
|
void selectFont(const int which);
|
||||||
|
void setColor(const int color);
|
||||||
|
|
||||||
|
void print(const int x, const int y, const std::string text);
|
||||||
|
void print(const int x, const int y, const int num);
|
||||||
|
}
|
||||||
@@ -11,7 +11,6 @@ namespace gamestate
|
|||||||
|
|
||||||
bool loop();
|
bool loop();
|
||||||
|
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
exit = 0;
|
exit = 0;
|
||||||
@@ -22,8 +21,6 @@ namespace gamestate
|
|||||||
audio::playMusic(audio::loadMusic("mus3.ogg"));
|
audio::playMusic(audio::loadMusic("mus3.ogg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
draw::setSource(fondo);
|
|
||||||
draw::draw(0,0,320,200,0,0);
|
|
||||||
draw::fadein();
|
draw::fadein();
|
||||||
|
|
||||||
game::setState(&gamestate::menu::loop);
|
game::setState(&gamestate::menu::loop);
|
||||||
|
|||||||
@@ -1,28 +1,34 @@
|
|||||||
#include "gamestates.h"
|
#include "gamestates.h"
|
||||||
#include "jgame.h"
|
#include "jgame.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "aux_font.h"
|
||||||
#define POSTFASE_INITIAL 0
|
|
||||||
#define POSTFASE_VICTORIA 1
|
|
||||||
#define POSTFASE_PASSWORD 2
|
|
||||||
|
|
||||||
namespace gamestate
|
namespace gamestate
|
||||||
{
|
{
|
||||||
namespace postfase
|
namespace postfase
|
||||||
{
|
{
|
||||||
|
namespace state
|
||||||
|
{
|
||||||
|
const int initial = 0;
|
||||||
|
const int victoria = 1;
|
||||||
|
const int password = 2;
|
||||||
|
}
|
||||||
|
|
||||||
// Variables del gamestate
|
// Variables del gamestate
|
||||||
static int sub_state = POSTFASE_INITIAL;
|
static int sub_state = postfase::state::initial;
|
||||||
|
|
||||||
void init_victoria();
|
void initVictoria();
|
||||||
void init_password();
|
void initPassword();
|
||||||
bool loop();
|
bool loop();
|
||||||
void drawText(const int x, const int y, const uint8_t color, std::string text);
|
std::string getPassword();
|
||||||
char *ObtenerPasswordDeFase();
|
|
||||||
|
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
sub_state = POSTFASE_INITIAL;
|
sub_state = postfase::state::initial;
|
||||||
|
|
||||||
|
font::selectFont(font::type::colored);
|
||||||
|
font::setColor(font::color::red);
|
||||||
|
|
||||||
if (game::getConfig("fase") == 30) {
|
if (game::getConfig("fase") == 30) {
|
||||||
gamestate::sequence::init();
|
gamestate::sequence::init();
|
||||||
@@ -33,34 +39,21 @@ namespace gamestate
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (game::getConfig("fase") % 5 == 0) {
|
if (game::getConfig("fase") % 5 == 0) {
|
||||||
gamestate::postfase::init_victoria();
|
gamestate::postfase::initVictoria();
|
||||||
} else {
|
} else {
|
||||||
gamestate::postfase::init_password();
|
gamestate::postfase::initPassword();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_victoria()
|
void initVictoria()
|
||||||
{
|
{
|
||||||
sub_state = POSTFASE_VICTORIA;
|
sub_state = postfase::state::victoria;
|
||||||
draw::surface *fondo = nullptr;
|
draw::surface *fondo = nullptr;
|
||||||
|
|
||||||
switch (game::getConfig("fase")) {
|
char filename[12] = "final00.GIF";
|
||||||
case 5:
|
filename[6]= game::getConfig("fase") / 5;
|
||||||
fondo = draw::loadSurface("final01.GIF", true);
|
fondo = draw::loadSurface(filename, true);
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
fondo = draw::loadSurface("final02.GIF", true);
|
|
||||||
break;
|
|
||||||
case 15:
|
|
||||||
fondo = draw::loadSurface("final03.GIF", true);
|
|
||||||
break;
|
|
||||||
case 20:
|
|
||||||
fondo = draw::loadSurface("final04.GIF", true);
|
|
||||||
break;
|
|
||||||
case 25:
|
|
||||||
fondo = draw::loadSurface("final05.GIF", true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
draw::setSource(fondo);
|
draw::setSource(fondo);
|
||||||
draw::draw(0,0,320,200,0,0);
|
draw::draw(0,0,320,200,0,0);
|
||||||
draw::freeSurface(fondo);
|
draw::freeSurface(fondo);
|
||||||
@@ -69,19 +62,18 @@ namespace gamestate
|
|||||||
game::setState(gamestate::postfase::loop);
|
game::setState(gamestate::postfase::loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_password()
|
void initPassword()
|
||||||
{
|
{
|
||||||
sub_state = POSTFASE_PASSWORD;
|
sub_state = postfase::state::password;
|
||||||
draw::surface *fondo = draw::loadSurface("postfase.gif", true);
|
draw::surface *fondo = draw::loadSurface("postfase.gif", true);
|
||||||
|
|
||||||
char *password = ObtenerPasswordDeFase();
|
std::string password = getPassword();
|
||||||
|
|
||||||
draw::setSource(fondo);
|
draw::setSource(fondo);
|
||||||
draw::draw(0,0,320,200,0,0);
|
draw::draw(0,0,320,200,0,0);
|
||||||
draw::freeSurface(fondo);
|
draw::freeSurface(fondo);
|
||||||
|
|
||||||
drawText(175, 166, 1, password);
|
font::print(175, 166, password);
|
||||||
free(password);
|
|
||||||
|
|
||||||
draw::fadein();
|
draw::fadein();
|
||||||
game::setState(gamestate::postfase::loop);
|
game::setState(gamestate::postfase::loop);
|
||||||
@@ -98,8 +90,8 @@ namespace gamestate
|
|||||||
if (salir)
|
if (salir)
|
||||||
{
|
{
|
||||||
salir = false;
|
salir = false;
|
||||||
if (sub_state == POSTFASE_VICTORIA) {
|
if (sub_state == postfase::state::victoria) {
|
||||||
gamestate::postfase::init_password();
|
gamestate::postfase::initPassword();
|
||||||
} else {
|
} else {
|
||||||
gamestate::sequence::init();
|
gamestate::sequence::init();
|
||||||
}
|
}
|
||||||
@@ -115,41 +107,14 @@ namespace gamestate
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawText(const int x, const int y, const uint8_t color, std::string text)
|
std::string getPassword()
|
||||||
{
|
{
|
||||||
draw::surface *pic = draw::loadSurface("fuente2.gif");
|
char *buffer = file::getFileBuffer("offsets.bal");
|
||||||
draw::setSource(pic);
|
|
||||||
draw::setTrans(0);
|
|
||||||
switch (color) {
|
|
||||||
case 0: draw::setPaletteEntry(63, 255, 255, 255); break;
|
|
||||||
case 1: draw::setPaletteEntry(63, 255, 0, 0); break;
|
|
||||||
case 2: draw::setPaletteEntry(63, 0, 255, 0); break;
|
|
||||||
case 3: draw::setPaletteEntry(63, 0, 0, 255); break;
|
|
||||||
}
|
|
||||||
const int len = text.length();
|
|
||||||
for (int i=0;i<len;++i)
|
|
||||||
{
|
|
||||||
char chr = text[i];
|
|
||||||
draw::draw(x+i*7, y, 6, 6, (int(chr)-32)*7, 0);
|
|
||||||
}
|
|
||||||
draw::setTrans(255);
|
|
||||||
draw::freeSurface(pic);
|
|
||||||
draw::render();
|
|
||||||
}
|
|
||||||
|
|
||||||
char *ObtenerPasswordDeFase()
|
|
||||||
{
|
|
||||||
int filesize = 0;
|
|
||||||
const char *buffer = file::getFileBuffer("offsets.bal", &filesize);
|
|
||||||
|
|
||||||
int punter = (game::getConfig("fase")-1)*11;
|
int punter = (game::getConfig("fase")-1)*11;
|
||||||
|
char passFile[11];
|
||||||
char *passFile = (char*)malloc(11);
|
for (int i=0;i<10;i++) passFile[i] = uint8_t(buffer[++punter]) - (101+i);
|
||||||
|
free(buffer);
|
||||||
for (int i=0;i<10;i++) {
|
|
||||||
punter++;
|
|
||||||
passFile[i] = uint8_t(buffer[punter]) - (101+i);
|
|
||||||
}
|
|
||||||
|
|
||||||
return passFile;
|
return passFile;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#include "gamestates.h"
|
#include "gamestates.h"
|
||||||
#include "jgame.h"
|
#include "jgame.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "aux_font.h"
|
||||||
|
#include "proc_mapa.h"
|
||||||
|
|
||||||
namespace gamestate
|
namespace gamestate
|
||||||
{
|
{
|
||||||
@@ -9,30 +11,35 @@ namespace gamestate
|
|||||||
// Variables del gamestate
|
// Variables del gamestate
|
||||||
draw::surface *fondo = nullptr;
|
draw::surface *fondo = nullptr;
|
||||||
draw::surface *cursor = nullptr;
|
draw::surface *cursor = nullptr;
|
||||||
draw::surface *font = nullptr;
|
|
||||||
|
|
||||||
uint8_t num_arounders = 0;
|
|
||||||
uint8_t arounders_necessaris = 0;
|
|
||||||
|
|
||||||
// Mètodes del gamestate
|
// Mètodes del gamestate
|
||||||
void carregarMapa();
|
|
||||||
std::string formatejar(const int numero);
|
|
||||||
void drawText(const int x, const int y, std::string text);
|
|
||||||
bool loop();
|
bool loop();
|
||||||
|
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
|
// Carrega el gif del fondo
|
||||||
fondo = draw::loadSurface("prefase.gif", true);
|
fondo = draw::loadSurface("prefase.gif", true);
|
||||||
cursor = draw::loadSurface("cursor.gif");
|
cursor = draw::loadSurface("cursor.gif");
|
||||||
font = draw::loadSurface("fuente1.gif");
|
|
||||||
|
|
||||||
//int size=0;
|
// Carrega el mapa
|
||||||
//uint32_t *font_pal = draw::loadPalette("fuente1.gif", &size);
|
mapa::carregar();
|
||||||
//draw::setPalette(font_pal+1, 5, 80);
|
|
||||||
|
|
||||||
carregarMapa();
|
// Pinta el text en el fondo
|
||||||
|
draw::setDestination(fondo);
|
||||||
|
font::selectFont(font::type::normal);
|
||||||
|
|
||||||
|
font::print(130, 60, "NIVELL");
|
||||||
|
font::print(179, 60, game::getConfig("fase")+1);
|
||||||
|
|
||||||
|
font::print(80, 100, mapa::arounders::totals);
|
||||||
|
font::print(101, 100, "AROUNDERS DISPONIBLES");
|
||||||
|
|
||||||
|
font::print(80, 110, mapa::arounders::necessaris);
|
||||||
|
font::print(101, 110, "AROUNDERS NECESSARIS");
|
||||||
|
|
||||||
|
draw::setDestination(nullptr);
|
||||||
|
|
||||||
|
// Comencem el bucle
|
||||||
draw::fadein();
|
draw::fadein();
|
||||||
game::setState(gamestate::prefase::loop);
|
game::setState(gamestate::prefase::loop);
|
||||||
}
|
}
|
||||||
@@ -41,27 +48,12 @@ namespace gamestate
|
|||||||
{
|
{
|
||||||
static bool salir = false;
|
static bool salir = false;
|
||||||
|
|
||||||
const int x = input::mouseX();
|
|
||||||
const int y = input::mouseY();
|
|
||||||
|
|
||||||
draw::setTrans(255);
|
draw::setTrans(255);
|
||||||
draw::setSource(fondo);
|
draw::setSource(fondo);
|
||||||
draw::draw(0, 0, 320, 200, 0, 0);
|
draw::draw(0, 0, 320, 200, 0, 0);
|
||||||
|
|
||||||
draw::setTrans(0);
|
|
||||||
draw::setSource(font);
|
|
||||||
|
|
||||||
drawText(130, 60, "NIVELL");
|
|
||||||
drawText(179, 60, formatejar(game::getConfig("fase")+1));
|
|
||||||
|
|
||||||
drawText(80, 100, formatejar(num_arounders));
|
|
||||||
drawText(101, 100, "AROUNDERS DISPONIBLES");
|
|
||||||
|
|
||||||
drawText(80, 110, formatejar(arounders_necessaris));
|
|
||||||
drawText(101, 110, "AROUNDERS NECESSARIS");
|
|
||||||
|
|
||||||
draw::setSource(cursor);
|
draw::setSource(cursor);
|
||||||
draw::draw(x, y, cursor->w, cursor->h, 0, 0);
|
draw::draw(input::mouseX(), input::mouseY(), cursor->w, cursor->h, 0, 0);
|
||||||
|
|
||||||
draw::render();
|
draw::render();
|
||||||
|
|
||||||
@@ -83,49 +75,5 @@ namespace gamestate
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void carregarMapa()
|
|
||||||
{
|
|
||||||
int filesize = 0;
|
|
||||||
char *buffer = file::getFileBuffer("MAPES.BAL", &filesize);
|
|
||||||
|
|
||||||
char *punter = buffer + (game::getConfig("fase") * 212) + 3;
|
|
||||||
|
|
||||||
num_arounders = *(punter++);
|
|
||||||
arounders_necessaris = *punter;
|
|
||||||
|
|
||||||
free(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string formatejar(const int numero)
|
|
||||||
{
|
|
||||||
char resultat[3];
|
|
||||||
|
|
||||||
if (numero > 9) {
|
|
||||||
resultat[0] = (numero / 10) + 48;
|
|
||||||
resultat[1] = (numero % 10) + 48;
|
|
||||||
} else {
|
|
||||||
resultat[0] = 48;
|
|
||||||
resultat[1] = (numero % 10) + 48;
|
|
||||||
}
|
|
||||||
|
|
||||||
resultat[2] = '\0';
|
|
||||||
|
|
||||||
return std::string(resultat);
|
|
||||||
}
|
|
||||||
|
|
||||||
void drawText(const int x, const int y, std::string text)
|
|
||||||
{
|
|
||||||
draw::setSource(font);
|
|
||||||
draw::setTrans(0);
|
|
||||||
//for (int i=1;i<=5;++i) draw::swapcol(i, 79+i);
|
|
||||||
const int len = text.length();
|
|
||||||
for (int i=0;i<len;++i)
|
|
||||||
{
|
|
||||||
char chr = text[i];
|
|
||||||
draw::draw(x+i*7, y, 5, 5, (int(chr)-32)*7, 0);
|
|
||||||
}
|
|
||||||
//for (int i=1;i<=5;++i) draw::restorecol(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,7 @@
|
|||||||
#include "jgame.h"
|
#include "jgame.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
#include "aux_font.h"
|
||||||
#define DIAPO_ESPERAR 0
|
|
||||||
#define DIAPO_FADEIN 1
|
|
||||||
#define DIAPO_SHOW 2
|
|
||||||
#define DIAPO_PRINT 3
|
|
||||||
#define DIAPO_MUSICA 4
|
|
||||||
#define DIAPO_FADEOUT 5
|
|
||||||
#define DIAPO_FADEMUSIC 6
|
|
||||||
|
|
||||||
namespace gamestate
|
namespace gamestate
|
||||||
{
|
{
|
||||||
@@ -19,17 +12,16 @@ namespace gamestate
|
|||||||
uint32_t wait_until = 0;
|
uint32_t wait_until = 0;
|
||||||
|
|
||||||
void drawPic(std::string filename);
|
void drawPic(std::string filename);
|
||||||
void drawText(const int x, const int y, const uint8_t color, std::string text);
|
|
||||||
bool loop();
|
bool loop();
|
||||||
|
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
draw::setTrans(255);
|
draw::setTrans(255);
|
||||||
const int fase = game::getConfig("fase");
|
font::selectFont(font::type::colored);
|
||||||
|
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
|
||||||
switch (fase)
|
switch (game::getConfig("fase"))
|
||||||
{
|
{
|
||||||
case -1: filename = "seqIN.txt"; break;
|
case -1: filename = "seqIN.txt"; break;
|
||||||
case 0: filename = "seq00.txt"; break;
|
case 0: filename = "seq00.txt"; break;
|
||||||
@@ -39,11 +31,10 @@ namespace gamestate
|
|||||||
case 20: filename = "seq20.txt"; break;
|
case 20: filename = "seq20.txt"; break;
|
||||||
case 25: filename = "seq25.txt"; break;
|
case 25: filename = "seq25.txt"; break;
|
||||||
case 30: filename = "seq30.txt"; break;
|
case 30: filename = "seq30.txt"; break;
|
||||||
default: gamestate::prefase::init();
|
default: gamestate::prefase::init(); return; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int filesize;
|
sequence_file = file::getFilePointer(filename);
|
||||||
sequence_file = file::getFilePointer(filename, &filesize);
|
|
||||||
|
|
||||||
game::setState(&gamestate::sequence::loop);
|
game::setState(&gamestate::sequence::loop);
|
||||||
}
|
}
|
||||||
@@ -54,6 +45,7 @@ namespace gamestate
|
|||||||
draw::render();
|
draw::render();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (wait_until > 0) && (SDL_GetTicks() < wait_until) )
|
if ( (wait_until > 0) && (SDL_GetTicks() < wait_until) )
|
||||||
{
|
{
|
||||||
if (input::anyKeyPressed() || input::mouseBtn(1)) {
|
if (input::anyKeyPressed() || input::mouseBtn(1)) {
|
||||||
@@ -87,30 +79,26 @@ namespace gamestate
|
|||||||
std::string command(text);
|
std::string command(text);
|
||||||
|
|
||||||
if (command=="ESPERAR") {
|
if (command=="ESPERAR") {
|
||||||
//int res =
|
|
||||||
fscanf(sequence_file, "%i", &val);
|
fscanf(sequence_file, "%i", &val);
|
||||||
printf("ESPERAR %i\n", val);
|
printf("ESPERAR %i\n", val);
|
||||||
wait_until = SDL_GetTicks() + val;
|
wait_until = SDL_GetTicks() + val;
|
||||||
|
|
||||||
} else if (command=="FADEIN") {
|
} else if (command=="FADEIN") {
|
||||||
//int res =
|
|
||||||
fscanf(sequence_file, " '%[^']'", text);
|
fscanf(sequence_file, " '%[^']'", text);
|
||||||
drawPic(text);
|
drawPic(text);
|
||||||
draw::fadein();
|
draw::fadein();
|
||||||
|
|
||||||
} else if (command=="SHOW") {
|
} else if (command=="SHOW") {
|
||||||
//int res =
|
|
||||||
fscanf(sequence_file, " '%[^']'", text);
|
fscanf(sequence_file, " '%[^']'", text);
|
||||||
drawPic(text);
|
drawPic(text);
|
||||||
draw::render();
|
draw::render();
|
||||||
|
|
||||||
} else if (command=="PRINT") {
|
} else if (command=="PRINT") {
|
||||||
//int res =
|
|
||||||
fscanf(sequence_file, " %i %i %i '%[^']'", &x, &y, &val, text);
|
fscanf(sequence_file, " %i %i %i '%[^']'", &x, &y, &val, text);
|
||||||
drawText(x, y, val, text);
|
font::setColor(val);
|
||||||
|
font::print(x, y, text);
|
||||||
|
|
||||||
} else if (command=="PLAYMUSIC") {
|
} else if (command=="PLAYMUSIC") {
|
||||||
//int res =
|
|
||||||
fscanf(sequence_file, " '%[^']'", text);
|
fscanf(sequence_file, " '%[^']'", text);
|
||||||
audio::loadMusic(text);
|
audio::loadMusic(text);
|
||||||
audio::playMusic();
|
audio::playMusic();
|
||||||
@@ -135,27 +123,5 @@ namespace gamestate
|
|||||||
draw::freeSurface(pic);
|
draw::freeSurface(pic);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawText(const int x, const int y, const uint8_t color, std::string text)
|
|
||||||
{
|
|
||||||
draw::surface *pic = draw::loadSurface("fuente2.gif");
|
|
||||||
draw::setSource(pic);
|
|
||||||
draw::setTrans(0);
|
|
||||||
switch (color) {
|
|
||||||
case 0: draw::setPaletteEntry(63, 255, 255, 255); break;
|
|
||||||
case 1: draw::setPaletteEntry(63, 255, 0, 0); break;
|
|
||||||
case 2: draw::setPaletteEntry(63, 0, 255, 0); break;
|
|
||||||
case 3: draw::setPaletteEntry(63, 0, 0, 255); break;
|
|
||||||
}
|
|
||||||
const int len = text.length();
|
|
||||||
for (int i=0;i<len;++i)
|
|
||||||
{
|
|
||||||
char chr = text[i];
|
|
||||||
draw::draw(x+i*7, y, 6, 6, (int(chr)-32)*7, 0);
|
|
||||||
}
|
|
||||||
draw::setTrans(255);
|
|
||||||
draw::freeSurface(pic);
|
|
||||||
draw::render();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "jgame.h"
|
#include "jgame.h"
|
||||||
#include "gamestates.h"
|
#include "gamestates.h"
|
||||||
|
#include "aux_font.h"
|
||||||
|
|
||||||
void game::init()
|
void game::init()
|
||||||
{
|
{
|
||||||
@@ -7,6 +8,8 @@ void game::init()
|
|||||||
input::init(3);
|
input::init(3);
|
||||||
audio::init();
|
audio::init();
|
||||||
|
|
||||||
|
font::init();
|
||||||
|
|
||||||
game::setUpdateTicks(16);
|
game::setUpdateTicks(16);
|
||||||
game::setConfig("fase", -1);
|
game::setConfig("fase", -1);
|
||||||
|
|
||||||
|
|||||||
103
source/proc_mapa.cpp
Normal file
103
source/proc_mapa.cpp
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
#include "proc_mapa.h"
|
||||||
|
#include "jgame.h"
|
||||||
|
#include <stdio.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()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
35
source/proc_mapa.h
Normal file
35
source/proc_mapa.h
Normal file
@@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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);
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user