Commit 7bdd592c authored by Tim Scheiber's avatar Tim Scheiber
Browse files

fixed initial rotation of bullets

parent fd00cf88
Pipeline #3349 failed with stage
in 4 minutes and 6 seconds
......@@ -21,7 +21,7 @@
"ContinuousPath": {
},
"Rigid_body": {
"radius": 0.1
"radius": 0.3
},
"Bullet": {}
}
......@@ -171,6 +171,11 @@ namespace phase_shifter::gameplay {
cont_path.direction = bullet_direction;
cont_path.curvature = bullet.curvature;
});
entity.process([=](Movement_comp& move, Continuous_path_comp& cont_path) {
float rad_direction = cont_path.direction * mirrage::util::PI / 180.f;
move.aim.x = std::sin(rad_direction);
move.aim.y = -std::cos(rad_direction);
});
})
.create();
}
......@@ -226,16 +231,21 @@ namespace phase_shifter::gameplay {
glm::vec2 direction1 = stad1.point2 - stad1.point1;
glm::vec2 direction2 = stad2.point2 - stad2.point1;
glm::vec2 eliminator{-direction1.y, direction1.x};
float temp = glm::dot(direction2, eliminator);
if(temp != 0) {
float lambda = glm::dot((stad1.point1 - stad2.point1), eliminator) / temp;
if(lambda >= 0 && lambda <= 1) {
// check for intersection of the line segments
float temp = -direction2.x * direction1.y + direction1.x * direction2.y;
if (temp != 0) {
float s = (-direction1.y * (stad1.point1.x - stad2.point1.x)
+ direction1.x * (stad1.point1.y - stad2.point1.y))
/ temp;
float t = (-direction2.y * (stad1.point1.x - stad2.point1.x)
+ direction2.x * (stad1.point1.y - stad2.point1.y))
/ temp;
if (s >= 0 && s <= 1 && t >= 0 && t <= 1) {
return true;
}
}
// check the distance from each end point to the other line segment
float comb_radius = stad1.radius + stad2.radius;
float length2 = glm::length2(direction1);
......
......@@ -95,7 +95,7 @@ namespace phase_shifter {
.entity_builder("basic_enemy")
.position({20, 0, 15})
.post_create([=](auto entity) {
entity.process([&](gameplay::Fixed_path_comp& fixed_path) { fixed_path.update_path({180}); });
entity.process([&](gameplay::Fixed_path_comp& fixed_path) { fixed_path.update_path({}); });
entity.process([&](gameplay::Shooting_comp& shooting) {
shooting.set_patterns({gameplay::Bulletpattern({{0, 0}})});
});
......@@ -117,8 +117,8 @@ namespace phase_shifter {
_input_system->update(dt);
_level_system->update(dt);
_dash_system->update(dt);
_enemy_system->update(dt);
_stationary_attack_system->update(dt);
_enemy_system->update(dt);
_movement_system->update(dt);
_combat_system->update(dt);
_camera_system->update(dt);
......
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