3 Commits

Author SHA1 Message Date
9c10b6a372 Merge branch 'master' of https://gitea.sustancia.synology.me/JailDoctor/thepool 2024-10-11 09:20:28 +02:00
31f63516ca - [CHG] Ara en Linux la configuració se guarda en " ~/.config/thepool/config.txt"
- [FIX] Solventada explosió en pantalla de gameover per un dangling pointer. Aplicades medides similars en catslife i ingame.
2024-10-11 09:20:24 +02:00
b5f4425672 - [FIX] Ja no es mostra el cursor mai (excepte si estas editant) 2024-10-10 20:38:12 +02:00
7 changed files with 42 additions and 18 deletions

View File

@@ -105,9 +105,10 @@ namespace draw
SDL_GetRendererInfo(sdl_renderer, &info);
printf("\nRenderer: %s\n", info.name);
SDL_ShowCursor(false);
if (screen_fullscreen)
{
SDL_ShowCursor(false);
int w, h;
SDL_GetWindowSize(sdl_window, &w, &h);
fullscreen_scale = h/screen_height;
@@ -118,7 +119,6 @@ namespace draw
}
else
{
SDL_ShowCursor(true);
dest_rect.x = dest_rect.y = 0;
dest_rect.w = screen_width * zoom;
dest_rect.h = screen_height * zoom;
@@ -187,9 +187,10 @@ namespace draw
sdl_renderer = SDL_CreateRenderer(sdl_window, -1, 0);
sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height);
SDL_ShowCursor(false);
if (screen_fullscreen)
{
SDL_ShowCursor(false);
int w, h;
SDL_GetWindowSize(sdl_window, &w, &h);
fullscreen_scale = h/screen_height;
@@ -200,7 +201,6 @@ namespace draw
}
else
{
SDL_ShowCursor(true);
dest_rect.x = dest_rect.y = 0;
dest_rect.w = screen_width * zoom;
dest_rect.h = screen_height * zoom;

View File

@@ -341,7 +341,19 @@ namespace file
#elif __linux__
struct passwd *pw = getpwuid(getuid());
const char *homedir = pw->pw_dir;
config_folder = std::string(homedir) + "/." + foldername;
config_folder = std::string(homedir) + "/.config/" + foldername;
{
// Intenta crear ".config", per si no existeix
std::string config_base_folder = std::string(homedir) + "/.config";
int ret = mkdir(config_base_folder.c_str(), S_IRWXU);
if (ret == -1 && errno != EEXIST)
{
printf("ERROR CREATING CONFIG BASE FOLDER.");
exit(EXIT_FAILURE);
}
}
#endif
struct stat st = {0};

View File

@@ -17,12 +17,15 @@ namespace modules
void init()
{
audio::playMusic("mus_gameover.ogg", 0);
if (gat == nullptr) gat = actor::createFromTemplate("GAT-NEGRE");
gat = actor::createFromTemplate("GAT-NEGRE");
}
bool loop()
{
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK)) {
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK))
{
if (gat) actor::remove(gat);
gat = nullptr;
return false;
}

View File

@@ -19,7 +19,6 @@ namespace modules
{
if (audio::getCurrentMusic() != "mus_gameover.ogg") audio::playMusic("mus_gameover.ogg", 0);
if (heroi) actor::remove(heroi);
if (actor::hero::isPrologo()) {
heroi = actor::create("HERO", {16, 32, 0}, {6, 6, 8}, "gat.gif", {0, 0, 24, 28}, {-4, 32});
} else {
@@ -43,7 +42,12 @@ namespace modules
bool loop()
{
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK)) { return false; }
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK))
{
if (heroi) actor::remove(heroi);
heroi = nullptr;
return false;
}
draw::cls(2);
draw::color(1);

View File

@@ -76,9 +76,17 @@ namespace modules
}
}
void cleanup()
{
for (int i=0; i<6; ++i) { actor::remove(parts[i]); parts[i]=nullptr;}
actor::remove(anbernic); anbernic=nullptr;
}
int loop()
{
if (controller::pressed(KEY_MENU)) {
if (controller::pressed(KEY_MENU))
{
cleanup();
return INGAME_CONTINUAR;
}
if (controller::pressed(KEY_DOWN) || input::keyPressed(SDL_SCANCODE_DOWN))
@@ -94,11 +102,7 @@ namespace modules
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK) || input::keyPressed(SDL_SCANCODE_RETURN))
{
audio::playSound("snd_push.wav", SOUND_BASIC);
if (selected_option==INGAME_EIXIR)
{
for (int i=0; i<6; ++i) { actor::remove(parts[i]); parts[i]=nullptr;}
actor::remove(anbernic); anbernic=nullptr;
}
cleanup();
return selected_option;
}

View File

@@ -31,7 +31,7 @@ namespace modules
void init()
{
srand(SDL_GetTicks());
anys = draw::getSurface("25anys.gif");
anys = draw::getSurface("25anys.gif"); // getSurface() no crea res, així que no fa falta destruir ni fer res al eixir
num_pixels = 0;
draw::surface *surf = draw::getSurface("jailgames.gif");
for (int y=0; y<surf->h; ++y)

View File

@@ -104,9 +104,10 @@ void game::init()
{
if (game::getParams(1) && strcmp(game::getParams(1), "editor")==0) editor::setDevMode();
if (editor::isDevMode())
if (editor::isDevMode()) {
draw::init("The Pool", 520, 240, zoom);
else {
SDL_ShowCursor(true);
} else {
loadConfig();
draw::init("The Pool", 320, 240, zoom, fullscreen);
console::init();