Baldurs Gate engine question

Started by
13 comments, last by Seriema 22 years, 9 months ago
basically u have a big bitmap like in bg and you outline buildings and objects that the player cannot walk through. there was an article in game development magazine about this for commandos. once u define with polygons where u cant walk u can walk anywhere
Advertisement
Just have your artist friend make black and white bitmaps that match the rendered ones, with white as passable and black as impassible (or the other way around). Then have him scale them down by a factor of, say, 1/4. In your code, divide the character''s position on the screen by 4 to get his position on the collision map (or better, multiply by 0.25). Then, assuming your backgrounds are loaded into memory as 32 bit bitmaps, then (assuming you use bits of bytes (use bitshifting), not bools[which take up a whole byte])your collision maps will be only 0.0078125 the size of the original bitmaps - hardly anything.

Now how do you store individual bits? Make an unsigned char array with dimensions of 1/8 those of your bitmap. Then, each char holds 8 bits. You can use bitshifting to extract a single bit.

Or, you could, as others have suggested, use vectors and polygons. But I really think a simple collision bitmap stored as a *.BMP file and edited in any image editing program would be the easiest way to go.
As the previous poster said, using a b/w bitmap that outlines where you can go and where you can''t would be ideal, and very easy to imlement. That b/w picture is called an alpha channel, similar to using an alpha channel in paint programs.

To extend that idea, you could even use a 16-color bitmap as the virtual collision map. That way, you can have more than just walk/can''t walk. You could do like:

  // #defines are evil, I''m just making a point here#define ATTR_CANT_WALK 0x01;  #define ATTR_WATER     0x02;#define ATTR_POISON    0x04;#define ATTR_SPECIAL   0x08;  


You know, you can make your values mean whatever you want.

-OR-

You could even have multiple 2-color bitmaps, one for each attribute. Like you could have a walk bitmap, and a water bitmap (you could also use this one to know where to draw reflections!) etc ...

The possibilities are endless, and by using a 1/4 or 1/8 scale low-color bitmap(s) as an attribute layer(s) your memory requirements are pretty low.

WOOW!!

THANX!!! I think I get it! I _was_ thinking of making the whole map hex tiles
*sound of flushing toilet*
not anymore!

I''m gonna make the game using the method you guys described, a tile based virtual collision map!
Using vectors like in BG, that seems pretty complicated :/

}+TITANIUM+{
[ ThumbView: Adds thumbnail support for DDS, PCX, TGA and 16 other imagetypes for Windows XP Explorer. ] [ Chocolate peanuts: Brazilian recipe for home made chocolate covered peanuts. Pure coding pleasure. ]

This topic is closed to new replies.

Advertisement