Archived

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

KlDzny

General structure..?

Recommended Posts

KlDzny    122
Right, I am only a newbie to this DirectX lark but I have been programming Windows for a while. I''ve read the Direct Draw tutorials on this site and they have helped me quite a lot with the basics, like making surfaces and blitting bitmaps etc. However, although I have a decent idea of the general structure of the code, there isn''t anything (that I can find) on this site about blitting tiles to the screen and blitting sprites (with transparent areas). I realise that all the tiles in my (isometric) map should have a z-order and they should be blitted in order so that the items and the player that are placed on the ground are blitted after the ground tiles, to prevent overblitting. Now, I''m not sure whether DirectDraw works the same as Windows in that you have to collect all your window information and draw it all at once in the WM_PAINT message. So, what''s the question? I guess my question is (after all that), how do I blit isometric tiles that are an arbitrary size and how do I blit transparent sprites? I also heard something about ''compiled sprites'' and wondered how this is done as I believe it has some speed advantages. Finally, how do I do animation with a collection of sprites? Thanks in advance... KlDzny "You can be in a minority of one but the truth is still the truth." - Gandhi

Share this post


Link to post
Share on other sites
Leprosy    122
using transparence in blits is pretty easy. first you have to set the color key of the surface - i call my surface image. you would set your color key via

DDCOLORKEY color_key; // used to set color key
color_key.dwColorSpaceLowValue = 0;
color_key.dwColorSpaceHighValue = 0;
image->SetColorKey(DDCKEY_SRCBLT, &color_key);

this would set the transparency color to black.
then when you blit make sure you use the DDBLT_KEYSRC flag

if (FAILED(dest->Blt(&dest_rect, image,
&source_rect,(DDBLT_WAIT | DDBLT_KEYSRC),
NULL)))
return(0);

where dest is the destination surface dest_rect is the destination rectangle, and source_rect is the source rectangle etc. im not sure what your questions about sprites are, you need to pick up a better book/tutorial - i suggest LaMothes book - tricks of the gaming gurus, Sprites just encapsulate a direct draw surface, hasthe surfac point maybe contains it width, height position, and a load and draw function you write your self.

Lep

Share this post


Link to post
Share on other sites
KlDzny    122
Thanks Leprosy...

Yeah, ignore the ''compiled sprites'' bit, it''s a DOS thing. And I am waiting for my ordered copy of LaMothe''s book to arrive...

My new problem is, how do I implement a multi-floor system? I have (for example) the ground- and first-floor of a building in an iso map... Now I don''t want to blt to the same tile more than once for efficiency, so I guess I need a z-order system... However, if I do blt everything in order of the z-order then surely I need to scan ahead to see if I there is going to be another tile that has to be put in that space... Example, I''m about to blt grass (z-order = 0) to a tile and need to see if this is necessary by checking whether a tile of z-order greater than grass is going to go there. I could do it the other way, by starting with the highest z-order but then I need to find out whether a tile position has already been drawn on. I''m so confused, please help...

Thanks in advance,

KlDzny

"You can be in a minority of one but the truth is still the truth." - Gandhi

Share this post


Link to post
Share on other sites
Leprosy    122
I personally use a linked list for different floor levels. for instance each tile has a pointer to another tile (the next level), if there are multiple levels on that tile. Then you have a variable of what level you are currently on. Lets say 4. for each tile you would try to traverse the list 4 times and blit that tile - but some times you dont have 4 floors on a given tile . thats why i use linked list - when traversing the list, if the next node == NULL then blit the furthest node you made it to.

i can clarify more if its unclear
Lep

Share this post


Link to post
Share on other sites