Advertisement

DirectDraw problem

Started by December 10, 2002 09:47 AM
13 comments, last by nodoubt 21 years, 11 months ago
I see the AP beat me to it.
-------------Ban KalvinB !
or make a nice background, and blit the background before the sprite.

My compiler generates one error message: "does not compile."
Advertisement
did you want to blt that stuff on top of each other?

Yes, use DDBLTFX to clear the back buffer.

did you add a delay to the loop so that they all wouldn''t appear within milliseconds of each other?
Programmers of the world, UNTIE!
First off, let me say thank you for everyone''s input and it is much appreciated. It is working perfectly now. To think I spent $400 on books this month and I can''t do something as trivial as this.

directrix, I have followed your advice and put it in a loop.
MattS423, I already have a delay in my code, but I''m only using the simple Sleep() function. Do you suggest otherwise?

Thanks again for everything!


I'm a newbie, please don't hurt me!
I suggest you do not use Sleep().
Let the program run as fast as it wants to and base you animations and movement on time. Not frames.


Do this ONCE when starting your program :
maybe you need to link to winmm.lib

ThisTime = timeGetTime();
LastTime = ThisTime;
TimeElapsed = 0;




In your loop:

//update time
LastTime = ThisTime;
ThisTime = timeGetTime();
ElapsedTime = ThisTime-LastTime;

//ElapsedTime now contain the number of milliseconds passed
//since last frame. You can use this information when moving or
//animating objects.

// Say you want to move your sprite 100 pixels to the right
//over a period of 1 second.
// fMySpritePosX must be a float.

fMySpritPosX += 100.0 * (float)((float)ElapsedTime/1000.0);

//same thing with animation, example animation of 10 frames at
//12 animation frames per second
fMySpriteFrame += 12.0 * (float)((float)ElapsedTime/1000.0);
while (fMySpriteFrame >= 10.0)
fMySpriteFrame-= 10.0;

//Now show the sprite (don''t know how you do that).
MySprite.Setpos((int)fMySpritePosX, (int)fMySpritePosY);
MySprite.Draw((int)fMySpriteFrame);

-------------Ban KalvinB !

This topic is closed to new replies.

Advertisement