- [NEW] Habitació de prova de parts
- [NEW] Templates de les parts - [NEW] Mòdul de debug - [NEW] Debug info de la posicio dels actors - [FIX] Al reiniciar partida el heroi estava en posició incorrecta - [NEW] Mòdul de config - [NEW] El joc ja permet canviar zoom i ficar fullscreen - [NEW] F1, F2 i F3 per a zoom i fullscreen - [NEW] Ja es guarda en arxiu de config el zoom, fullscreen, musica i só. - [FIX] Al eixir prematurament del logo de vegades la paleta estava loca - [NEW] Menú de configuració del àudio - [NEW] Menú de pausa dins del joc (es veu peces que falten per arreplegar) - [ONGOING] Comença l'implementació de tecles redefinides
This commit is contained in:
@@ -1,26 +1,58 @@
|
||||
#include "jgame.h"
|
||||
#include "jdraw.h"
|
||||
#include "jfile.h"
|
||||
#include "jinput.h"
|
||||
#include "editor.h"
|
||||
#include "console.h"
|
||||
#include "string.h"
|
||||
#include "config.h"
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#include "m_game.h"
|
||||
#include "m_menu.h"
|
||||
#include "m_logo.h"
|
||||
#include "m_ingame.h"
|
||||
#include "m_menu_audio.h"
|
||||
|
||||
#define M_LOGO 0
|
||||
#define M_MENU 1
|
||||
#define M_GAME 2
|
||||
#define M_INGAME 3
|
||||
#define M_MENU_AUDIO 4
|
||||
|
||||
int current_module = M_LOGO;
|
||||
int zoom = 3;
|
||||
bool fullscreen = false;
|
||||
char tmp[100];
|
||||
|
||||
void loadConfig()
|
||||
{
|
||||
file::setConfigFolder("thepool");
|
||||
|
||||
if (strcmp(file::getConfigValue("music").c_str(), "no")==0) config::setMusic(false);
|
||||
|
||||
const char *so = file::getConfigValue("sound").c_str();
|
||||
if (strcmp(so, "basic")==0)
|
||||
config::setSound(SOUND_BASIC);
|
||||
else if (strcmp(so, "none")==0)
|
||||
config::setSound(SOUND_NONE);
|
||||
|
||||
std::string txt_zoom = file::getConfigValue("zoom");
|
||||
if (txt_zoom!="") zoom = SDL_atoi(txt_zoom.c_str());
|
||||
|
||||
std::string txt_fullscreen = file::getConfigValue("fullscreen");
|
||||
if (txt_fullscreen=="yes") fullscreen = true;
|
||||
}
|
||||
|
||||
void game::init()
|
||||
{
|
||||
if (game::getParams(1) && strcmp(game::getParams(1), "editor")==0) editor::setDevMode();
|
||||
|
||||
if (editor::isDevMode())
|
||||
draw::init("The Pool", 520, 240, 3);
|
||||
draw::init("The Pool", 520, 240, zoom);
|
||||
else {
|
||||
draw::init("The Pool", 320, 240, 3);
|
||||
loadConfig();
|
||||
draw::init("The Pool", 320, 240, zoom, fullscreen);
|
||||
console::init();
|
||||
}
|
||||
|
||||
@@ -36,6 +68,22 @@ void game::init()
|
||||
|
||||
bool game::loop()
|
||||
{
|
||||
if (input::keyPressed(SDL_SCANCODE_F1)) {
|
||||
draw::decZoom();
|
||||
zoom = draw::getZoom();
|
||||
file::setConfigValue("zoom", SDL_itoa(zoom, tmp, 10));
|
||||
}
|
||||
if (input::keyPressed(SDL_SCANCODE_F2)) {
|
||||
draw::incZoom();
|
||||
zoom = draw::getZoom();
|
||||
file::setConfigValue("zoom", SDL_itoa(zoom, tmp, 10));
|
||||
}
|
||||
if (input::keyPressed(SDL_SCANCODE_F3)) {
|
||||
draw::toggleFullscreen();
|
||||
fullscreen = draw::getFullscreen();
|
||||
file::setConfigValue("fullscreen", fullscreen?"yes":"no");
|
||||
}
|
||||
|
||||
int option;
|
||||
switch(current_module)
|
||||
{
|
||||
@@ -47,10 +95,25 @@ bool game::loop()
|
||||
if (option != OPTION_NONE) {
|
||||
if (option == OPTION_EIXIR) return false;
|
||||
if (option == OPTION_JUGAR) { modules::game::init(); current_module = M_GAME; }
|
||||
if (option == OPTION_AUDIO) { modules::menu_audio::init(); current_module = M_MENU_AUDIO; }
|
||||
}
|
||||
break;
|
||||
case M_GAME:
|
||||
return modules::game::loop();
|
||||
if (!modules::game::loop()) { modules::ingame::init(); current_module = M_INGAME; }
|
||||
break;
|
||||
case M_INGAME:
|
||||
option = modules::ingame::loop();
|
||||
if (option != INGAME_NONE) {
|
||||
if (option == INGAME_EIXIR) { modules::menu::init(); current_module = M_MENU; }
|
||||
if (option == INGAME_CONTINUAR) { current_module = M_GAME; }
|
||||
}
|
||||
break;
|
||||
case M_MENU_AUDIO:
|
||||
if (modules::menu_audio::loop() == MENU_AUDIO_TORNAR) {
|
||||
modules::menu::init(); current_module = M_MENU;
|
||||
}
|
||||
break;
|
||||
|
||||
};
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user