Advertisement

2d animation

Started by January 26, 2003 03:46 AM
3 comments, last by Rhin0tea 21 years, 9 months ago
hello i have a question on time loops and frame rates.First i am using Microsoft Visual C++ 6.0 standard edition the u.k version and i am using DirectX 7. I have managed to make a window and take it over with DirectX to FullScreen mode, i am using the directdraw interface and i have a bitmap loader and i have made an array of surfaces that hold the bitmap images, i have also blited them to the screen. When i run the programme the images flicker to fast. my questioned is how do i slow them down so that one frame is shown every second. this is my first time i have done this and i am not used to time functions if anyone could help or if you know of any good time tutorials then please let me know. Thank you for taking the time to read my post. heres a snippet of my code where i blit them to the screen. //Blit our image to the backbuffer, frame_no is just something to keep track of what frame we want to draw.. //Put the image onto the backbuffer lpDDSBack->BltFast(Player_x,Player_y, Enemy[Frame_no++], NULL, DDBLTFAST_WAIT); //This really should be your last call, it basically displays everything you have //written to the backbuffer on screen. lpDDSPrimary->Flip(NULL, DDFLIP_WAIT); //Now flip the backbuffer to the visible screen We Are Borg, Resistance Is Futile
We Are Borg, Resistance Is Futile
can any one help please

We Are Borg, Resistance Is Futile
We Are Borg, Resistance Is Futile
Advertisement
you have to make a loop that last one second to pass.

t0 = GetTicks();
while (t1 - t0) > 1000){
//actualize the timers
}

draw the image

something like that
if it doesn''t work i''ll check my code next time, ok?
You have to use a timer (an empty loop will be optomized out) use rest(). Look at some of the resources in the resource section here.

The Green Manalishi with the Three Prong Crown
Hey! I wrote a DX 7 DirectDraw sidescroller that I later rewrote to DX 8 Direct3D... so I''ve been over this territory before. And... you say that your images "flicker too fast"? Ugh... I don''t see how that is possible, unless your moving things around strangely. If you have a set scene where everything has its own place, wether your fps (frames-per-second) is 30 or 200, it shouldn''t make any visible difference. IMHO, slowing down the framerate doesn''t sound like a solution to the problem.

What do you have on the screen right now, and how are you drawing them? If I knew this info I would probably be able to help you a bit more. As for the 1 frame/sec question... I would use timeGetTime(). (returns the system uptime in milliseconds)
// make a global variable to store the time the last frame was drawnDWORD LastFrame;// somewhere at the start of your code:LastFrame = timeGetTime();// at the start of your rendering function:// (so the function isn''t run before 1000 seconds are up from// the last time drawn)if(LastFrame + 1000 < timeGetTime()) return;// right after that, to reset the time the frame is drawnLastFrame = timeGetTime();... drawing code ... 


---email--- Tok ----surf----
~The Feature Creep of the Family~
--------------------------~The Feature Creep of the Family~

This topic is closed to new replies.

Advertisement