portal: make shot 2 times faster, add hog movement speed to shot speed (only the part in shot direction, so that aiming is not messed up)
authorsheepluva
Sat, 26 Jun 2010 08:14:53 +0200
changeset 3560 3e51dad04026
parent 3558 86a4437e614b
child 3562 c601630a12d5
portal: make shot 2 times faster, add hog movement speed to shot speed (only the part in shot direction, so that aiming is not messed up)
hedgewars/GSHandlers.inc
--- a/hedgewars/GSHandlers.inc	Fri Jun 25 22:59:31 2010 -0400
+++ b/hedgewars/GSHandlers.inc	Sat Jun 26 08:14:53 2010 +0200
@@ -3386,7 +3386,18 @@
 procedure doStepPortalShot(newPortal: PGear);
 var 
     iterator: PGear;
+    s: hwFloat;
 begin
+    s:= Distance (newPortal^.dX, newPortal^.dY);
+
+    // Adds the hog speed (only that part in/directly against shot direction)
+    // to the shot speed (which we triple previously btw)
+    // (This is done my projecting the hog movement vector onto the shot movement vector and then adding the resulting length
+    // to the scaler)
+    s := _3 * s + (newPortal^.dX * CurrentHedgehog^.Gear^.dX + newPortal^.dY * CurrentHedgehog^.Gear^.dY ) / s;
+    newPortal^.dX := newPortal^.dX * s;
+    newPortal^.dY := newPortal^.dY * s;
+
     newPortal^.IntersectGear := nil;
 
     if CurrentHedgehog <> nil then