@@ -169,10 +169,9 @@ Crusher::should_crush()
169
169
170
170
continue ;
171
171
}
172
- else
172
+ else if (!playerbbox. overlaps ( get_detect_box ()))
173
173
{
174
- if (!playerbbox.overlaps (get_detect_box ()))
175
- continue ;
174
+ continue ;
176
175
}
177
176
178
177
RaycastResult result = Sector::get ().get_first_line_intersection (get_bbox ().get_middle (),
@@ -942,18 +941,6 @@ Crusher::update(float dt_sec)
942
941
{
943
942
MovingSprite::update (dt_sec);
944
943
945
- Vector frame_movement;
946
- if (m_state == AWAIT_IDLE)
947
- {
948
- frame_movement = Vector (0 .f , 0 .f );
949
- m_physic.set_velocity (Vector (0 .f , 0 .f ));
950
- }
951
- else
952
- {
953
- frame_movement = m_physic.get_movement (dt_sec);
954
- }
955
- m_col.propagate_movement (frame_movement);
956
-
957
944
const CrusherState old_state = m_state;
958
945
959
946
switch (m_state)
@@ -1002,36 +989,27 @@ Crusher::update(float dt_sec)
1002
989
{
1003
990
brick.break_for_crusher (this );
1004
991
}
1005
- else
992
+ else if ( is_big ())
1006
993
{
1007
- if (is_big ())
1008
- {
1009
- brick.break_for_crusher (this );
1010
- }
994
+ brick.break_for_crusher (this );
1011
995
}
1012
996
}
1013
997
}
1014
998
1015
999
Vector current_velocity = m_physic.get_velocity ();
1016
- if (m_dir_vector.x != 0 .f ) // Horizontal
1000
+ if (m_dir_vector.x != 0 .f && std::abs (current_velocity. x ) > MAX_CRUSH_SPEED ) // Horizontal
1017
1001
{
1018
- if (std::abs (current_velocity.x ) > MAX_CRUSH_SPEED)
1019
- {
1020
- current_velocity.x = std::copysign (MAX_CRUSH_SPEED, current_velocity.x );
1021
- m_physic.set_velocity (current_velocity);
1022
- }
1002
+ current_velocity.x = std::copysign (MAX_CRUSH_SPEED, current_velocity.x );
1003
+ m_physic.set_velocity (current_velocity);
1023
1004
}
1024
- if (m_dir_vector.y != 0 .f ) // Vertical
1005
+ if (m_dir_vector.y != 0 .f && std::abs (current_velocity. y ) > MAX_CRUSH_SPEED ) // Vertical
1025
1006
{
1026
- if (std::abs (current_velocity.y ) > MAX_CRUSH_SPEED)
1027
- {
1028
- current_velocity.y = std::copysign (MAX_CRUSH_SPEED, current_velocity.y );
1029
- m_physic.set_velocity (current_velocity);
1030
- }
1007
+ current_velocity.y = std::copysign (MAX_CRUSH_SPEED, current_velocity.y );
1008
+ m_physic.set_velocity (current_velocity);
1031
1009
}
1032
1010
break ;
1033
1011
}
1034
-
1012
+
1035
1013
case DELAY:
1036
1014
if (m_state_timer.check ())
1037
1015
{
@@ -1052,12 +1030,9 @@ Crusher::update(float dt_sec)
1052
1030
{
1053
1031
idle ();
1054
1032
}
1055
- else
1033
+ else if ( is_recovery_path_clear_of_crushers ())
1056
1034
{
1057
- if (is_recovery_path_clear_of_crushers ())
1058
- {
1059
- recover ();
1060
- }
1035
+ recover ();
1061
1036
}
1062
1037
break ;
1063
1038
@@ -1066,19 +1041,21 @@ Crusher::update(float dt_sec)
1066
1041
break ;
1067
1042
}
1068
1043
1044
+ Vector frame_movement;
1045
+
1069
1046
// Prevent extra movement after idle() sets position.
1070
1047
if (old_state == RECOVERING && m_state == IDLE)
1071
1048
{
1072
1049
frame_movement = Vector (0 .0f , 0 .0f );
1073
1050
}
1074
-
1075
- if (m_state != AWAIT_IDLE)
1051
+ else if (m_state != AWAIT_IDLE)
1076
1052
{
1077
1053
frame_movement = m_physic.get_movement (dt_sec);
1078
1054
}
1079
1055
else
1080
1056
{
1081
1057
frame_movement = Vector (0 .0f , 0 .0f );
1058
+ m_physic.set_velocity (Vector (0 .0f , 0 .0f ));
1082
1059
}
1083
1060
1084
1061
bool in_water = !Sector::get ().is_free_of_tiles (get_bbox (), true , Tile::WATER);
0 commit comments