Florian Köberle a écrit : > --- > lib/wormux/include/WORMUX_action.h | 4 + > src/character/character.cpp | 116 +++++++++++++++++++++++++++++------ > src/character/character.h | 21 +++++-- > src/include/action_handler.cpp | 28 +++++++++ > 4 files changed, 143 insertions(+), 26 deletions(-) > > [...]
> - ActiveTeam().crosshair.Show(); > + if (Network::GetInstance()->IsTurnMaster()) { > + HideGameInterface(); > + ActiveTeam().crosshair.Show(); > + } > +} > I have already seen the same code in a previous patch. Maybe this can be factorized latter. Otherwise, as other patches, it looks good :) I am also thinking of adding a Action::Push(bool), and Action::PopBool() but this is another story ;) > > - if (IsImmobile()) > - { > - UpdateLastMovingTime(); > - CharacterCursor::GetInstance()->Hide(); > - if (slowly) AddFiringAngle(-DELTA_CROSSHAIR/10.0); > - else AddFiringAngle(-DELTA_CROSSHAIR); > - } > +void Character::StopDecreasingFireAngle(bool slowly) > +{ > + if (slowly) > + decrease_fire_angle_slowly_pressed = false; > + else > + decrease_fire_angle_pressed = false; > +} > + > + > +void Character::HandleKeyPressed_Up(bool slowly) > +{ > + Action *a = new > Action(Action::ACTION_CHARACTER_START_DECREASING_FIRE_ANGLE); > + a->Push(slowly ? 1 : 0); > + ActionHandler::GetInstance()->NewAction(a); > +} > + > +void Character::HandleKeyReleased_Up(bool slowly) > +{ > + Action *a = new > Action(Action::ACTION_CHARACTER_STOP_DECREASING_FIRE_ANGLE); > + a->Push(slowly ? 1 : 0); > + ActionHandler::GetInstance()->NewAction(a); > } > > // #################### DOWN > -void Character::HandleKeyRefreshed_Down(bool slowly) > + > + > +void Character::StartIncreasingFireAngle(bool slowly) > { > - HideGameInterface(); > + if (slowly) > + increase_fire_angle_slowly_pressed = true; > + else > + increase_fire_angle_pressed = true; > > - ActiveTeam().crosshair.Show(); > + if (Network::GetInstance()->IsTurnMaster()) { > + HideGameInterface(); > + ActiveTeam().crosshair.Show(); > + } > +} > > - if (IsImmobile()) > - { > - UpdateLastMovingTime(); > - CharacterCursor::GetInstance()->Hide(); > - if (slowly) AddFiringAngle(DELTA_CROSSHAIR/10.0); > - else AddFiringAngle(DELTA_CROSSHAIR); > - } > +void Character::StopIncreasingFireAngle(bool slowly) > +{ > + if (slowly) > + increase_fire_angle_slowly_pressed = false; > + else > + increase_fire_angle_pressed = false; > +} > + > +void Character::HandleKeyPressed_Down(bool slowly) > +{ > + Action *a = new > Action(Action::ACTION_CHARACTER_START_INCREASING_FIRE_ANGLE); > + a->Push(slowly ? 1 : 0); > + ActionHandler::GetInstance()->NewAction(a); > +} > + > +void Character::HandleKeyReleased_Down(bool slowly) > +{ > + Action *a = new > Action(Action::ACTION_CHARACTER_STOP_INCREASING_FIRE_ANGLE); > + a->Push(slowly ? 1 : 0); > + ActionHandler::GetInstance()->NewAction(a); > } > > // #################### JUMP > diff --git a/src/character/character.h b/src/character/character.h > index 88436e0..950de4e 100644 > --- a/src/character/character.h > +++ b/src/character/character.h > @@ -87,6 +87,10 @@ private: > bool move_left_slowly_pressed; > bool move_right_pressed; > bool move_right_slowly_pressed; > + bool increase_fire_angle_pressed; > + bool increase_fire_angle_slowly_pressed; > + bool decrease_fire_angle_pressed; > + bool decrease_fire_angle_slowly_pressed; > public: > > // Previous strength > @@ -167,6 +171,11 @@ public: > double GetAbsFiringAngle() const { return firing_angle; }; > void SetFiringAngle(double angle); > > + void StartIncreasingFireAngle(bool slowly); > + void StopIncreasingFireAngle(bool slowly); > + void StartDecreasingFireAngle(bool slowly); > + void StopDecreasingFireAngle(bool slowly); > + > // Show hide the Character > void Hide() { hidden = true; }; > void Show() { hidden = false; }; > @@ -235,13 +244,13 @@ public: > void HandleKeyRefreshed_MoveLeft(bool /*slowly*/) {}; > void HandleKeyReleased_MoveLeft(bool slowly); > > - void HandleKeyPressed_Up(bool slowly) { HandleKeyRefreshed_Up(slowly); }; > - void HandleKeyRefreshed_Up(bool slowly); > - void HandleKeyReleased_Up(bool /*slowly*/) const {}; > + void HandleKeyPressed_Up(bool slowly); > + void HandleKeyRefreshed_Up(bool /*slowly*/) {}; > + void HandleKeyReleased_Up(bool slowly); > > - void HandleKeyPressed_Down(bool slowly) { HandleKeyRefreshed_Down(slowly); > }; > - void HandleKeyRefreshed_Down(bool slowly); > - void HandleKeyReleased_Down(bool /*slowly*/) const {}; > + void HandleKeyPressed_Down(bool slowly); > + void HandleKeyRefreshed_Down(bool /*slowly*/) {}; > + void HandleKeyReleased_Down(bool slowly); > > void HandleKeyPressed_Jump(); > void HandleKeyRefreshed_Jump() const {}; > diff --git a/src/include/action_handler.cpp b/src/include/action_handler.cpp > index ae17c3d..e144a2a 100644 > --- a/src/include/action_handler.cpp > +++ b/src/include/action_handler.cpp > @@ -597,6 +597,30 @@ static void Action_Character_StopMovingRight(Action *a) > ActiveCharacter().StopMovingRight(slowly); > } > > +static void Action_Character_StartIncreasingFireAngle(Action *a) > +{ > + bool slowly = a->PopInt(); > + ActiveCharacter().StartIncreasingFireAngle(slowly); > +} > + > +static void Action_Character_StopIncreasingFireAngle(Action *a) > +{ > + bool slowly = a->PopInt(); > + ActiveCharacter().StopIncreasingFireAngle(slowly); > +} > + > +static void Action_Character_StartDecreasingFireAngle(Action *a) > +{ > + bool slowly = a->PopInt(); > + ActiveCharacter().StartDecreasingFireAngle(slowly); > +} > + > +static void Action_Character_StopDecreasingFireAngle(Action *a) > +{ > + bool slowly = a->PopInt(); > + ActiveCharacter().StopDecreasingFireAngle(slowly); > +} > + > static void Action_Weapon_Shoot (Action *a) > { > if (Game::GetInstance()->ReadState() != Game::PLAYING) > @@ -959,6 +983,10 @@ void Action_Handler_Init() > ActionHandler::GetInstance()->Register > (Action::ACTION_CHARACTER_STOP_MOVING_LEFT, "CHARACTER_stop_moving_left", > &Action_Character_StopMovingLeft); > ActionHandler::GetInstance()->Register > (Action::ACTION_CHARACTER_START_MOVING_RIGHT, "CHARACTER_start_moving_right", > &Action_Character_StartMovingRight); > ActionHandler::GetInstance()->Register > (Action::ACTION_CHARACTER_STOP_MOVING_RIGHT, "CHARACTER_stop_moving_right", > &Action_Character_StopMovingRight); > + ActionHandler::GetInstance()->Register > (Action::ACTION_CHARACTER_START_INCREASING_FIRE_ANGLE, > "CHARACTER_start_increasing_fire_angle", > &Action_Character_StartIncreasingFireAngle); > + ActionHandler::GetInstance()->Register > (Action::ACTION_CHARACTER_STOP_INCREASING_FIRE_ANGLE, > "CHARACTER_stop_increasing_fire_angle", > &Action_Character_StopIncreasingFireAngle); > + ActionHandler::GetInstance()->Register > (Action::ACTION_CHARACTER_START_DECREASING_FIRE_ANGLE, > "CHARACTER_start_decreasing_fire_angle", > &Action_Character_StartDecreasingFireAngle); > + ActionHandler::GetInstance()->Register > (Action::ACTION_CHARACTER_STOP_DECREASING_FIRE_ANGLE, > "CHARACTER_stop_decreasing_fire_angle", > &Action_Character_StopDecreasingFireAngle); > > // ######################################################## > // Using Weapon > _______________________________________________ Wormux-dev mailing list Wormux-dev@gna.org https://mail.gna.org/listinfo/wormux-dev