hedgewars/uUtils.pas
changeset 4385 f679ffa2dc8c
parent 4380 b78638b36b89
child 4398 36d7e4b6ca81
--- a/hedgewars/uUtils.pas	Sat Nov 20 22:05:01 2010 +0300
+++ b/hedgewars/uUtils.pas	Sat Nov 20 23:08:11 2010 +0300
@@ -41,6 +41,9 @@
 procedure initModule;
 procedure freeModule;
 
+function  GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt;
+function  GetLaunchY(at: TAmmoType; angle: LongInt): LongInt;
+
 implementation
 uses typinfo, Math, uConsts, uVariables, SysUtils;
 
@@ -264,6 +267,24 @@
        ((#$2F800 <= u) and (u >= #$2FA1F)))   // CJK Compatibility Ideographs Supplement *)
 end;
 
+
+function GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt;
+begin
+    if (Ammoz[at].ejectX <> 0) or (Ammoz[at].ejectY <> 0) then
+        GetLaunchX:= sign(dir) * (8 + hwRound(AngleSin(angle) * Ammoz[at].ejectX) + hwRound(AngleCos(angle) * Ammoz[at].ejectY))
+    else
+        GetLaunchX:= 0
+end;
+
+function GetLaunchY(at: TAmmoType; angle: LongInt): LongInt;
+begin
+    if (Ammoz[at].ejectX <> 0) or (Ammoz[at].ejectY <> 0) then
+        GetLaunchY:= hwRound(AngleSin(angle) * Ammoz[at].ejectY) - hwRound(AngleCos(angle) * Ammoz[at].ejectX) - 2
+    else
+        GetLaunchY:= 0
+end;
+
+
 procedure initModule;
 {$IFDEF DEBUGFILE}{$IFNDEF IPHONEOS}var i: LongInt;{$ENDIF}{$ENDIF}
 begin