- [NEW] Nova debug info: flags

- [NEW] Só de caminar i botar funcionant
- [NEW] Só de enemics rebotant
- [NEW] Menus amb só (MOC MOC!)
- [FIX] El so de caminar ja no continua durant el menu ingame
This commit is contained in:
2024-10-03 16:27:43 +02:00
parent 9ca1e59f44
commit 1251ef5110
10 changed files with 64 additions and 21 deletions

View File

@@ -32,7 +32,6 @@ namespace actor
bool floating_editing = false;
int walk_channel = -1;
int falling_sound = -1;
void resetTag()
{
@@ -858,9 +857,6 @@ namespace actor
{
act->react_mask = 0; // desactivem la guarda (react_mask=0)
act->flags |= FLAG_GRAVITY; // i reactivem el flag de gravetat
if (falling_sound!=-1) { audio::stopChannel(falling_sound); falling_sound = -1; }
falling_sound = audio::playSound("snd_fall.wav", SOUND_ALL, -1);
}
}
@@ -868,7 +864,7 @@ namespace actor
if (moving)
{
act->flags |= FLAG_ANIMATED;
if (act->react_mask==0 && !(act->flags&FLAG_GRAVITY)) audio::resumeChannel(walk_channel);
if (act->react_mask==0 && ( (act->below) || (act->pos.z==0) )) audio::resumeChannel(walk_channel);
}
else
{
@@ -886,6 +882,7 @@ namespace actor
void changeMoving(actor_t *act)
{
audio::playSound("snd_push.wav", SOUND_BASIC);
switch (act->movement)
{
case MOV_X:
@@ -1260,8 +1257,6 @@ namespace actor
// Si estic sobre el piso, no faig res
if (act->pos.z == 0)
{
if (act->flags&FLAG_HERO && falling_sound!=-1) { audio::stopChannel(falling_sound); falling_sound = -1; }
if ((act->flags & FLAG_MOVING) && (act->movement == MOV_Z))
changeMoving(act);
act->push &= ~PUSH_ZN;
@@ -1302,7 +1297,6 @@ namespace actor
// Si sí que hi ha...
if (below)
{
if (act->flags&FLAG_HERO && falling_sound!=-1) { audio::stopChannel(falling_sound); falling_sound = -1; }
// ...el asociem...
act->below = below;
below->above = act;
@@ -1496,6 +1490,13 @@ namespace actor
draw::swapcol(1, room::getColor(0)); // Tornem al color per defecte
}
}
if ((act->flags & FLAG_HERO) && debug::isEnabled(DEBUG_ACTOR_FLAGS))
{
char tmp[100];
draw::print(SDL_itoa(act->flags, tmp, 2), 1, 1, LIGHT + WHITE, BLACK);
draw::swapcol(1, room::getColor(0)); // Tornem al color per defecte
}
if (draw_all && act->next)
draw(act->next);
}
@@ -1671,6 +1672,11 @@ namespace actor
{
return floating_editing;
}
void pauseWalkSound()
{
audio::pauseChannel(walk_channel);
}
namespace templates
{
std::vector<actor_t> templates;

View File

@@ -179,6 +179,8 @@ namespace actor
const bool getFloatingEditing();
void pauseWalkSound();
namespace templates
{
void load();

View File

@@ -264,7 +264,7 @@ namespace console
strcpy(msg, "ERROR: Nothing to show.");
} else {
strcpy(msg, "Ok.");
const int value = getIndexFromString(tokens[1], {"NOTHING", "ACTOR-POS"});
const int value = getIndexFromString(tokens[1], {"NOTHING", "POS", "FLAGS"});
if (value==-1)
strcpy(msg, "ERROR: Cannot show that.");
else
@@ -276,7 +276,7 @@ namespace console
strcpy(msg, "ERROR: Nothing to hide.");
} else {
strcpy(msg, "Ok.");
const int value = getIndexFromString(tokens[1], {"NOTHING", "ACTOR-POS"});
const int value = getIndexFromString(tokens[1], {"NOTHING", "POS", "FLAGS"});
if (value==-1)
strcpy(msg, "ERROR: Cannot hide that.");
else
@@ -309,10 +309,10 @@ namespace console
strcpy(msg, "Exits the game.");
break;
case CMD_SHOW:
strcpy(msg, "NOTHING ACTOR-POS");
strcpy(msg, "NOTHING POS FLAGS");
break;
case CMD_HIDE:
strcpy(msg, "NOTHING ACTOR-POS");
strcpy(msg, "NOTHING POS FLAGS");
break;
}

View File

@@ -2,7 +2,7 @@
namespace debug
{
bool debug_info[2] {false, false};
bool debug_info[3] {false, false, false};
void enable(int info_type)
{

View File

@@ -3,6 +3,7 @@
namespace debug
{
#define DEBUG_ACTOR_POS 1
#define DEBUG_ACTOR_FLAGS 2
void enable(int info_type);
void disable(int info_type);

View File

@@ -298,6 +298,8 @@ namespace modules
console::toggle();
} else {
if (room::editor::isModified()) room::editor::save();
actor::pauseWalkSound();
return GAME_MENU;
}
}

View File

@@ -3,6 +3,7 @@
#include "jinput.h"
#include "controller.h"
#include "jdraw.h"
#include "jaudio.h"
#include "actor.h"
#include "room.h"
#include "config.h"
@@ -18,6 +19,7 @@ namespace modules
void init()
{
selected_option = INGAME_CONTINUAR;
surf = draw::getSurface("objectes.gif");
@@ -71,10 +73,18 @@ namespace modules
return INGAME_CONTINUAR;
}
if (controller::pressed(KEY_DOWN))
{
selected_option = (selected_option+1)&1;
audio::playSound("snd_push.wav", SOUND_BASIC);
}
if (controller::pressed(KEY_UP))
{
selected_option = (selected_option-1)&1;
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK)) {
audio::playSound("snd_push.wav", SOUND_BASIC);
}
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK))
{
audio::playSound("snd_push.wav", SOUND_BASIC);
return selected_option;
}

View File

@@ -33,15 +33,19 @@ namespace modules
}
if (controller::pressed(KEY_DOWN) || input::keyPressed(SDL_SCANCODE_DOWN))
{
audio::playSound("snd_push.wav", SOUND_BASIC);
selected_option++; if (selected_option==5) selected_option=0;
}
if (controller::pressed(KEY_UP) || input::keyPressed(SDL_SCANCODE_UP))
{
audio::playSound("snd_push.wav", SOUND_BASIC);
selected_option--; if (selected_option<0) selected_option=4;
}
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK) || input::keyPressed(SDL_SCANCODE_SPACE) ) {
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK) || input::keyPressed(SDL_SCANCODE_SPACE) )
{
audio::playSound("snd_push.wav", SOUND_BASIC);
return selected_option;
}

View File

@@ -1,6 +1,7 @@
#include "m_menu_gamepad.h"
#include "jdraw.h"
#include "jinput.h"
#include "jaudio.h"
#include "controller.h"
#include "config.h"
#include <SDL2/SDL.h>
@@ -35,12 +36,20 @@ namespace modules
return MENU_GAMEPAD_TORNAR;
}
if (controller::pressed(KEY_DOWN))
{ selected_option++; if (selected_option>6) selected_option=0; }
{
audio::playSound("snd_push.wav", SOUND_BASIC);
selected_option++; if (selected_option>6) selected_option=0;
}
if (controller::pressed(KEY_UP))
{ selected_option--; if (selected_option<0) selected_option=6; }
{
audio::playSound("snd_push.wav", SOUND_BASIC);
selected_option--; if (selected_option<0) selected_option=6;
}
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK)) {
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK))
{
audio::playSound("snd_push.wav", SOUND_BASIC);
if (selected_option==MENU_GAMEPAD_TORNAR)
return MENU_GAMEPAD_TORNAR;
else

View File

@@ -1,6 +1,7 @@
#include "m_menu_tecles.h"
#include "jdraw.h"
#include "jinput.h"
#include "jaudio.h"
#include "controller.h"
#include "config.h"
#include <SDL2/SDL.h>
@@ -44,12 +45,20 @@ namespace modules
return MENU_TECLES_TORNAR;
}
if (controller::pressed(KEY_DOWN) || input::keyPressed(SDL_SCANCODE_DOWN))
{ selected_option++; if (selected_option>6) selected_option=0; }
{
audio::playSound("snd_push.wav", SOUND_BASIC);
selected_option++; if (selected_option>6) selected_option=0;
}
if (controller::pressed(KEY_UP) || input::keyPressed(SDL_SCANCODE_UP))
{ selected_option--; if (selected_option<0) selected_option=6; }
{
audio::playSound("snd_push.wav", SOUND_BASIC);
selected_option--; if (selected_option<0) selected_option=6;
}
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK) || input::keyPressed(SDL_SCANCODE_SPACE)) {
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK) || input::keyPressed(SDL_SCANCODE_SPACE))
{
audio::playSound("snd_push.wav", SOUND_BASIC);
if (selected_option==MENU_TECLES_TORNAR)
return MENU_TECLES_TORNAR;
else