Archived

This topic is now archived and is closed to further replies.

directx animation HOW???

This topic is 6379 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have read the lamothe''s game guru book. He explains the BOB engine in there for animation. I think it is too complicated! Does anybody have a simple way to do animation in directx? Just a way to load several bitmaps in order and that is it. I don''t want any dead state alive state arrays or whatever. THX!

Share this post


Link to post
Share on other sites
To keep the animation simple, you should start out with a surface with the sprite data on it and use the Blt function along with changing your RECT structure to point to the desired data.
sprite.left=0;
sprite.right=64;
sprite.top=0;
sprite.bottom=64;
surf->Blt(&sprite,.....); // sorry too lazy to type =)

Use an array to make a table to the sprite data... that''s your animation sequence table. the alive...state states etc.. are just flags to the sprite structure. I made my own sprite structure to be more comfortable with animation as well.
I hope that helped out.

Share this post


Link to post
Share on other sites
The BOB thing is not terribly good. Make your own one. You only need a structure to contain the x and y positions of the sprite, the current animation frame, when to change etc. Then use Blt or BltFast to render it to the screen every frame.

#pragma twice

Share this post


Link to post
Share on other sites
You''ll need a timer that you can set so that it''s not so fast that you only see a blur. Like this:
    
int timer;
...
if(GetTickCount()%10==1) //adjust this for timing

timer++;
switch(timer)
{
case 1: draw_frame_one();
...
}
if(timer>=last_frame_number)
timer=1;


JoeMont001@aol.com

Share this post


Link to post
Share on other sites
I usually use the vertical sync for a timer. That way I know how many FPS I am theorically going to have.

it goes something like this

while (vsync)
{
//main program loop
}

//but the problem is the computer is waiting for the vsync to do anything. Probably a multithreaded application could work its way around this.

Share this post


Link to post
Share on other sites