DXDraw speed

Started by
6 comments, last by patroclus 21 years, 10 months ago
Hi ; I still have the same problem I had months ago. I''m back with a DelphiX game proyect, and I wanted to know how can I make the thing go at a certain speed (no depending on the refresh rate of the monitor on which I''m running the game, as it happends if you set the DXTimer to 0) I try to use a counter in miliseconds in order to wait a certain time before going again into the next Dxtimer routine, and it works but the game doesn''t move as smooth as it should... any help please??
Advertisement
A way to do it and to make sure it runs 'at least' in a certain millisecond speed is to use GetTickCount.

Something you can do is set your timer to 5ms or so, then the first couple lines of your timer should be

  if GetTickCount-TimerTickCount<50 then exit;TimerTickCount:=GetTickCount;  

50 is the ms that you want it to run at least in,
and make sure you declare TimerTickCount in your Unit variables.

Mess around w/ GetTickCount and you might find some other ways to use it.

[edited by - LiquidIce on June 9, 2002 10:33:56 PM]
--LiquidIcegiuliano1@adelphia.netLiquidIce@unholynation.comwww.unholynation.com
In order to make sprites at a certain speed irrespective of the speed of the computer I use the lagcount that is part of the dxtimer.

I take that value put it into an equation that provides me with the number of pixels to move per frame. Less pixels on fast computers more on slow computers. That way a sprite will cover the same distance independent of CPU speed. Is that what you want to achieve?
In reply to LiquidIce :

Yes, I use QueryPerformanceCounter (like GetTickCount, but better I think), and I manage to set the frames per second at a certain speed.
It''s great, but I have a problem, and don''t know why.
The game doesn''t run smoot when I use this (the animations at runtime are not as smooth, and frecuentily it stacks for less than 100ms, but enough to make it look not nice)

Know what I mean??
Thanks
In reply to czar ;

I don''t know how to use Lagcount, could you please tell me a bit about it, and about what equation you use in order to calculate that value.

thank you
The LagCount parameter for the TDXTimer.OnTimer event specifies the number of milliseconds since OnTimer was last called. You usually use this to calculate how far everything needs to be moved in that frame.
[ PGD - The Home of Pascal Game Development! ] [ Help GameDev.net fight cancer ]
Here is a bit of code I use. dx is delta X, thats the number of pixels per second I want to move. Say 100 pixels. The stepsize is a real value containing the number of pixels to move in one frame. Xc is a real that holds the Current X coordinate of my object.

StepSize := dx * (lagcount / 1000); Xc := Xc + StepSize;


I hope that helps



[edited by - czar on June 10, 2002 5:34:09 PM]
Another way use Lagcount is:

DxSprite.Move(LagCount);

this skip moving frames on slowest CPU and play all frames on faster.

This topic is closed to new replies.

Advertisement