🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Starting from zero

Started by
4 comments, last by dannyxyz22 24 years, 3 months ago
Since I''ve got a bitmap file with a motion sequence, how can I turn it into a person that moves, using direct draw? Is there a better way, not using the ms directx? Could someone send me the tutorial/samples only from direct draw? I couldn''t get the LONG file on microsoft. Thank ya!
Advertisement
Well, basically, since you''ve already got the "motion sequence" of a bitmap, now you can use what is called animation. This can make the bitmap, whether it be a person, monster, etc. move.

To do this using DirectX, you have to load the bitmap somehow onto an offscreen surface. When doing your drawing, you blit the sequences from the offscreen surface to a secondary buffer surface. Then flip. Repeat.

I hope I helped,
Martin
______________Martin EstevaolpSoftware
Thanks Martin!
That''s useful, but do you have an exemple or source code for this thing?
How would I get specific coordinates on the bitmap.
By the way, why do games we buy don''t come with those bitmaps. I think they use another file type or they code the bitmaps, but I''m not sure. Do you know why we don''t see those files?



Commercial companies tend to package their files into one big file for several reasons:

1) So its harder for people to access the bitmaps directly. After all it is their copyrighted work.

2) To compress the data stored on the computer (like Quake 3 using zip files)

3) Faster access to files. Files can be ordered so that they can be streamed in whilst loading a level instead of relying on the O/S to do random access to the disk.


Mark Allen
Lead Programmer
Tashco Studios
http://www.tashco.com
Hmm...I''ll try to explain it all to you without confusing you with a weird explanation.

Suppose you have 3 bitmaps that form an animation sequence, each 32 pixels in length and 32 pixels in width.

0,0 32 64 96
/*********/ /*********/ /*********/ <--very nice, eh?
/ / / / / /
/ / / / / /
/ / / / / /
/*********/ /*********/ /*********/
32 32 32

Ok, now that we have our very nice bitmap, we have to create a function that "loops" through the animation sequence and BltFast()''s each frame one at a time. In the function, I assume that you''ve already loaded the bitmap file to an offscreensurface called lppdsoffscreen, for example, and created a secondary and primary surface for flipping purposes. It blits the animated sprite to 100, 100.

int num_frames = 3;
int curr_frame = 1;

int draw_next_frame(void)
{
RECT bitmap_in_memory;

if (curr_frame > num_frames)
curr_frame = 1; //Set curr_frame back to first frame

//In this code we establish a RECT that describes which
//frame we want to blit, depending on the current frame.

bitmap_in_memory.left = (curr_frame - 1) * 32;
bitmap_in_memory.top = 0;
bitmap_in_memory.right = curr_frame * 32;
bitmap_in_memory.bottom = 32;

lpddssecondary->BltFast(100, 100, lpddsoffscreen,
&bitmap_in_memory,
DDBLTFAST_NOCOLORKEY);

lpddsprimary->Flip(NULL, DDFLIP_WAIT); //flip

curr_frame++; //go to the next frame. this creates
//the animation.
return(1);
}

Phew! That''s it. You want to call this function somewhere so it is continually processed. Of course, you don''t have to flip from within the function, but I just added it to clarify the whole picture.

I hope I helped,
Martin










______________Martin EstevaolpSoftware
Darn, my ascii bitmap picture turned out really rotten. I hope you still can understand it. The first bitmap starts at 0, 0 and goes to 32, 32. The second is from 32, 0 to 64, 32. The third is from 64, 0 to 96, 32.

Martin
______________Martin EstevaolpSoftware

This topic is closed to new replies.

Advertisement