#include <time.h>
void __fastcall TForm1::MyIdleHandler(TObject *Sender, bool &Done)
{
double timeclick;
timeclick = (float)clock()/CLOCKS_PER_SEC;
Done = false; //Set this so that OnIdle is continuously recalled...
//relocate your bitmap based off of the timeclick variable...
.
.
.
Good luck, and happy programming.Quote:}
> I am new to programming in windows and I am coding a really simple game
> where a 300 x 250 bitmap moves to one side and you try to avoid
> obstacles. Its extremely simple but I cant speed up the animation. I
> tried slicing the image with CopyRect and also redrawing it entirely by
> using an array with all the data every time, but the timer ticks (55mS)
> seem to be very slow for getting an acceptable rate.
> Is there any way of speeding it up with another kind of timer? I have
> John Mianos How-To, where he mentions using a multimedia timer....
> Please any help...
DWORD OldTime = timeGetTime();
...
TimePassed = timeGetTime() - OldTime;
Sprite.Position.x += TimePassed * PixelPerMs;
...
There are also other ways, but this one is very easy to implement (and gives
you good results).
You might also wish to go to www.mr-gamemaker.com. They have a tutorial on
using timers for games.
M.F.
This API function will call a static function at a periodic rate. The
minimum time between events is 1 millisecond.
--
Regards,
Scott
http://www.gnt.net/~heiman
heiman at gnt dot net (don't ya just hate spam)
Thanks in advance
Federico
> Using timeGetTime() would be straight-forward. It gives you the time in
> milliseconds (1/1000 secs). You'd have to include <mmsystem.h>, and animate
> your sprite like this:
> DWORD OldTime = timeGetTime();
> ...
> TimePassed = timeGetTime() - OldTime;
> Sprite.Position.x += TimePassed * PixelPerMs;
> ...
> There are also other ways, but this one is very easy to implement (and gives
> you good results).
> You might also wish to go to www.mr-gamemaker.com. They have a tutorial on
> using timers for games.
> M.F.
> I am new to programming in windows and I am coding a really simple game
> where a 300 x 250 bitmap moves to one side and you try to avoid
> obstacles. Its extremely simple but I cant speed up the animation. I
> tried slicing the image with CopyRect and also redrawing it entirely by
> using an array with all the data every time, but the timer ticks (55mS)
> seem to be very slow for getting an acceptable rate.
> Is there any way of speeding it up with another kind of timer? I have
> John Mianos How-To, where he mentions using a multimedia timer....
> Please any help...
-Evan
Regards,
M.F.
1. 3d and 2d ANIMATIONS (UNREEL ANIMATIONS CO.)
3D AND 2D animatiions and graphics for pc gaming. Inquire by email for
my resume.
Jerry Munday
2913 Wade Ave
Raleigh N.C.
2. Newbie to C++ and MFCs requires Example Program...please.
3. 3D and 2D ANIMATIONS (UNREEL ANIMATIONS CO.)
5. Need help w/ simple simple 2D thing
7. old timers: 3DS4 'fast' processors patch
10. How can hi-quality animations be done ?
11. Who has done water animations?
12. Help with doing SGI animations
13. Those famous animations and how they're done