DEADSOFTWARE

game: disable gfx for server
[d2df-sdl.git] / src / game / g_phys.pas
index ce56afefa1612f45ed881936519955d5b3bc7a0e..3ff102b6e00b3220b8ce658b4cc7666726468820 100644 (file)
@@ -2,8 +2,7 @@
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * the Free Software Foundation, version 3 of the License ONLY.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,8 +17,7 @@ unit g_phys;
 
 interface
 
-uses
-  e_graphics;
+  uses g_base;
 
 type
   PObj = ^TObj;
@@ -32,6 +30,9 @@ type
     // this is purely visual change, it won't affect anything else
     slopeUpLeft: Integer; // left to go
     slopeFramesLeft: Integer; // frames left to go
+    // for frame interpolation
+    oldX, oldY: Integer;
+    procedure lerp(t: Single; out fX, fY: Integer);
   end;
 
 const
@@ -75,14 +76,23 @@ var
 
 implementation
 
-uses
-  g_map, g_basic, Math, g_player, g_console, SysUtils,
-  g_sound, g_gfx, MAPDEF, g_monsters, g_game, utils;
+  uses
+    {$IFDEF ENABLE_GFX}
+      g_gfx,
+    {$ENDIF}
+    g_map, g_basic, Math, g_player, g_console, SysUtils,
+    g_sound, MAPDEF, g_monsters, g_game, utils
+  ;
 
 
 const
   SmoothSlopeFrames = 4;
 
+procedure TObj.lerp(t: Single; out fX, fY: Integer);
+begin
+  fX := nlerp(oldX, X, t);
+  fY := nlerp(oldY, Y, t);
+end;
 
 function g_Obj_StayOnStep(Obj: PObj): Boolean; inline;
 begin
@@ -219,11 +229,13 @@ begin
       g_Sound_PlayExAt('SOUND_GAME_BULK2', Obj^.X, Obj^.Y);
   end;
 
-  g_GFX_Water(Obj^.X+Obj^.Rect.X+(Obj^.Rect.Width div 2),
-              Obj^.Y+Obj^.Rect.Y+(Obj^.Rect.Height div 2),
-              Min(5*(abs(Obj^.Vel.X)+abs(Obj^.Vel.Y)), 50),
-              -Obj^.Vel.X, -Obj^.Vel.Y,
-              Obj^.Rect.Width, 16, Color);
+  {$IFDEF ENABLE_GFX}
+    g_GFX_Water(Obj^.X+Obj^.Rect.X+(Obj^.Rect.Width div 2),
+                Obj^.Y+Obj^.Rect.Y+(Obj^.Rect.Height div 2),
+                Min(5*(abs(Obj^.Vel.X)+abs(Obj^.Vel.Y)), 50),
+                -Obj^.Vel.X, -Obj^.Vel.Y,
+                Obj^.Rect.Width, 16, Color);
+  {$ENDIF}
 end;
 
 
@@ -472,9 +484,10 @@ begin
       //writeln('velocity=(', Obj^.Vel.X, ',', Obj^.Vel.Y, '); acceleration=(', Obj^.Accel.X, ',', Obj^.Accel.Y, ')');
       if (g_Obj_GetSpeedDirF(Obj, dirx, diry, speed)) then
       begin
-        if (speed > 4) then
+        //writeln('SPEED: ', speed);
+        if (speed > 5) then
         begin
-          speed := speed/2.0;
+          speed := speed/1.4;
           Obj^.Vel.X := round(dirx*speed);
           Obj^.Vel.Y := round(diry*speed);
         end;
@@ -483,9 +496,9 @@ begin
       // acceleration
       if (g_Obj_GetAccelDirF(Obj, dirx, diry, speed)) then
       begin
-        if (speed > 4) then
+        if (speed > 5) then
         begin
-          speed := speed/2.0;
+          speed := speed/1.4;
           Obj^.Accel.X := round(dirx*speed);
           Obj^.Accel.Y := round(diry*speed);
         end;