summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 900602c)
raw | patch | inline | side by side (parent: 900602c)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 17 Jul 2022 11:33:03 +0000 (14:33 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 9 Jun 2023 08:53:47 +0000 (11:53 +0300) |
src/game/g_animations.pas | patch | blob | history |
index efa32ec8e2c5d94ca8886abf344e8a0881a40328..0135b15ec0c2587fd2e734e3dacfaa98951e60a1 100644 (file)
procedure g_Anim_GetFrameFromState (const s: TAnimState; backanim: Boolean; out frame: LongInt);
procedure g_Anim_GetInterplatedFrameFromState (const s: TAnimState; newlength: LongInt; out frame: LongInt);
+ procedure g_Anim_GetTimeFromState (const s: TAnimState; out curtime, fulltime: LongInt);
implementation
ASSERT(frame < newlength);
end;
+ procedure g_Anim_GetTimeFromState (const s: TAnimState; out curtime, fulltime: LongInt);
+ var delay, curframe, curcount: LongInt;
+ begin
+ ASSERT(s.length > 0);
+ (* 1. normalize state values *)
+ delay := MAX(1, s.speed);
+ curframe := MIN(MAX(s.CurrentFrame, 0), s.length - 1);
+ curcount := MIN(MAX(s.CurrentCounter, 0), delay - 1);
+ (* 2. calc current time (normalized) *)
+ fulltime := s.length * delay;
+ curtime := MIN(curframe * delay + curcount, fulltime);
+ end;
+
end.