aboutsummaryrefslogtreecommitdiff
path: root/engines/bladerunner/vector.h
diff options
context:
space:
mode:
authorPeter Kohaut2018-02-18 22:18:41 +0100
committerPeter Kohaut2018-02-18 22:20:16 +0100
commit7090841ccc43c64d5a1d9058071ebccaf6b52fc2 (patch)
tree44fb7798096b66646039a34c6d4756e091bc700b /engines/bladerunner/vector.h
parent1d69120112e16a74a9d101a0d4d9de04196d29de (diff)
downloadscummvm-rg350-7090841ccc43c64d5a1d9058071ebccaf6b52fc2.tar.gz
scummvm-rg350-7090841ccc43c64d5a1d9058071ebccaf6b52fc2.tar.bz2
scummvm-rg350-7090841ccc43c64d5a1d9058071ebccaf6b52fc2.zip
BLADERUNNER: Support for running
Fixed Runciter idle state Fixed movement track delay Basic combat support
Diffstat (limited to 'engines/bladerunner/vector.h')
-rw-r--r--engines/bladerunner/vector.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/engines/bladerunner/vector.h b/engines/bladerunner/vector.h
index d04070f7c5..f3cc1f1e6d 100644
--- a/engines/bladerunner/vector.h
+++ b/engines/bladerunner/vector.h
@@ -143,6 +143,23 @@ inline float cos_1024(int angle1024) {
inline float sin_1024(int angle1024) {
return sin(angle1024 * (M_PI / 512.0f));
}
+
+inline bool lineIntersection(Vector2 a1, Vector2 a2, Vector2 b1, Vector2 b2, Vector2 *intersection) {
+ Vector2 s1(a2.x - a1.x, a2.y - a1.y);
+ Vector2 s2(b2.x - b1.x, b2.y - b1.y);
+
+ float s = (s1.x * (a1.y - b1.y) - s1.y * (a1.x - b1.x)) / (s1.x * s2.y - s2.x * s1.y);
+ float t = (s2.x * (a1.y - b1.y) - s2.y * (a1.x - b1.x)) / (s1.x * s2.y - s2.x * s1.y);
+
+ if (s >= 0.0f && s <= 1.0f && t >= 0.0f && t <= 1.0f) {
+ intersection->x = a1.x + (t * s1.x);
+ intersection->y = a1.y + (t * s1.y);
+ return true;
+ }
+
+ return false; // No collision
+}
+
} // End of namespace BladeRunner
#endif