---
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(-)
diff --git a/lib/wormux/include/WORMUX_action.h
b/lib/wormux/include/WORMUX_action.h
index c396fb4..2b9a9c4 100644
--- a/lib/wormux/include/WORMUX_action.h
+++ b/lib/wormux/include/WORMUX_action.h
@@ -86,6 +86,10 @@ public:
ACTION_CHARACTER_STOP_MOVING_LEFT,
ACTION_CHARACTER_START_MOVING_RIGHT,
ACTION_CHARACTER_STOP_MOVING_RIGHT,
+ ACTION_CHARACTER_START_INCREASING_FIRE_ANGLE,
+ ACTION_CHARACTER_STOP_INCREASING_FIRE_ANGLE,
+ ACTION_CHARACTER_START_DECREASING_FIRE_ANGLE,
+ ACTION_CHARACTER_STOP_DECREASING_FIRE_ANGLE,
// ########################################################
// Using Weapon
diff --git a/src/character/character.cpp b/src/character/character.cpp
index 0daba9d..fb695a9 100644
--- a/src/character/character.cpp
+++ b/src/character/character.cpp
@@ -134,6 +134,10 @@ Character::Character (Team& my_team, const std::string
&name, Body *char_body) :
move_left_slowly_pressed(false),
move_right_pressed(false),
move_right_slowly_pressed(false),
+ increase_fire_angle_pressed(false),
+ increase_fire_angle_slowly_pressed(false),
+ decrease_fire_angle_pressed(false),
+ decrease_fire_angle_slowly_pressed(false),
previous_strength(0),
body(NULL)
{
@@ -194,6 +198,10 @@ Character::Character (const Character& acharacter) :
move_left_slowly_pressed(false),
move_right_pressed(false),
move_right_slowly_pressed(false),
+ increase_fire_angle_pressed(false),
+ increase_fire_angle_slowly_pressed(false),
+ decrease_fire_angle_pressed(false),
+ decrease_fire_angle_slowly_pressed(false),
previous_strength(acharacter.previous_strength),
body(NULL)
{
@@ -357,6 +365,10 @@ void Character::Die()
move_left_slowly_pressed = false;
move_right_pressed = false;
move_right_slowly_pressed = false;
+ increase_fire_angle_pressed = false;
+ increase_fire_angle_slowly_pressed = false;
+ decrease_fire_angle_pressed = false;
+ decrease_fire_angle_slowly_pressed = false;
if(death_explosion)
ApplyExplosion(GetCenter(),
GameMode::GetInstance()->death_explosion_cfg);
@@ -539,6 +551,23 @@ void Character::Refresh()
} else if (right && !left) {
Move(DIRECTION_RIGHT, move_right_slowly_pressed);
}
+ bool increase_angle = increase_fire_angle_pressed ||
increase_fire_angle_slowly_pressed;
+ bool decrease_angle = decrease_fire_angle_pressed ||
decrease_fire_angle_slowly_pressed;
+ if (increase_angle && !decrease_angle) {
+ UpdateLastMovingTime();
+ CharacterCursor::GetInstance()->Hide();
+ if (increase_fire_angle_slowly_pressed)
+ AddFiringAngle(DELTA_CROSSHAIR/10.0);
+ else
+ AddFiringAngle(DELTA_CROSSHAIR);
+ } else if (decrease_angle && ! increase_angle) {
+ UpdateLastMovingTime();
+ CharacterCursor::GetInstance()->Hide();
+ if (decrease_fire_angle_slowly_pressed)
+ AddFiringAngle(-DELTA_CROSSHAIR/10.0);
+ else
+ AddFiringAngle(-DELTA_CROSSHAIR);
+ }
}
if (IsGhost()) return;
@@ -841,6 +870,10 @@ void Character::StopPlaying()
move_left_slowly_pressed = false;
move_right_pressed = false;
move_right_slowly_pressed = false;
+ increase_fire_angle_pressed = false;
+ increase_fire_angle_slowly_pressed = false;
+ decrease_fire_angle_pressed = false;
+ decrease_fire_angle_slowly_pressed = false;
}
// Begining of turn or changed to this character
@@ -1058,35 +1091,78 @@ void Character::HandleKeyReleased_MoveLeft(bool slowly)
}
// #################### UP
-void Character::HandleKeyRefreshed_Up(bool slowly)
+void Character::StartDecreasingFireAngle(bool slowly)
{
- HideGameInterface();
+ if (slowly)
+ decrease_fire_angle_slowly_pressed = true;
+ else
+ decrease_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::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
--
1.6.0.4
_______________________________________________
Wormux-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wormux-dev