just saying thank you

Coly

LOMCN Developer
Developer
Mar 31, 2005
1,399
33
195
Germany
^^ No Problem with English, my English is not better XD...
The question was only for me, to see how Code has solved the problem ;-)
I self use a Array and Records to reflect the Animation :

Littel Screatchie Excemple to understand Syncron Animation Draw and Time under Mir3 :

Code:
type
  TAnimation = record
    aRunFrame   : Byte;
    aMaxFrame   : Byte;
    aRunTime    : LongInt;
    aMaxRunTime : Integer;
  end;

var
  FAnimationArray : array [1..50] of TAnimation;


procedure TimeAnimateArry;
var
  I : Integer;
begin
  for I := 1 to 50 do
    if (GetTickCount - FAnimationArray[I].aRunTime > FAnimationArray[I].aMaxRunTime) then
    begin
      if FAnimationArray[I].aMaxFrame = FAnimationArray[I].aRunFrame then
        FAnimationArray[I].aRunFrame := 0
      else Inc(FAnimationArray[I].aRunFrame);
      FAnimationArray[I].aRunTime := GetTickCount;
    end;
end;


procedure IniteAnimation;
begin
  FillChar(FAnimationArray,49,0);
  FAnimationArray[1].aMaxFrame   := 2;
  FAnimationArray[1].aMaxRunTime := 400;
  FAnimationArray[1].aRunTime    := GetTickCount;

  FAnimationArray[2].aMaxFrame   := 4;
  FAnimationArray[2].aMaxRunTime := 350;
  FAnimationArray[2].aRunTime    := GetTickCount;

  ... 

  FAnimationArray[35].aMaxFrame   := 22;
  FAnimationArray[35].aMaxRunTime := 120;
  FAnimationArray[35].aRunTime    := GetTickCount;

  ...
end;

:::: Create System :::

constructor TRenderEngine.Create;
begin
   inherited Create;
   ...
   IniteAnimation;
end;

:::: in Render Engine  ::::

TimeAnimateArry;
BeginScene;
  ...
EndScene;

^^ I hope it helps a bit...
 

DjDarkBoyZ

Dev
Golden Oldie
Aug 11, 2006
1,065
228
260
127.Ø.Ø.1
Its good ;)
After set the frame image put the drawprocess if you want or in another sub if you want to separate math with drawing.

In this example i see you set the images and times in array manually (in code)
but if your intention is make an animation for editor put the pointers inside the tile(x,y) array and set the parameters when loads the map file.

Advanced note (Depend of the application: editor,game,etc):
For no ReLoading images before drawing you can put a flag when a image is loaded and other flag to put a expiration time using tick, this make a good performance and mantain more free memory.

I hope this serves you ;)
 

Coly

LOMCN Developer
Developer
Mar 31, 2005
1,399
33
195
Germany
Ahmm I don't has show the use in Draw function :

as Excemple:
DrawImag(ImageID + FAnimationArray[MapHeaderAnimationID].aRunFrame);

the Inite in this Excemple is called by create of the Application and not ever.
This System handle all Animation Times from the Game.
One Animation ID has other Frame Time for Animation...
with your System you have only ONE Time to draw Animation.

FAnimationArray[1].aMaxRunTime := 400 <-- this is the time in msec
FAnimationArray[2].aMaxRunTime := 350 and here you see it has other time

The Time Sets I have test and it works very good. On my own MapEditor for my own Game typ, I has so many things running and no lag problems. ;-)
 

DjDarkBoyZ

Dev
Golden Oldie
Aug 11, 2006
1,065
228
260
127.Ø.Ø.1
Lol, no sorry, a mistake understanding me XD
My system explained for animations is not ONE timing, every animated Tile have your own pointers,but depending of the use/application is best to use an external array or inside the (map)tile array.

I only suggest to you to put a (boolean)flag and other things in texture to not ReLoad textures every frame.

Most of these implementations are in MirIV like Light animations (using light proximity), glows, etc

Sorry if you dont understand me ^^ great work Coly ;)
 

Coly

LOMCN Developer
Developer
Mar 31, 2005
1,399
33
195
Germany
I Know, it looks like I change the Image to many, but I can say No, it change only if the Time correct. I need the system like this to Syncron the Animation on the full map.
I believe if you see it in full code, you understand it full :).

For Mir3 Coding, I have ask for a own Section / Thread in Moderator Channel, I hope we get one to have One Place for all the Mir3 Coding things.