- [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:
@@ -8,28 +8,74 @@ door-texture: 0
|
|||||||
under-door-texture: 0
|
under-door-texture: 0
|
||||||
exit-xp: 7
|
exit-xp: 7
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: P-ELBOW
|
||||||
|
bmp: objectes.gif
|
||||||
|
bmp-rect: 0 32 22 32
|
||||||
|
bmp-offset: -2 35
|
||||||
|
pos: 8 16 0
|
||||||
|
size: 4 4 4
|
||||||
|
anim-wait: 6
|
||||||
|
flags: ANIMATED SPECIAL
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: P-PIPE
|
||||||
|
bmp: objectes.gif
|
||||||
|
bmp-rect: 0 64 16 32
|
||||||
|
bmp-offset: -8 36
|
||||||
|
pos: 8 24 0
|
||||||
|
size: 4 4 4
|
||||||
|
anim-wait: 6
|
||||||
|
flags: ANIMATED SPECIAL
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: P-SALT
|
||||||
|
bmp: objectes.gif
|
||||||
|
bmp-rect: 66 32 20 32
|
||||||
|
bmp-offset: -7 35
|
||||||
|
pos: 8 32 0
|
||||||
|
size: 4 4 4
|
||||||
|
anim-wait: 6
|
||||||
|
flags: ANIMATED SPECIAL
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
actor{
|
actor{
|
||||||
name: P-FILTER
|
name: P-FILTER
|
||||||
bmp: objectes.gif
|
bmp: objectes.gif
|
||||||
bmp-rect: 24 0 24 32
|
bmp-rect: 0 0 24 32
|
||||||
bmp-offset: -4 34
|
bmp-offset: -4 34
|
||||||
pos: 8 8 0
|
pos: 8 24 8
|
||||||
size: 4 4 4
|
size: 4 4 4
|
||||||
anim-cycle: SEQ
|
anim-wait: 6
|
||||||
anim-wait: 2
|
flags: ANIMATED SPECIAL
|
||||||
flags: SPECIAL
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: P-PUMP
|
||||||
|
bmp: objectes.gif
|
||||||
|
bmp-rect: 48 64 22 32
|
||||||
|
bmp-offset: -5 35
|
||||||
|
pos: 8 32 11
|
||||||
|
size: 4 4 4
|
||||||
|
anim-wait: 6
|
||||||
|
flags: ANIMATED SPECIAL
|
||||||
movement: CW
|
movement: CW
|
||||||
}
|
}
|
||||||
|
|
||||||
actor{
|
actor{
|
||||||
name: P-TIMER
|
name: P-TIMER
|
||||||
bmp: objectes.gif
|
bmp: objectes.gif
|
||||||
bmp-rect: 96 0 24 32
|
bmp-rect: 72 0 24 32
|
||||||
bmp-offset: -4 34
|
bmp-offset: -4 34
|
||||||
pos: 8 16 0
|
pos: 8 40 8
|
||||||
size: 4 4 4
|
size: 4 4 4
|
||||||
anim-cycle: SEQ
|
anim-wait: 6
|
||||||
anim-wait: 2
|
flags: ANIMATED SPECIAL
|
||||||
flags: SPECIAL
|
|
||||||
movement: CW
|
movement: CW
|
||||||
}
|
}
|
||||||
|
|||||||
7
data/rooms/09.txt
Normal file
7
data/rooms/09.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
width: 2
|
||||||
|
height: 2
|
||||||
|
color: CYAN
|
||||||
|
floor-texture: 0
|
||||||
|
wall-texture: 0
|
||||||
|
door-texture: 0
|
||||||
|
under-door-texture: 0
|
||||||
@@ -85,6 +85,32 @@ actor{
|
|||||||
bmp: objectes.gif
|
bmp: objectes.gif
|
||||||
bmp-rect: 96 0 24 32
|
bmp-rect: 96 0 24 32
|
||||||
bmp-offset: -4 34
|
bmp-offset: -4 34
|
||||||
|
pos: 8 40 8
|
||||||
|
size: 4 4 4
|
||||||
|
anim-cycle: SEQ
|
||||||
|
anim-wait: 2
|
||||||
|
flags: SPECIAL
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: P-FILTER
|
||||||
|
bmp: objectes.gif
|
||||||
|
bmp-rect: 24 0 24 32
|
||||||
|
bmp-offset: -4 34
|
||||||
|
pos: 8 24 8
|
||||||
|
size: 4 4 4
|
||||||
|
anim-cycle: SEQ
|
||||||
|
anim-wait: 2
|
||||||
|
flags: SPECIAL
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: P-ELBOW
|
||||||
|
bmp: objectes.gif
|
||||||
|
bmp-rect: 22 32 22 32
|
||||||
|
bmp-offset: -2 35
|
||||||
pos: 8 16 0
|
pos: 8 16 0
|
||||||
size: 4 4 4
|
size: 4 4 4
|
||||||
anim-cycle: SEQ
|
anim-cycle: SEQ
|
||||||
@@ -92,3 +118,42 @@ actor{
|
|||||||
flags: SPECIAL
|
flags: SPECIAL
|
||||||
movement: CW
|
movement: CW
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: P-PIPE
|
||||||
|
bmp: objectes.gif
|
||||||
|
bmp-rect: 16 64 16 32
|
||||||
|
bmp-offset: -8 36
|
||||||
|
pos: 8 24 0
|
||||||
|
size: 4 4 4
|
||||||
|
anim-cycle: SEQ
|
||||||
|
anim-wait: 2
|
||||||
|
flags: SPECIAL
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: P-SALT
|
||||||
|
bmp: objectes.gif
|
||||||
|
bmp-rect: 86 32 20 32
|
||||||
|
bmp-offset: -7 35
|
||||||
|
pos: 8 32 0
|
||||||
|
size: 4 4 4
|
||||||
|
anim-cycle: SEQ
|
||||||
|
anim-wait: 2
|
||||||
|
flags: SPECIAL
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: P-PUMP
|
||||||
|
bmp: objectes.gif
|
||||||
|
bmp-rect: 70 64 22 32
|
||||||
|
bmp-offset: -5 35
|
||||||
|
pos: 8 32 11
|
||||||
|
size: 4 4 4
|
||||||
|
anim-cycle: SEQ
|
||||||
|
anim-wait: 2
|
||||||
|
flags: SPECIAL
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#include "jutil.h"
|
#include "jutil.h"
|
||||||
#include "room.h"
|
#include "room.h"
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "config.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace actor
|
namespace actor
|
||||||
@@ -455,7 +457,7 @@ namespace actor
|
|||||||
vec3_t max = room::getMax();
|
vec3_t max = room::getMax();
|
||||||
|
|
||||||
bool moving = false;
|
bool moving = false;
|
||||||
if ( input::keyDown(SDL_SCANCODE_LEFT) )
|
if ( input::keyDown(SDL_SCANCODE_LEFT) || input::keyDown(config::getKey(KEY_LEFT)) )
|
||||||
{
|
{
|
||||||
hero::useBoostRun();
|
hero::useBoostRun();
|
||||||
act->orient=PUSH_XN;
|
act->orient=PUSH_XN;
|
||||||
@@ -473,7 +475,7 @@ namespace actor
|
|||||||
act->push |= PUSH_XN;
|
act->push |= PUSH_XN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( input::keyDown(SDL_SCANCODE_RIGHT) )
|
else if ( input::keyDown(SDL_SCANCODE_RIGHT) || input::keyDown(config::getKey(KEY_RIGHT)) )
|
||||||
{
|
{
|
||||||
hero::useBoostRun();
|
hero::useBoostRun();
|
||||||
act->orient=PUSH_XP;
|
act->orient=PUSH_XP;
|
||||||
@@ -491,7 +493,7 @@ namespace actor
|
|||||||
act->push |= PUSH_XP;
|
act->push |= PUSH_XP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( input::keyDown(SDL_SCANCODE_UP) )
|
else if ( input::keyDown(SDL_SCANCODE_UP) || input::keyDown(config::getKey(KEY_UP)) )
|
||||||
{
|
{
|
||||||
hero::useBoostRun();
|
hero::useBoostRun();
|
||||||
act->orient=PUSH_YN;
|
act->orient=PUSH_YN;
|
||||||
@@ -509,7 +511,7 @@ namespace actor
|
|||||||
act->push |= PUSH_YN;
|
act->push |= PUSH_YN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( input::keyDown(SDL_SCANCODE_DOWN) )
|
else if ( input::keyDown(SDL_SCANCODE_DOWN) || input::keyDown(config::getKey(KEY_DOWN)) )
|
||||||
{
|
{
|
||||||
hero::useBoostRun();
|
hero::useBoostRun();
|
||||||
act->orient=PUSH_YP;
|
act->orient=PUSH_YP;
|
||||||
@@ -527,7 +529,7 @@ namespace actor
|
|||||||
act->push |= PUSH_YP;
|
act->push |= PUSH_YP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (input::keyPressed(SDL_SCANCODE_RETURN) && (hero::getSkills()&SKILL_PANTS))
|
if ((input::keyPressed(SDL_SCANCODE_RETURN) || input::keyDown(config::getKey(KEY_PICK)) ) && (hero::getSkills()&SKILL_PANTS))
|
||||||
{
|
{
|
||||||
if (picked)
|
if (picked)
|
||||||
{
|
{
|
||||||
@@ -552,10 +554,10 @@ namespace actor
|
|||||||
{
|
{
|
||||||
const int height = act->below->size.z;
|
const int height = act->below->size.z;
|
||||||
pick(act->below);
|
pick(act->below);
|
||||||
if (!input::keyDown(SDL_SCANCODE_SPACE)) act->pos.z -= height;
|
if (!input::keyDown(SDL_SCANCODE_SPACE) && !input::keyDown(config::getKey(KEY_JUMP))) act->pos.z -= height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( input::keyDown(SDL_SCANCODE_SPACE) && (hero::getSkills()&SKILL_SHOES) && (act->pos.y+act->size.y)<=max.y && act->pos.y>=min.y && (act->pos.x+act->size.x)<=max.x && act->pos.x>=min.x && act->react_mask==0 && (act->pos.z==0 || act->below))
|
if (( input::keyDown(SDL_SCANCODE_SPACE) || input::keyDown(config::getKey(KEY_JUMP)) ) && (hero::getSkills()&SKILL_SHOES) && (act->pos.y+act->size.y)<=max.y && act->pos.y>=min.y && (act->pos.x+act->size.x)<=max.x && act->pos.x>=min.x && act->react_mask==0 && (act->pos.z==0 || act->below))
|
||||||
{
|
{
|
||||||
// [RZC 14/05/2024] hack usant react_mask i react_push del heroi. Llegir més avall.
|
// [RZC 14/05/2024] hack usant react_mask i react_push del heroi. Llegir més avall.
|
||||||
act->react_mask=hero::getBoostJump()>0 ? 2 : 1; // =1 estic botant (anant cap amunt)
|
act->react_mask=hero::getBoostJump()>0 ? 2 : 1; // =1 estic botant (anant cap amunt)
|
||||||
@@ -992,11 +994,13 @@ namespace actor
|
|||||||
draw::draw(x, y, act->bmp_rect.w, act->bmp_rect.h, act->bmp_rect.x+ao, act->bmp_rect.y+oo, flip);
|
draw::draw(x, y, act->bmp_rect.w, act->bmp_rect.h, act->bmp_rect.x+ao, act->bmp_rect.y+oo, flip);
|
||||||
draw::swapcol(1, room::getColor(0)); // Tornem al color per defecte
|
draw::swapcol(1, room::getColor(0)); // Tornem al color per defecte
|
||||||
draw::popSource();
|
draw::popSource();
|
||||||
//print(x+5,y,act->pos.x);
|
if (debug::isEnabled(DEBUG_ACTOR_POS))
|
||||||
//print(x+5,y+6,act->pos.y);
|
{
|
||||||
//print(x+5,y+12,act->pos.z);
|
char tmp[100];
|
||||||
//print(x+5,y+12,order);
|
draw::print(SDL_itoa(act->inner_x, tmp, 10), x+9,y+20, LIGHT+WHITE, BLACK);
|
||||||
//print(x+5,y,act->flags);
|
draw::print(SDL_itoa(act->inner_y, tmp, 10), x+9,y+26, LIGHT+WHITE, BLACK);
|
||||||
|
draw::swapcol(1, room::getColor(0)); // Tornem al color per defecte
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (draw_all && act->next) draw(act->next);
|
if (draw_all && act->next) draw(act->next);
|
||||||
}
|
}
|
||||||
@@ -1113,14 +1117,14 @@ namespace actor
|
|||||||
|
|
||||||
actor_t *getPicked() { return picked; }
|
actor_t *getPicked() { return picked; }
|
||||||
|
|
||||||
void clear()
|
void clear(const bool all)
|
||||||
{
|
{
|
||||||
actor_t *hero = nullptr;
|
actor_t *hero = nullptr;
|
||||||
actor_t *act = first;
|
actor_t *act = first;
|
||||||
while (act)
|
while (act)
|
||||||
{
|
{
|
||||||
actor_t *tmp = act->next;
|
actor_t *tmp = act->next;
|
||||||
if (act->flags & FLAG_HERO) {
|
if (!all && (act->flags & FLAG_HERO)) {
|
||||||
hero = act;
|
hero = act;
|
||||||
} else {
|
} else {
|
||||||
//draw::freeSurface(act->surface);
|
//draw::freeSurface(act->surface);
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ namespace actor
|
|||||||
|
|
||||||
actor_t *getPicked();
|
actor_t *getPicked();
|
||||||
|
|
||||||
void clear();
|
void clear(const bool all=false);
|
||||||
|
|
||||||
namespace templates
|
namespace templates
|
||||||
{
|
{
|
||||||
|
|||||||
55
source/config.cpp
Normal file
55
source/config.cpp
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#include "config.h"
|
||||||
|
#include "jfile.h"
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
|
namespace config
|
||||||
|
{
|
||||||
|
bool musicEnabled = true;
|
||||||
|
int soundMode = SOUND_ALL;
|
||||||
|
uint8_t keys[6] = {SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_SPACE, SDL_SCANCODE_RETURN};
|
||||||
|
|
||||||
|
void setMusic(const bool value)
|
||||||
|
{
|
||||||
|
musicEnabled = value;
|
||||||
|
file::setConfigValue("music", musicEnabled ? "yes" : "no");
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggleMusic()
|
||||||
|
{
|
||||||
|
musicEnabled = !musicEnabled;
|
||||||
|
file::setConfigValue("music", musicEnabled ? "yes" : "no");
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool isMusicEnabled()
|
||||||
|
{
|
||||||
|
return musicEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSound(const int value)
|
||||||
|
{
|
||||||
|
soundMode = value;
|
||||||
|
file::setConfigValue("sound", soundMode==SOUND_ALL ? "all" : soundMode==SOUND_BASIC ? "basic" : "none");
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggleSound()
|
||||||
|
{
|
||||||
|
soundMode++;
|
||||||
|
if (soundMode>SOUND_NONE) soundMode = SOUND_ALL;
|
||||||
|
file::setConfigValue("sound", soundMode==SOUND_ALL ? "all" : soundMode==SOUND_BASIC ? "basic" : "none");
|
||||||
|
}
|
||||||
|
|
||||||
|
const int getSoundMode()
|
||||||
|
{
|
||||||
|
return soundMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void defineKey(const int which, const int key)
|
||||||
|
{
|
||||||
|
keys[which] = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int getKey(const int which)
|
||||||
|
{
|
||||||
|
return keys[which];
|
||||||
|
}
|
||||||
|
}
|
||||||
27
source/config.h
Normal file
27
source/config.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace config
|
||||||
|
{
|
||||||
|
#define SOUND_ALL 0
|
||||||
|
#define SOUND_BASIC 1
|
||||||
|
#define SOUND_NONE 2
|
||||||
|
|
||||||
|
#define KEY_UP 0
|
||||||
|
#define KEY_DOWN 1
|
||||||
|
#define KEY_LEFT 2
|
||||||
|
#define KEY_RIGHT 3
|
||||||
|
#define KEY_JUMP 4
|
||||||
|
#define KEY_PICK 5
|
||||||
|
|
||||||
|
void setMusic(const bool value);
|
||||||
|
void toggleMusic();
|
||||||
|
const bool isMusicEnabled();
|
||||||
|
|
||||||
|
void setSound(const int value);
|
||||||
|
void toggleSound();
|
||||||
|
const int getSoundMode();
|
||||||
|
|
||||||
|
void defineKey(const int which, const int key);
|
||||||
|
const int getKey(const int which);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "room.h"
|
#include "room.h"
|
||||||
#include "actor.h"
|
#include "actor.h"
|
||||||
#include "jgame.h"
|
#include "jgame.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
namespace console
|
namespace console
|
||||||
{
|
{
|
||||||
@@ -41,8 +42,9 @@ namespace console
|
|||||||
const char scancode_to_ascii(uint8_t scancode)
|
const char scancode_to_ascii(uint8_t scancode)
|
||||||
{
|
{
|
||||||
if (scancode == SDL_SCANCODE_SPACE) return ' ';
|
if (scancode == SDL_SCANCODE_SPACE) return ' ';
|
||||||
if (scancode == SDL_SCANCODE_0) return '0';
|
if (scancode == SDL_SCANCODE_0 || scancode == SDL_SCANCODE_KP_0) return '0';
|
||||||
if (scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_9) return scancode+19;
|
if (scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_9) return scancode+19;
|
||||||
|
if (scancode >= SDL_SCANCODE_KP_1 && scancode <= SDL_SCANCODE_KP_9) return scancode-40;
|
||||||
if (scancode >= SDL_SCANCODE_A && scancode <= SDL_SCANCODE_Z) return scancode+61;
|
if (scancode >= SDL_SCANCODE_A && scancode <= SDL_SCANCODE_Z) return scancode+61;
|
||||||
|
|
||||||
if (scancode == SDL_SCANCODE_MINUS) return '-';
|
if (scancode == SDL_SCANCODE_MINUS) return '-';
|
||||||
@@ -130,9 +132,11 @@ namespace console
|
|||||||
#define CMD_GOTO 2
|
#define CMD_GOTO 2
|
||||||
#define CMD_MOVE 3
|
#define CMD_MOVE 3
|
||||||
#define CMD_EXIT 4
|
#define CMD_EXIT 4
|
||||||
#define NUM_CMDS 5
|
#define CMD_SHOW 5
|
||||||
|
#define CMD_HIDE 6
|
||||||
|
#define NUM_CMDS 7
|
||||||
|
|
||||||
const char *command_text[NUM_CMDS] = { "GIVE", "DROP", "GOTO", "MOVE", "EXIT" };
|
const char *command_text[NUM_CMDS] = { "GIVE", "DROP", "GOTO", "MOVE", "EXIT", "SHOW", "HIDE" };
|
||||||
|
|
||||||
#define PARAM_UNKNOWN -1
|
#define PARAM_UNKNOWN -1
|
||||||
#define PARAM_RUN 0
|
#define PARAM_RUN 0
|
||||||
@@ -165,6 +169,19 @@ namespace console
|
|||||||
return SDL_atoi(tokens[index]);
|
return SDL_atoi(tokens[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int getIndexFromString(char *str, std::vector<const char*> list)
|
||||||
|
{
|
||||||
|
//static const char *skillset_name[4] = {"SHOES", "GLOVES", "PANTS", "BAG"};
|
||||||
|
for (int i=0;i<list.size();++i)
|
||||||
|
{
|
||||||
|
if (strcmp(str, list[i])==0)
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
void execute_command()
|
void execute_command()
|
||||||
{
|
{
|
||||||
tokenize();
|
tokenize();
|
||||||
@@ -241,6 +258,30 @@ namespace console
|
|||||||
case CMD_EXIT:
|
case CMD_EXIT:
|
||||||
game::exit();
|
game::exit();
|
||||||
break;
|
break;
|
||||||
|
case CMD_SHOW:
|
||||||
|
if (!tokens[1]) {
|
||||||
|
strcpy(msg, "ERROR: Nothing to show.");
|
||||||
|
} else {
|
||||||
|
strcpy(msg, "Ok.");
|
||||||
|
const int value = getIndexFromString(tokens[1], {"NOTHING", "ACTOR-POS"});
|
||||||
|
if (value==-1)
|
||||||
|
strcpy(msg, "ERROR: Cannot show that.");
|
||||||
|
else
|
||||||
|
debug::enable(value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CMD_HIDE:
|
||||||
|
if (!tokens[1]) {
|
||||||
|
strcpy(msg, "ERROR: Nothing to hide.");
|
||||||
|
} else {
|
||||||
|
strcpy(msg, "Ok.");
|
||||||
|
const int value = getIndexFromString(tokens[1], {"NOTHING", "ACTOR-POS"});
|
||||||
|
if (value==-1)
|
||||||
|
strcpy(msg, "ERROR: Cannot hide that.");
|
||||||
|
else
|
||||||
|
debug::disable(value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
cmd_size=0;
|
cmd_size=0;
|
||||||
cmd[cmd_size] = '\0';
|
cmd[cmd_size] = '\0';
|
||||||
|
|||||||
21
source/debug.cpp
Normal file
21
source/debug.cpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
namespace debug
|
||||||
|
{
|
||||||
|
bool debug_info[2] {false, false};
|
||||||
|
|
||||||
|
void enable(int info_type)
|
||||||
|
{
|
||||||
|
debug_info[info_type] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void disable(int info_type)
|
||||||
|
{
|
||||||
|
debug_info[info_type] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool isEnabled(int info_type)
|
||||||
|
{
|
||||||
|
return debug_info[info_type];
|
||||||
|
}
|
||||||
|
}
|
||||||
10
source/debug.h
Normal file
10
source/debug.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace debug
|
||||||
|
{
|
||||||
|
#define DEBUG_ACTOR_POS 1
|
||||||
|
|
||||||
|
void enable(int info_type);
|
||||||
|
void disable(int info_type);
|
||||||
|
const bool isEnabled(int info_type);
|
||||||
|
}
|
||||||
@@ -16,6 +16,10 @@ namespace draw
|
|||||||
SDL_Texture *sdl_texture = nullptr; // La textura de SDL a la que pintarem la nostra superficie "screen" i que despres volcarem a pantalla
|
SDL_Texture *sdl_texture = nullptr; // La textura de SDL a la que pintarem la nostra superficie "screen" i que despres volcarem a pantalla
|
||||||
|
|
||||||
static int screen_zoom = 1;
|
static int screen_zoom = 1;
|
||||||
|
static bool screen_fullscreen = false;
|
||||||
|
static int screen_width = 320;
|
||||||
|
static int screen_height = 240;
|
||||||
|
std::string screen_title = "";
|
||||||
|
|
||||||
surface *screen = nullptr; // La superficie screen, que representa la pantalla. Se crea i destrueix internament
|
surface *screen = nullptr; // La superficie screen, que representa la pantalla. Se crea i destrueix internament
|
||||||
surface *destination = nullptr; // Punter a la actual superficie de destí
|
surface *destination = nullptr; // Punter a la actual superficie de destí
|
||||||
@@ -36,16 +40,20 @@ namespace draw
|
|||||||
int num_managed = 0;
|
int num_managed = 0;
|
||||||
|
|
||||||
// Inicialització de tot el que fa falta per a carregar gràfics i pintar en pantalla
|
// Inicialització de tot el que fa falta per a carregar gràfics i pintar en pantalla
|
||||||
void init(const std::string &titol, const uint16_t width, const uint16_t height, const int zoom)
|
void init(const std::string &titol, const uint16_t width, const uint16_t height, const int zoom, const bool fullscreen)
|
||||||
{
|
{
|
||||||
|
screen_title = titol;
|
||||||
|
screen_fullscreen = fullscreen;
|
||||||
screen_zoom = zoom;
|
screen_zoom = zoom;
|
||||||
|
screen_width = width;
|
||||||
|
screen_height = height;
|
||||||
|
|
||||||
// [TODO] Incloure gestió de pantalla completa
|
// [TODO] Incloure gestió de pantalla completa
|
||||||
|
|
||||||
// Inicialització de les estructures de SDL
|
// Inicialització de les estructures de SDL
|
||||||
sdl_window = SDL_CreateWindow(titol.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width * zoom, height * zoom, SDL_WINDOW_SHOWN);
|
sdl_window = SDL_CreateWindow(screen_title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screen_width * screen_zoom, screen_height * screen_zoom, screen_fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_SHOWN);
|
||||||
sdl_renderer = SDL_CreateRenderer(sdl_window, -1, 0);
|
sdl_renderer = SDL_CreateRenderer(sdl_window, -1, 0);
|
||||||
sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, width, height);
|
sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height);
|
||||||
|
|
||||||
// Establim el tamany "logic", indepndent del tamany de finestra
|
// Establim el tamany "logic", indepndent del tamany de finestra
|
||||||
SDL_RenderSetLogicalSize(sdl_renderer, width, height);
|
SDL_RenderSetLogicalSize(sdl_renderer, width, height);
|
||||||
@@ -97,6 +105,64 @@ namespace draw
|
|||||||
screen = destination = source = nullptr;
|
screen = destination = source = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reinit()
|
||||||
|
{
|
||||||
|
// Destruim tot el relacionat amb SDL
|
||||||
|
SDL_DestroyTexture(sdl_texture);
|
||||||
|
SDL_DestroyRenderer(sdl_renderer);
|
||||||
|
SDL_DestroyWindow(sdl_window);
|
||||||
|
|
||||||
|
const int zoom = screen_fullscreen ? 1 : screen_zoom;
|
||||||
|
sdl_window = SDL_CreateWindow(screen_title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screen_width * zoom, screen_height * zoom, screen_fullscreen?SDL_WINDOW_FULLSCREEN_DESKTOP:SDL_WINDOW_SHOWN);
|
||||||
|
sdl_renderer = SDL_CreateRenderer(sdl_window, -1, 0);
|
||||||
|
sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height);
|
||||||
|
|
||||||
|
// Establim el tamany "logic", indepndent del tamany de finestra
|
||||||
|
SDL_RenderSetLogicalSize(sdl_renderer, screen_width, screen_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setZoom(const int value)
|
||||||
|
{
|
||||||
|
if (value < 1) return;
|
||||||
|
|
||||||
|
SDL_DisplayMode dm;
|
||||||
|
SDL_GetCurrentDisplayMode(0, &dm);
|
||||||
|
|
||||||
|
if (screen_width*value > dm.w) return;
|
||||||
|
if (screen_height*value > dm.h) return;
|
||||||
|
|
||||||
|
screen_zoom = value;
|
||||||
|
reinit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void incZoom()
|
||||||
|
{
|
||||||
|
setZoom(screen_zoom+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void decZoom()
|
||||||
|
{
|
||||||
|
setZoom(screen_zoom-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggleFullscreen()
|
||||||
|
{
|
||||||
|
screen_fullscreen = !screen_fullscreen;
|
||||||
|
reinit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFullscreen(const bool value)
|
||||||
|
{
|
||||||
|
if (screen_fullscreen == value) return;
|
||||||
|
screen_fullscreen = value;
|
||||||
|
reinit();
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool getFullscreen()
|
||||||
|
{
|
||||||
|
return screen_fullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
const int getZoom()
|
const int getZoom()
|
||||||
{
|
{
|
||||||
return screen_zoom;
|
return screen_zoom;
|
||||||
|
|||||||
@@ -31,11 +31,17 @@ namespace draw
|
|||||||
/// @param width es el ample de la finestra "virtual"
|
/// @param width es el ample de la finestra "virtual"
|
||||||
/// @param height es el alt de la finestra "virtual"
|
/// @param height es el alt de la finestra "virtual"
|
||||||
/// @param zoom es com de grans son els pixels.
|
/// @param zoom es com de grans son els pixels.
|
||||||
void init(const std::string &titol, const uint16_t width, const uint16_t height, const int zoom);
|
void init(const std::string &titol, const uint16_t width, const uint16_t height, const int zoom, const bool fullscreen=false);
|
||||||
|
|
||||||
/// @brief Finalització del sistema (tancar coses de SDL, superficies fixes, etc...)
|
/// @brief Finalització del sistema (tancar coses de SDL, superficies fixes, etc...)
|
||||||
void quit();
|
void quit();
|
||||||
|
|
||||||
|
void setZoom(const int value);
|
||||||
|
void incZoom();
|
||||||
|
void decZoom();
|
||||||
|
void toggleFullscreen();
|
||||||
|
void setFullscreen(const bool value);
|
||||||
|
const bool getFullscreen();
|
||||||
const int getZoom();
|
const int getZoom();
|
||||||
|
|
||||||
/// @brief Crea una superficie i torna un punter a ella
|
/// @brief Crea una superficie i torna un punter a ella
|
||||||
|
|||||||
@@ -18,10 +18,11 @@ namespace modules
|
|||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
|
actor::clear(true);
|
||||||
::game::setUpdateTicks(64);
|
::game::setUpdateTicks(64);
|
||||||
|
actor::templates::load();
|
||||||
|
|
||||||
if (editor::isDevMode()) {
|
if (editor::isDevMode()) {
|
||||||
actor::templates::load();
|
|
||||||
|
|
||||||
FILE* f = fopen("data/gifs.txt", "r");
|
FILE* f = fopen("data/gifs.txt", "r");
|
||||||
int buffer_len=255;
|
int buffer_len=255;
|
||||||
|
|||||||
108
source/m_ingame.cpp
Normal file
108
source/m_ingame.cpp
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
#include "m_ingame.h"
|
||||||
|
#include "jgame.h"
|
||||||
|
#include "jinput.h"
|
||||||
|
#include "jdraw.h"
|
||||||
|
#include "actor.h"
|
||||||
|
#include "room.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
|
namespace modules
|
||||||
|
{
|
||||||
|
namespace ingame
|
||||||
|
{
|
||||||
|
draw::surface *surf;
|
||||||
|
int selected_option = INGAME_CONTINUAR;
|
||||||
|
actor::actor_t *parts[6] = {nullptr,nullptr,nullptr,nullptr,nullptr,nullptr};
|
||||||
|
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
selected_option = INGAME_CONTINUAR;
|
||||||
|
|
||||||
|
surf = draw::getSurface("objectes.gif");
|
||||||
|
if (parts[0]==nullptr)
|
||||||
|
{
|
||||||
|
parts[0] = actor::createFromTemplate("P-ELBOW");
|
||||||
|
parts[0]->inner_x=166+16;
|
||||||
|
parts[0]->inner_y=68+8;
|
||||||
|
}
|
||||||
|
if (parts[1]==nullptr)
|
||||||
|
{
|
||||||
|
parts[1] = actor::createFromTemplate("P-PIPE");
|
||||||
|
parts[1]->inner_x=148+16;
|
||||||
|
parts[1]->inner_y=75+8;
|
||||||
|
}
|
||||||
|
if (parts[2]==nullptr)
|
||||||
|
{
|
||||||
|
parts[2] = actor::createFromTemplate("P-SALT");
|
||||||
|
parts[2]->inner_x=123+16;
|
||||||
|
parts[2]->inner_y=84+8;
|
||||||
|
}
|
||||||
|
if (parts[3]==nullptr)
|
||||||
|
{
|
||||||
|
parts[3] = actor::createFromTemplate("P-FILTER");
|
||||||
|
parts[3]->inner_x=144+16;
|
||||||
|
parts[3]->inner_y=45+8;
|
||||||
|
}
|
||||||
|
if (parts[4]==nullptr)
|
||||||
|
{
|
||||||
|
parts[4] = actor::createFromTemplate("P-PUMP");
|
||||||
|
parts[4]->inner_x=121+16;
|
||||||
|
parts[4]->inner_y=54+8;
|
||||||
|
}
|
||||||
|
if (parts[5]==nullptr)
|
||||||
|
{
|
||||||
|
parts[5] = actor::createFromTemplate("P-TIMER");
|
||||||
|
parts[5]->inner_x=96+16;
|
||||||
|
parts[5]->inner_y=69+8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int loop()
|
||||||
|
{
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) {
|
||||||
|
return INGAME_CONTINUAR;
|
||||||
|
}
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_DOWN) || input::keyPressed(config::getKey(KEY_DOWN)))
|
||||||
|
selected_option = (selected_option+1)&1;
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_UP) || input::keyPressed(config::getKey(KEY_UP)))
|
||||||
|
selected_option = (selected_option-1)&1;
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_SPACE) || input::keyPressed(SDL_SCANCODE_RETURN) ||
|
||||||
|
input::keyPressed(config::getKey(KEY_JUMP)) || input::keyPressed(config::getKey(KEY_PICK))) {
|
||||||
|
return selected_option;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw::cls(2);
|
||||||
|
draw::color(1);
|
||||||
|
|
||||||
|
draw::setSource(surf);
|
||||||
|
static int part[6] = { PART_ELBOW, PART_PIPE, PART_SALT, PART_FILTER, PART_PUMP, PART_TIMER};
|
||||||
|
for (int i=0;i<6;++i)
|
||||||
|
{
|
||||||
|
draw::swapcol(1, room::getColor((actor::hero::getParts() & part[i])?1:3));
|
||||||
|
actor::drawAt(parts[i], parts[i]->inner_x, parts[i]->inner_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
draw::print2("PAUSA", 17, 3, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
|
|
||||||
|
switch (selected_option)
|
||||||
|
{
|
||||||
|
case INGAME_CONTINUAR:
|
||||||
|
draw::print2("fg CONTINUAR", 13, 19, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
|
draw::print2("de EIXIR", 13, 22, TEAL, FONT_ZOOM_NONE);
|
||||||
|
break;
|
||||||
|
case INGAME_EIXIR:
|
||||||
|
draw::print2("de CONTINUAR", 13, 19, TEAL, FONT_ZOOM_NONE);
|
||||||
|
draw::print2("fg EIXIR", 13, 21, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
draw::print2("(C) JAILDOCTOR 2024", 11, 28, TEAL, FONT_ZOOM_NONE);
|
||||||
|
|
||||||
|
draw::render();
|
||||||
|
return INGAME_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
source/m_ingame.h
Normal file
14
source/m_ingame.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace modules
|
||||||
|
{
|
||||||
|
namespace ingame
|
||||||
|
{
|
||||||
|
#define INGAME_NONE -1
|
||||||
|
#define INGAME_CONTINUAR 0
|
||||||
|
#define INGAME_EIXIR 1
|
||||||
|
|
||||||
|
void init();
|
||||||
|
int loop();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "m_logo.h"
|
#include "m_logo.h"
|
||||||
#include "jdraw.h"
|
#include "jdraw.h"
|
||||||
#include "jinput.h"
|
#include "jinput.h"
|
||||||
|
#include "config.h"
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
namespace modules
|
namespace modules
|
||||||
@@ -56,7 +57,9 @@ namespace modules
|
|||||||
{
|
{
|
||||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE) ||
|
if (input::keyPressed(SDL_SCANCODE_ESCAPE) ||
|
||||||
input::keyPressed(SDL_SCANCODE_SPACE) ||
|
input::keyPressed(SDL_SCANCODE_SPACE) ||
|
||||||
input::keyPressed(SDL_SCANCODE_RETURN) ) {
|
input::keyPressed(SDL_SCANCODE_RETURN) ||
|
||||||
|
input::keyPressed(config::getKey(KEY_JUMP)) ||
|
||||||
|
input::keyPressed(config::getKey(KEY_PICK)) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "jgame.h"
|
#include "jgame.h"
|
||||||
#include "jinput.h"
|
#include "jinput.h"
|
||||||
#include "jdraw.h"
|
#include "jdraw.h"
|
||||||
|
#include "config.h"
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
namespace modules
|
namespace modules
|
||||||
@@ -16,9 +17,11 @@ namespace modules
|
|||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
|
selected_option = OPTION_JUGAR;
|
||||||
::game::setUpdateTicks(64);
|
::game::setUpdateTicks(64);
|
||||||
draw::loadPalette("test.gif");
|
draw::loadPalette("test.gif");
|
||||||
surf = draw::getSurface("test.gif");
|
surf = draw::getSurface("test.gif");
|
||||||
|
draw::restorecol(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int loop()
|
int loop()
|
||||||
@@ -26,10 +29,15 @@ namespace modules
|
|||||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) {
|
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) {
|
||||||
return OPTION_EIXIR;
|
return OPTION_EIXIR;
|
||||||
}
|
}
|
||||||
if (input::keyPressed(SDL_SCANCODE_DOWN)) selected_option = (selected_option+1)&3;
|
if (input::keyPressed(SDL_SCANCODE_DOWN) || input::keyPressed(config::getKey(KEY_DOWN)))
|
||||||
if (input::keyPressed(SDL_SCANCODE_UP)) selected_option = (selected_option-1)&3;
|
selected_option = (selected_option+1)&3;
|
||||||
if (input::keyPressed(SDL_SCANCODE_SPACE) || input::keyPressed(SDL_SCANCODE_RETURN)) {
|
|
||||||
if (selected_option == OPTION_EIXIR || selected_option == OPTION_JUGAR) return selected_option;
|
if (input::keyPressed(SDL_SCANCODE_UP) || input::keyPressed(config::getKey(KEY_UP)))
|
||||||
|
selected_option = (selected_option-1)&3;
|
||||||
|
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_SPACE) || input::keyPressed(SDL_SCANCODE_RETURN) ||
|
||||||
|
input::keyPressed(config::getKey(KEY_JUMP)) || input::keyPressed(config::getKey(KEY_PICK))) {
|
||||||
|
return selected_option;
|
||||||
}
|
}
|
||||||
|
|
||||||
draw::cls(2);
|
draw::cls(2);
|
||||||
@@ -37,7 +45,7 @@ namespace modules
|
|||||||
|
|
||||||
draw::swapcol(1, WHITE);
|
draw::swapcol(1, WHITE);
|
||||||
draw::setSource(surf);
|
draw::setSource(surf);
|
||||||
draw::draw(142,48,20,32,64+anim_pos*20,32);
|
draw::draw(150,56,20,32,64+anim_pos*20,32);
|
||||||
retras--;
|
retras--;
|
||||||
if (retras==0) {retras=4; anim_pos=(anim_pos+1)&1; }
|
if (retras==0) {retras=4; anim_pos=(anim_pos+1)&1; }
|
||||||
|
|
||||||
@@ -46,28 +54,28 @@ namespace modules
|
|||||||
switch (selected_option)
|
switch (selected_option)
|
||||||
{
|
{
|
||||||
case OPTION_JUGAR:
|
case OPTION_JUGAR:
|
||||||
draw::print2("fg JUGAR AL JOC", 11, 12, YELLOW, FONT_ZOOM_VERTICAL);
|
draw::print2("fg JUGAR AL JOC", 11, 14, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
draw::print2("de REDEFINIR TECLES", 11, 15, TEAL, FONT_ZOOM_NONE);
|
draw::print2("de REDEFINIR TECLES", 11, 17, TEAL, FONT_ZOOM_NONE);
|
||||||
draw::print2("de CONFIGURAR SO", 11, 17, TEAL, FONT_ZOOM_NONE);
|
draw::print2("de CONFIGURAR AUDIO", 11, 19, TEAL, FONT_ZOOM_NONE);
|
||||||
draw::print2("de EIXIR", 11, 19, TEAL, FONT_ZOOM_NONE);
|
draw::print2("de EIXIR", 11, 21, TEAL, FONT_ZOOM_NONE);
|
||||||
break;
|
break;
|
||||||
case OPTION_TECLES:
|
case OPTION_TECLES:
|
||||||
draw::print2("de JUGAR AL JOC", 11, 12, TEAL, FONT_ZOOM_NONE);
|
draw::print2("de JUGAR AL JOC", 11, 14, TEAL, FONT_ZOOM_NONE);
|
||||||
draw::print2("fg REDEFINIR TECLES", 11, 14, YELLOW, FONT_ZOOM_VERTICAL);
|
draw::print2("fg REDEFINIR TECLES", 11, 16, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
draw::print2("de CONFIGURAR SO", 11, 17, TEAL, FONT_ZOOM_NONE);
|
draw::print2("de CONFIGURAR AUDIO", 11, 19, TEAL, FONT_ZOOM_NONE);
|
||||||
draw::print2("de EIXIR", 11, 19, TEAL, FONT_ZOOM_NONE);
|
draw::print2("de EIXIR", 11, 21, TEAL, FONT_ZOOM_NONE);
|
||||||
break;
|
break;
|
||||||
case OPTION_SO:
|
case OPTION_AUDIO:
|
||||||
draw::print2("de JUGAR AL JOC", 11, 12, TEAL, FONT_ZOOM_NONE);
|
draw::print2("de JUGAR AL JOC", 11, 14, TEAL, FONT_ZOOM_NONE);
|
||||||
draw::print2("de REDEFINIR TECLES", 11, 14, TEAL, FONT_ZOOM_NONE);
|
draw::print2("de REDEFINIR TECLES", 11, 16, TEAL, FONT_ZOOM_NONE);
|
||||||
draw::print2("fg CONFIGURAR SO", 11, 16, YELLOW, FONT_ZOOM_VERTICAL);
|
draw::print2("fg CONFIGURAR AUDIO", 11, 18, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
draw::print2("de EIXIR", 11, 19, TEAL, FONT_ZOOM_NONE);
|
draw::print2("de EIXIR", 11, 21, TEAL, FONT_ZOOM_NONE);
|
||||||
break;
|
break;
|
||||||
case OPTION_EIXIR:
|
case OPTION_EIXIR:
|
||||||
draw::print2("de JUGAR AL JOC", 11, 12, TEAL, FONT_ZOOM_NONE);
|
draw::print2("de JUGAR AL JOC", 11, 14, TEAL, FONT_ZOOM_NONE);
|
||||||
draw::print2("de REDEFINIR TECLES", 11, 14, TEAL, FONT_ZOOM_NONE);
|
draw::print2("de REDEFINIR TECLES", 11, 16, TEAL, FONT_ZOOM_NONE);
|
||||||
draw::print2("de CONFIGURAR SO", 11, 16, TEAL, FONT_ZOOM_NONE);
|
draw::print2("de CONFIGURAR AUDIO", 11, 18, TEAL, FONT_ZOOM_NONE);
|
||||||
draw::print2("fg EIXIR", 11, 18, YELLOW, FONT_ZOOM_VERTICAL);
|
draw::print2("fg EIXIR", 11, 21, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace modules
|
|||||||
#define OPTION_NONE -1
|
#define OPTION_NONE -1
|
||||||
#define OPTION_JUGAR 0
|
#define OPTION_JUGAR 0
|
||||||
#define OPTION_TECLES 1
|
#define OPTION_TECLES 1
|
||||||
#define OPTION_SO 2
|
#define OPTION_AUDIO 2
|
||||||
#define OPTION_EIXIR 3
|
#define OPTION_EIXIR 3
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|||||||
80
source/m_menu_audio.cpp
Normal file
80
source/m_menu_audio.cpp
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#include "m_menu_audio.h"
|
||||||
|
#include "jgame.h"
|
||||||
|
#include "jinput.h"
|
||||||
|
#include "jdraw.h"
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
namespace modules
|
||||||
|
{
|
||||||
|
namespace menu_audio
|
||||||
|
{
|
||||||
|
int selected_option = MENU_AUDIO_MUSICA;
|
||||||
|
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
selected_option = MENU_AUDIO_MUSICA;
|
||||||
|
}
|
||||||
|
|
||||||
|
int loop()
|
||||||
|
{
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) {
|
||||||
|
return MENU_AUDIO_TORNAR;
|
||||||
|
}
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_DOWN) || input::keyPressed(config::getKey(KEY_DOWN)))
|
||||||
|
selected_option = (selected_option==2)?0:selected_option+1;
|
||||||
|
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_UP) || input::keyPressed(config::getKey(KEY_UP)))
|
||||||
|
selected_option = (selected_option==0)?2:selected_option-1;
|
||||||
|
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_SPACE) || input::keyPressed(SDL_SCANCODE_RETURN) ||
|
||||||
|
input::keyPressed(config::getKey(KEY_JUMP)) || input::keyPressed(config::getKey(KEY_PICK))) {
|
||||||
|
if (selected_option==MENU_AUDIO_MUSICA) config::toggleMusic();
|
||||||
|
if (selected_option==MENU_AUDIO_SO) config::toggleSound();
|
||||||
|
if (selected_option==MENU_AUDIO_TORNAR) return MENU_AUDIO_TORNAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw::cls(2);
|
||||||
|
draw::color(1);
|
||||||
|
|
||||||
|
draw::print2("CONFIGURAR AUDIO", 13, 3, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
|
|
||||||
|
const char *musica_msg = config::isMusicEnabled() ? "MUSICA: SI" : "MUSICA: NO";
|
||||||
|
const int soundmode=config::getSoundMode();
|
||||||
|
const char *so_msg = soundmode==SOUND_ALL? "SO: TOT" : soundmode==SOUND_BASIC?"SO: BASIC" : "SO: SILENCI";
|
||||||
|
|
||||||
|
int pos = 14;
|
||||||
|
|
||||||
|
if (selected_option==MENU_AUDIO_MUSICA) {
|
||||||
|
draw::print2("fg", 13, pos, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
|
draw::print2(musica_msg, 18, pos, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
|
pos+=3;
|
||||||
|
} else {
|
||||||
|
draw::print2("de", 13, pos, TEAL, FONT_ZOOM_NONE);
|
||||||
|
draw::print2(musica_msg, 18, pos, TEAL, FONT_ZOOM_NONE);
|
||||||
|
pos+=2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selected_option==MENU_AUDIO_SO) {
|
||||||
|
draw::print2("fg", 13, pos, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
|
draw::print2(so_msg, 18, pos, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
|
pos+=3;
|
||||||
|
} else {
|
||||||
|
draw::print2("de", 13, pos, TEAL, FONT_ZOOM_NONE);
|
||||||
|
draw::print2(so_msg, 18, pos, TEAL, FONT_ZOOM_NONE);
|
||||||
|
pos+=2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selected_option==MENU_AUDIO_TORNAR) {
|
||||||
|
draw::print2("fg TORNAR", 13, pos, YELLOW, FONT_ZOOM_VERTICAL);
|
||||||
|
} else {
|
||||||
|
draw::print2("de TORNAR", 13, pos, TEAL, FONT_ZOOM_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
draw::print2("(C) JAILDOCTOR 2024", 11, 28, TEAL, FONT_ZOOM_NONE);
|
||||||
|
|
||||||
|
draw::render();
|
||||||
|
return MENU_AUDIO_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
source/m_menu_audio.h
Normal file
15
source/m_menu_audio.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace modules
|
||||||
|
{
|
||||||
|
namespace menu_audio
|
||||||
|
{
|
||||||
|
#define MENU_AUDIO_NONE -1
|
||||||
|
#define MENU_AUDIO_MUSICA 0
|
||||||
|
#define MENU_AUDIO_SO 1
|
||||||
|
#define MENU_AUDIO_TORNAR 2
|
||||||
|
|
||||||
|
void init();
|
||||||
|
int loop();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +1,58 @@
|
|||||||
#include "jgame.h"
|
#include "jgame.h"
|
||||||
#include "jdraw.h"
|
#include "jdraw.h"
|
||||||
|
#include "jfile.h"
|
||||||
|
#include "jinput.h"
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
#include "m_game.h"
|
#include "m_game.h"
|
||||||
#include "m_menu.h"
|
#include "m_menu.h"
|
||||||
#include "m_logo.h"
|
#include "m_logo.h"
|
||||||
|
#include "m_ingame.h"
|
||||||
|
#include "m_menu_audio.h"
|
||||||
|
|
||||||
#define M_LOGO 0
|
#define M_LOGO 0
|
||||||
#define M_MENU 1
|
#define M_MENU 1
|
||||||
#define M_GAME 2
|
#define M_GAME 2
|
||||||
|
#define M_INGAME 3
|
||||||
|
#define M_MENU_AUDIO 4
|
||||||
|
|
||||||
int current_module = M_LOGO;
|
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()
|
void game::init()
|
||||||
{
|
{
|
||||||
if (game::getParams(1) && strcmp(game::getParams(1), "editor")==0) editor::setDevMode();
|
if (game::getParams(1) && strcmp(game::getParams(1), "editor")==0) editor::setDevMode();
|
||||||
|
|
||||||
if (editor::isDevMode())
|
if (editor::isDevMode())
|
||||||
draw::init("The Pool", 520, 240, 3);
|
draw::init("The Pool", 520, 240, zoom);
|
||||||
else {
|
else {
|
||||||
draw::init("The Pool", 320, 240, 3);
|
loadConfig();
|
||||||
|
draw::init("The Pool", 320, 240, zoom, fullscreen);
|
||||||
console::init();
|
console::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +68,22 @@ void game::init()
|
|||||||
|
|
||||||
bool game::loop()
|
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;
|
int option;
|
||||||
switch(current_module)
|
switch(current_module)
|
||||||
{
|
{
|
||||||
@@ -47,10 +95,25 @@ bool game::loop()
|
|||||||
if (option != OPTION_NONE) {
|
if (option != OPTION_NONE) {
|
||||||
if (option == OPTION_EIXIR) return false;
|
if (option == OPTION_EIXIR) return false;
|
||||||
if (option == OPTION_JUGAR) { modules::game::init(); current_module = M_GAME; }
|
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;
|
break;
|
||||||
case M_GAME:
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user