DEADSOFTWARE

graphics: lerp flags
[d2df-sdl.git] / src / game / g_map.pas
index 20bfa3bf1bee93ff29bc5471cb86a60cf214941a..570d5e2413c66732c51084fdc17e37e62fc50708 100644 (file)
@@ -54,6 +54,7 @@ type
     CaptureTime: LongWord;
     Animation:   TAnimation;
     Direction:   TDirection;
+    NeedSend:    Boolean;
   end;
 
 function  g_Map_Load(Res: String): Boolean;
@@ -2567,8 +2568,13 @@ begin
         begin
           if gFlags[a].Animation <> nil then gFlags[a].Animation.Update();
 
+          Obj.oldX := Obj.X;
+          Obj.oldY := Obj.Y;
+
           m := g_Obj_Move(@Obj, True, True);
 
+          NeedSend := NeedSend or (Obj.X <> Obj.oldX) or (Obj.Y <> Obj.oldY);
+
           if gTime mod (GAME_TICK*2) <> 0 then Continue;
 
           // Ñîïðîòèâëåíèå âîçäóõà
@@ -3153,6 +3159,9 @@ begin
       Direction := FlagPoints[Flag]^.Direction;
       State := FLAG_STATE_NORMAL;
     end;
+    Obj.oldX := Obj.X;
+    Obj.oldY := Obj.Y;
+    NeedSend := False; // the event will take care of this
     Count := -1;
   end;
 end;
@@ -3160,6 +3169,7 @@ end;
 procedure g_Map_DrawFlags();
 var
   i, dx: Integer;
+  tx, ty: Integer;
   Mirror: TMirrorType;
 begin
   if gGameSettings.GameMode <> GM_CTF then
@@ -3172,6 +3182,8 @@ begin
         if State = FLAG_STATE_NONE then
           continue;
 
+        Obj.lerp(gLerpFactor, tx, ty);
+
         if Direction = TDirection.D_LEFT then
           begin
             Mirror := TMirrorType.Horizontal;
@@ -3183,7 +3195,7 @@ begin
             dx := 1;
           end;
 
-        Animation.Draw(Obj.X+dx, Obj.Y+1, Mirror);
+        Animation.Draw(tx+dx, ty+1, Mirror);
 
         if g_debug_Frames then
         begin