Convert the rest of rotated sprites to be rotated by OpenGL
authorunc0rr
Mon, 28 Jan 2008 19:05:29 +0000
changeset 776 8fc7e59d9cb4
parent 775 23c253aae336
child 777 86177328b094
Convert the rest of rotated sprites to be rotated by OpenGL
hedgewars/GSHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
share/hedgewars/Data/Graphics/AirBomb.png
share/hedgewars/Data/Graphics/Bomb.png
share/hedgewars/Data/Graphics/ClBomb.png
share/hedgewars/Data/Graphics/MineOff.png
share/hedgewars/Data/Graphics/MineOn.png
share/hedgewars/Data/Graphics/RopeHook.png
--- a/hedgewars/GSHandlers.inc	Mon Jan 28 18:22:35 2008 +0000
+++ b/hedgewars/GSHandlers.inc	Mon Jan 28 19:05:29 2008 +0000
@@ -51,13 +51,13 @@
 ////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////
 procedure CalcRotationDirAngle(Gear: PGear);
-var dAngle: hwFloat;
+var dAngle: real;
 begin
-dAngle:= (hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) * _0_1;
+dAngle:= (hwAbs(Gear^.dX) + hwAbs(Gear^.dY)).QWordValue / $80000000;
 if not Gear^.dX.isNegative then Gear^.DirAngle:= Gear^.DirAngle + dAngle
                 else Gear^.DirAngle:= Gear^.DirAngle - dAngle;
-if Gear^.DirAngle.isNegative then Gear^.DirAngle:= Gear^.DirAngle + _16
-else if _16 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle - _16
+if Gear^.DirAngle < 0 then Gear^.DirAngle:= Gear^.DirAngle + 360
+else if 360 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle - 360
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -599,7 +599,7 @@
                 begin
                 X:= Gear^.X;
                 Y:= Gear^.Y;
-                if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle32(Gear^.dY, Gear^.dX);
+                if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX);
                 b:= (cc * HHGear^.dY) > (cs * HHGear^.dX);
                 dLen:= len
                 end;
--- a/hedgewars/uConsts.pas	Mon Jan 28 18:22:35 2008 +0000
+++ b/hedgewars/uConsts.pas	Mon Jan 28 19:05:29 2008 +0000
@@ -248,7 +248,7 @@
                      (FileName: 'Clouds'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil;
                       Width: 256; Height:128; saveSurf: false),// sprCloud
                      (FileName:       'Bomb'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
-                      Width:  16; Height: 16; saveSurf: false),// sprBomb
+                      Width:   8; Height:  8; saveSurf: false),// sprBomb
                      (FileName:  'BigDigits'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
                       Width:  32; Height: 32; saveSurf: false),// sprBigDigit
                      (FileName:      'Frame'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
@@ -266,13 +266,13 @@
                      (FileName: 'SmokeTrace'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
                       Width:  32; Height: 32; saveSurf: false),// sprSmokeTrace
                      (FileName:   'RopeHook'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
-                      Width:  32; Height: 32; saveSurf: false),// sprRopeHook
+                      Width:  16; Height: 16; saveSurf: false),// sprRopeHook
                      (FileName:     'Expl50'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
                       Width:  64; Height: 64; saveSurf: false),// sprExplosion50
                      (FileName:    'MineOff'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
-                      Width:  16; Height: 16; saveSurf: false),// sprMineOff
+                      Width:   8; Height:  8; saveSurf: false),// sprMineOff
                      (FileName:     'MineOn'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
-                      Width:  16; Height: 16; saveSurf: false),// sprMineOn
+                      Width:   8; Height:  8; saveSurf: false),// sprMineOn
                      (FileName:       'Case'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
                       Width:  32; Height: 32; saveSurf: false),// sprCase
                      (FileName:   'FirstAid'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
@@ -306,11 +306,11 @@
                      (FileName:     'Finger'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
                       Width:  32; Height: 48; saveSurf: false),// sprFinger
                      (FileName:    'AirBomb'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
-                      Width:  32; Height: 32; saveSurf: false),// sprAirBomb
+                      Width:  16; Height: 16; saveSurf: false),// sprAirBomb
                      (FileName:   'Airplane'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
                       Width: 125; Height: 42; saveSurf: false),// sprAirplane
                      (FileName: 'amAirplane'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
-                      Width:  64; Height: 32; saveSurf: false),// sprAirplane
+                      Width:  64; Height: 32; saveSurf: false),// sprAmAirplane
                      (FileName:   'amGirder'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
                       Width: 160; Height:160; saveSurf:  true),// sprAmGirder
                      (FileName:     'hhMask'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
--- a/hedgewars/uGears.pas	Mon Jan 28 18:22:35 2008 +0000
+++ b/hedgewars/uGears.pas	Mon Jan 28 19:05:29 2008 +0000
@@ -37,7 +37,7 @@
              doStep: TGearStepProcedure;
              Radius: LongInt;
              Angle, Power : Longword;
-             DirAngle: hwFloat;
+             DirAngle: real;
              Timer : LongWord;
              Elasticity: hwFloat;
              Friction  : hwFloat;
@@ -70,10 +70,10 @@
 
 implementation
 uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions,
-     uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers;
+     uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers, GL;
 var RopePoints: record
                 Count: Longword;
-                HookAngle: LongInt;
+                HookAngle: GLfloat;
                 ar: array[0..300] of record
                                   X, Y: hwFloat;
                                   dLen: hwFloat;
@@ -575,9 +575,9 @@
       begin
       case Gear^.Kind of
            gtCloud: DrawSprite(sprCloud   , hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State, Surface);
-       gtAmmo_Bomb: DrawSprite(sprBomb , hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, hwRound(Gear^.DirAngle), Surface);
+       gtAmmo_Bomb: DrawRotated(sprBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.DirAngle);
         gtHedgehog: DrawHH(Gear, Surface);
-    gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, DxDy2Angle(Gear^.dY, Gear^.dX));//DrawSprite(sprGrenade , hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, DxDy2Angle32(Gear^.dY, Gear^.dX), Surface);
+    gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, DxDy2Angle(Gear^.dY, Gear^.dX));
        gtHealthTag,
      gtSmallDamage: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
            gtGrave: DrawSurfSprite(hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex, Surface);
@@ -597,31 +597,31 @@
                                     hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy);
                        DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
                                     hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy);
-                       DrawSprite(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx - 16, hwRound(RopePoints.ar[0].Y) + WorldDy - 16, RopePoints.HookAngle, Surface);
+                       DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, RopePoints.HookAngle)
                        end else
                        begin
                        DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
                                     hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy);
-                       DrawSprite(sprRopeHook, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, DxDy2Angle32(Gear^.dY, Gear^.dX), Surface);
+                       DrawRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, DxDy2Angle(Gear^.dY, Gear^.dX));
                        end;
                     end;
       gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State, Surface);
        gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State, Surface);
             gtMine: if ((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)
-                       then DrawSprite(sprMineOff , hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, hwRound(Gear^.DirAngle), Surface)
-                       else DrawSprite(sprMineOn  , hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, hwRound(Gear^.DirAngle), Surface);
+                       then DrawRotated(sprMineOff, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.DirAngle)
+                       else DrawRotated(sprMineOn, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.DirAngle);
             gtCase: case Gear^.Pos of
                          posCaseAmmo  : DrawSprite(sprCase, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0, Surface);
                          posCaseHealth: DrawSprite(sprFAid, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, (GameTicks shr 6) mod 13, Surface);
                          end;
         gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1, Surface);
-     gtClusterBomb: DrawSprite(sprClusterBomb, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, hwRound(Gear^.DirAngle), Surface);
+     gtClusterBomb: DrawRotated(sprClusterBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.DirAngle);
          gtCluster: DrawSprite(sprClusterParticle, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, 0, Surface);
            gtFlame: DrawSprite(sprFlame, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy,(GameTicks div 128 + Gear^.Angle) mod 8, Surface);
        gtParachute: DrawSprite(sprParachute, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 48 + WorldDy, 0, Surface);
        gtAirAttack: if Gear^.Tag > 0 then DrawSprite(sprAirplane, hwRound(Gear^.X) - 60 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, 0, Surface)
                                      else DrawSprite(sprAirplane, hwRound(Gear^.X) - 60 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, 1, Surface);
-         gtAirBomb: DrawSprite(sprAirBomb , hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, DxDy2Angle32(Gear^.dY, Gear^.dX), Surface);
+         gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, DxDy2Angle(Gear^.dY, Gear^.dX));
         gtSwitcher: DrawSprite(sprSwitch, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 56 + WorldDy, (GameTicks shr 6) mod 12, Surface);
           gtTarget: DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0, Surface);
               end;
Binary file share/hedgewars/Data/Graphics/AirBomb.png has changed
Binary file share/hedgewars/Data/Graphics/Bomb.png has changed
Binary file share/hedgewars/Data/Graphics/ClBomb.png has changed
Binary file share/hedgewars/Data/Graphics/MineOff.png has changed
Binary file share/hedgewars/Data/Graphics/MineOn.png has changed
Binary file share/hedgewars/Data/Graphics/RopeHook.png has changed