diff --git a/source/actor.cpp b/source/actor.cpp index 566decb..df44d58 100644 --- a/source/actor.cpp +++ b/source/actor.cpp @@ -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 templates; diff --git a/source/actor.h b/source/actor.h index 9119cf0..6fece4f 100644 --- a/source/actor.h +++ b/source/actor.h @@ -179,6 +179,8 @@ namespace actor const bool getFloatingEditing(); + void pauseWalkSound(); + namespace templates { void load(); diff --git a/source/console.cpp b/source/console.cpp index e06d546..b934b5d 100644 --- a/source/console.cpp +++ b/source/console.cpp @@ -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; } diff --git a/source/debug.cpp b/source/debug.cpp index 2ec0959..bd047ed 100644 --- a/source/debug.cpp +++ b/source/debug.cpp @@ -2,7 +2,7 @@ namespace debug { - bool debug_info[2] {false, false}; + bool debug_info[3] {false, false, false}; void enable(int info_type) { diff --git a/source/debug.h b/source/debug.h index b221ac5..ff0943d 100644 --- a/source/debug.h +++ b/source/debug.h @@ -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); diff --git a/source/m_game.cpp b/source/m_game.cpp index 3eeb47d..e456025 100644 --- a/source/m_game.cpp +++ b/source/m_game.cpp @@ -298,6 +298,8 @@ namespace modules console::toggle(); } else { if (room::editor::isModified()) room::editor::save(); + actor::pauseWalkSound(); + return GAME_MENU; } } diff --git a/source/m_ingame.cpp b/source/m_ingame.cpp index 794a0f7..5eebb6d 100644 --- a/source/m_ingame.cpp +++ b/source/m_ingame.cpp @@ -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; } diff --git a/source/m_menu.cpp b/source/m_menu.cpp index 95ae7ac..abab3b5 100644 --- a/source/m_menu.cpp +++ b/source/m_menu.cpp @@ -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; } diff --git a/source/m_menu_gamepad.cpp b/source/m_menu_gamepad.cpp index caa5803..897f025 100644 --- a/source/m_menu_gamepad.cpp +++ b/source/m_menu_gamepad.cpp @@ -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 @@ -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 diff --git a/source/m_menu_tecles.cpp b/source/m_menu_tecles.cpp index 4fcf9e8..66d9739 100644 --- a/source/m_menu_tecles.cpp +++ b/source/m_menu_tecles.cpp @@ -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 @@ -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