I think this is a little more efficient than dxdy, and easier to read. We call DxDy2 a lot, can any of those use Angle/DirAngle?
authornemo
Sat, 17 Mar 2012 14:02:11 -0400
changeset 6788 88036f0e0a92
parent 6787 8a4cd042d191
child 6789 bed473d0aa7d
I think this is a little more efficient than dxdy, and easier to read. We call DxDy2 a lot, can any of those use Angle/DirAngle?
hedgewars/uGearsRender.pas
--- a/hedgewars/uGearsRender.pas	Sat Mar 17 13:16:50 2012 -0400
+++ b/hedgewars/uGearsRender.pas	Sat Mar 17 14:02:11 2012 -0400
@@ -908,6 +908,7 @@
 var
     HHGear: PGear;
     i: Longword;
+    aAngle: real;
     startX, endX, startY, endY: LongInt;
 begin
     if Gear^.Target.X <> NoPointX then
@@ -926,19 +927,12 @@
                   else DrawSprite(sprMolotov, x, y, 8);
 
        gtRCPlane: begin
+                  aangle:= Gear^.Angle * 360 / 4096;
+                  if Gear^.Tag < 0 then aangle:= 360-aangle;
                   Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF);
-                  if Gear^.Tag = -1 then
-                      begin
-                      DrawRotatedF(sprPlane, x, y, 0, -1, DxDy2Angle(Gear^.dX, Gear^.dY) + 90);
-                      Tint($FF, $FF, $FF, $FF);
-                      DrawRotatedF(sprPlane, x, y, 1, -1, DxDy2Angle(Gear^.dX, Gear^.dY) + 90)
-                      end
-                  else
-                      begin
-                      DrawRotatedF(sprPlane, x, y, 0, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
-                      Tint($FF, $FF, $FF, $FF);
-                      DrawRotatedF(sprPlane, x, y, 1, 0, DxDy2Angle(Gear^.dY, Gear^.dX))
-                      end
+                  DrawRotatedF(sprPlane, x, y, 0, Gear^.Tag, aangle - 90);
+                  Tint($FF, $FF, $FF, $FF);
+                  DrawRotatedF(sprPlane, x, y, 1, Gear^.Tag, aangle - 90)
                   end;
        gtBall: DrawRotatedf(sprBalls, x, y, Gear^.Tag,0, Gear^.DirAngle);