Author Topic: Regular image update problem  (Read 4409 times)

Waco

  • Jr. Member
  • **
  • Posts: 61
Regular image update problem
« on: November 02, 2009, 07:43:11 pm »
I'm making a game. After several tries it works as follows: The image gets updated every 15ms by a TTimer, the game screen (in a window) moves according to the arrows pressed. When I decrease this time span, it has no effect at all. However, as I increase it, the game really gets slower. I thought it was caused by my processor, which is gradually saying goodbye, but after using TMyDrawingControl from the "How to avoid flickering" tutorial, I doubt it. Does anyone know the cause of this? Thanks in advance.

idog

  • Full Member
  • ***
  • Posts: 121
    • www.idogendel.com (Hebrew)
Re: Regular image update problem
« Reply #1 on: November 03, 2009, 02:12:10 am »
Are you programming on Windows? The regular system TTimer does not support very exact time resolutions - I'd be careful when using it for anything under 50ms. I found EpikTimer to be a very good replacement:

http://wiki.lazarus.freepascal.org/EpikTimer

Another possibility is that your code simply takes about 15ms to draw each screen, in which case no better timer accuracy can help...

Waco

  • Jr. Member
  • **
  • Posts: 61
Re: Regular image update problem
« Reply #2 on: November 03, 2009, 07:29:59 am »
I'll try using this EpikTimer, hope it helps. I'm on Windows, but how long does it take to redraw a 400x300 image plus evaluate several fundamental conditions? Even when this is caused by slow drawing, shouldn't have using the TMyDrawingControl helped?

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1225
    • Burdjia
Re: Regular image update problem
« Reply #3 on: November 03, 2009, 10:48:34 am »
If you're making a game I recommend you don't use the LCL (except if you're making the game to learn how to use the LCL, of course ;)).

There are several libraries optimized to create games such as Allegro.pas, SDL and GLScene.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Waco

  • Jr. Member
  • **
  • Posts: 61
Re: Regular image update problem
« Reply #4 on: November 03, 2009, 10:55:41 am »
Thanks for the advice, but my skills classify as very low and I'm just learning, so I doubt I'll be able to use this libraries. However, I can give it a shot, we'll see.

 

TinyPortal © 2005-2018