Recent

Author Topic: Trying to use the 'EpikTimer' unit  (Read 13372 times)

mausyo

  • Newbie
  • Posts: 6
Trying to use the 'EpikTimer' unit
« on: February 16, 2010, 10:19:54 am »
Hello guys. I'm rather new to the forum and i consider myself not so experimented at programming but i hope this will change with time.

Recently i was trying to find an effective tool for time measuring in Free Pascal. And i was lucky to find one called EpikTimer developed by the Lazarus team. The problem is downloaded the files and when i try to compile it they don't work. The error i receive is

"Can find unit LResources used by Epiktimer"

And this isn't the only unit missing. If i remove this unit from the header (just experimentally) i get errors that other units are missing.


So i wonder where can i find the units which are missing. Or maybe i'm making a mistake somewhere else. Hope someone will respond to my topic.

PS: here's some info about the unit
 http://wiki.lazarus.freepascal.org/EpikTimer and you can download it here
 http://sourceforge.net/projects/lazarus-ccr/files/EpikTimer/

mausyo

  • Newbie
  • Posts: 6
Re: Trying to use the 'EpikTimer' unit
« Reply #1 on: February 17, 2010, 01:23:22 pm »
nobody ?
c'mon guys i really need some help.  :'( :'(

Wodzu

  • Full Member
  • ***
  • Posts: 171
Re: Trying to use the 'EpikTimer' unit
« Reply #2 on: February 17, 2010, 02:07:59 pm »
Hi mausyo this unit should be in the "YourLazarusPath\lcl" directory.

Check do you have it there?

mausyo

  • Newbie
  • Posts: 6
Re: Trying to use the 'EpikTimer' unit
« Reply #3 on: February 17, 2010, 07:45:49 pm »
I get the same error  :o
The curious thing is when i compile and run the application made by the creator of the unit works like a charm. But mine doesn't want to work at all. And i even saved my application in the same directory with the unit.
Another problem is i can't really get used to the IDE Lazarus. I'm familiar with Freepascal. This one has too many buttons and it's complicated.

In case you are wondering what i need, is a effective delay function which can be microseconds accurate.I must use it for an animation which can run the same way on every computer. I would accept any other solution to my problem. But i searched for days now and haven't find anything.

I tried to write one myself but i can write only short functions which are not effective as well. This is because more complex algorithms goes beyond my knowlegde.


PS: hope the sections where i posted is the right one.

Wodzu

  • Full Member
  • ***
  • Posts: 171
Re: Trying to use the 'EpikTimer' unit
« Reply #4 on: February 18, 2010, 10:00:27 am »
But you haven't answered me the question?

Have you checked Lazarus folder for this unit?

I will be needing this unit for the same pupouse as you so I will check the package by myself and let you know if it works for me.

May I ask what thing you will be animating? Is this some sort of object or an image with different frames?

mausyo

  • Newbie
  • Posts: 6
Re: Trying to use the 'EpikTimer' unit
« Reply #5 on: February 18, 2010, 06:08:35 pm »
Oh sorry. I misunderstood your question. If you are asking about the LResource unit, yes it is in the lcl folder. Tell me if you succed to make it work.

I'm just want to make something similar to this:

Code: [Select]
DelayInSeconds := 8.5; // or any value
 OldTime := ET.Elapse;

 while ((ET.Elapsed - OldTime) < DelayInSeconds) do
 begin
   ET.SystemSleep(10);
 end;

  // DelayInSeconds has elapsed and now you can continue executing the code

But for now i can't make the unit work.

And to answer you on the last question: I'm trying to move an object on the screen, pixel by pixel. And the speed must be the same on every computer.

Wodzu

  • Full Member
  • ***
  • Posts: 171
Re: Trying to use the 'EpikTimer' unit
« Reply #6 on: February 19, 2010, 10:25:21 am »
Hi.

I've tested the component and it works. I've tested it with 0.9.29 Lazarus version under Windows XP. Did you read the readme.txt in the component folder?
Have you installed it without problems?

mausyo, generaly you should not use SystemSleep in such operations. You should avoid sleeping your application. Instead of freezeing the animation you should calculate the framerate and calculate the number of pixels that your object will move depending on the framerate.

Check my example how it should be done:

http://www.afterwarp.net/forum/showthread.php?t=1246&highlight=pixel+collision

This is the example concerning Direct3D and Delphi but the source code is avalaible so you may see the part with the timer.

mausyo

  • Newbie
  • Posts: 6
Re: Trying to use the 'EpikTimer' unit
« Reply #7 on: February 19, 2010, 05:04:42 pm »
I sent you a pm. Please check it  :-[

mausyo

  • Newbie
  • Posts: 6
Re: Trying to use the 'EpikTimer' unit
« Reply #8 on: February 21, 2010, 05:20:41 pm »
Never mind. I used the SDL.dll library and SDL4FreePascal
Here's the code.
Code: [Select]
Program it_works;


Uses SDL, SDL_timer, wincrt,wingraph;


var start,ending,timer:longint;
    ok:boolean;
    i,left:integer;
    gd,gm:smallint;


Begin

   ok:=true;
   gd:=noPalette;
   gm:=mDefault;
   Initgraph(gd,gm,'');
   i:=20;
   SDL_Init (SDL_INIT_Timer) ;
   repeat
   begin
   timer:=SDL_GetTicks mod 100;
   writeln('*',SDL_getTicks);
   PutPixel(30,i,white);
   i:=i+1;
   writeln(5-(SDL_GetTicks mod 100-timer));

   if (SDL_GetTicks mod 100- timer <5) then
       begin
       left:=5-SDL_GetTicks mod 100+timer;
       SDL_delay(left);
       end;


   end;
   until (i=600) ;
   SDL_Quit ;



End.

 

TinyPortal © 2005-2018