Commit ed788b72 authored by Kevin Balz's avatar Kevin Balz
Browse files

fix dash

parent a133fd43
Pipeline #3340 passed with stage
in 2 minutes and 49 seconds
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
} }
}, },
"Model": { "Model": {
"aid": "model:cube" "aid": "model:drone"
}, },
"Shadowcaster": { "Shadowcaster": {
}, },
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
"off_beat_threshold": 0.0 "off_beat_threshold": 0.0
}, },
"Killable": { "Killable": {
"radius": 0.7 "radius": 1
}, },
"FixedPath": { "FixedPath": {
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
} }
}, },
"Model": { "Model": {
"aid": "model:cube" "aid": "model:drone"
}, },
"Shadowcaster": { "Shadowcaster": {
}, },
...@@ -20,6 +20,6 @@ ...@@ -20,6 +20,6 @@
"FollowTarget": { "FollowTarget": {
}, },
"Killable": { "Killable": {
"radius": 0.7 "radius": 1
} }
} }
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
"Input_controller": {}, "Input_controller": {},
"Player": {}, "Player": {},
"Dash": { "Dash": {
"attack_width": 2 "attack_width": 0.5
}, },
"Stationary_attack": { "Stationary_attack": {
"radius": 3 "radius": 3
......
...@@ -13,8 +13,7 @@ namespace phase_shifter::gameplay { ...@@ -13,8 +13,7 @@ namespace phase_shifter::gameplay {
float attack_width = 1; float attack_width = 1;
bool was_move = false; bool was_move = false;
bool dash = false; bool dash = false;
glm::vec2 last_position;
}; };
sf2_structDef(Dash_comp, attack_width, was_move, dash, last_position); sf2_structDef(Dash_comp, attack_width);
} }
\ No newline at end of file
...@@ -76,16 +76,17 @@ namespace phase_shifter::gameplay { ...@@ -76,16 +76,17 @@ namespace phase_shifter::gameplay {
{ {
for(auto&& [transform, move, dash] : _ecs.list<Transform_comp, Movement_comp, Dash_comp>()) { for(auto&& [transform, move, dash] : _ecs.list<Transform_comp, Movement_comp, Dash_comp>()) {
if((dash.dash || dash.was_move) && move.step_time_left > 0) { if(dash.dash || move.step_time_left > 0) {
//dash //dash
std::cout << "dash" << std::endl;
glm::vec2 position(transform.position.x, transform.position.z); glm::vec2 position(transform.position.x, transform.position.z);
auto movement = position - dash.last_position; auto movement = (position - move.last_position) * 1.1f;
auto angle = std::atan2(movement.y, movement.x); auto angle = std::atan2(movement.y, movement.x);
auto width = glm::length(movement); auto width = glm::length(movement);
auto height = dash.attack_width; auto height = dash.attack_width;
auto center = rotate_point( auto center = rotate_point(
{dash.last_position.x + movement.x / 2, dash.last_position.y + movement.y / 2}, {move.last_position.x + movement.x / 2, move.last_position.y + movement.y / 2},
angle); angle);
glm::vec2 topleft(center.x - width / 2, center.y + height / 2); glm::vec2 topleft(center.x - width / 2, center.y + height / 2);
...@@ -98,10 +99,10 @@ namespace phase_shifter::gameplay { ...@@ -98,10 +99,10 @@ namespace phase_shifter::gameplay {
if(rect_circle_intersects(topleft.x, topleft.y, width, height, circle.x, circle.y, kill.radius)) { if(rect_circle_intersects(topleft.x, topleft.y, width, height, circle.x, circle.y, kill.radius)) {
// calc attack angle // calc attack angle
auto target_dir = glm::vec2(k_transform.position.x, k_transform.position.z) auto target_dir = glm::vec2(k_transform.position.x, k_transform.position.z)
- dash.last_position; - move.last_position;
auto attacker_angle = std::atan2(move.last_step.y, move.last_step.x); auto attacker_angle = std::atan2(move.last_position.y, move.last_position.x);
auto attack_angle = normalize_angle(std::atan2(target_dir.y, target_dir.x) auto attack_angle = normalize_angle(std::atan2(target_dir.y, target_dir.x)
- std::atan2(move.last_step.y, move.last_step.x)); - std::atan2(move.last_position.y, move.last_position.x));
if(attack_angle < (-15_deg).value()) if(attack_angle < (-15_deg).value())
attack_angle = (-45_deg).value(); attack_angle = (-45_deg).value();
...@@ -118,20 +119,10 @@ namespace phase_shifter::gameplay { ...@@ -118,20 +119,10 @@ namespace phase_shifter::gameplay {
} }
} }
dash.last_position = position; dash.dash = move.step_time_left > 0;
dash.dash = true;
} else { } else {
dash.dash = false; dash.dash = false;
} }
if(move.move) {
if(!dash.was_move || move.step_time_left <= 0) {
dash.was_move = true;
dash.last_position = {transform.position.x, transform.position.z};
}
} else {
dash.was_move = false;
}
} }
} }
} // namespace phase_shifter::gameplay } // namespace phase_shifter::gameplay
...@@ -24,6 +24,7 @@ namespace phase_shifter::gameplay { ...@@ -24,6 +24,7 @@ namespace phase_shifter::gameplay {
float step_time = 0; float step_time = 0;
glm::vec2 last_step; glm::vec2 last_step;
glm::vec2 last_aim; glm::vec2 last_aim;
glm::vec2 last_position;
bool attack = false; bool attack = false;
}; };
......
...@@ -45,7 +45,10 @@ namespace phase_shifter::gameplay { ...@@ -45,7 +45,10 @@ namespace phase_shifter::gameplay {
auto beat = _beat_system.beat_state(); auto beat = _beat_system.beat_state();
for(auto&& [entity, transform, move] : _ecs.list<Entity_facet, Transform_comp, Movement_comp>()) { for(auto&& [entity, transform, move] : _ecs.list<Entity_facet, Transform_comp, Movement_comp>()) {
if(beat.beat) { move.last_position = {transform.position.x, transform.position.z};
if(beat.beat)
{
move.beats_since_move++; move.beats_since_move++;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment