Bit arrays?
I am working on a 2D game and I have started to make collision detection. I want to use an array to hold information on whether a pixel is transparent or not. I want to use a bit array. Are bit arrays even possible, or do I need to use memory consuming integer arrays. I was thinking of using GetPixel() to determin if a pixil matches the colorkey, then store the information in the array.
If anyone can answer these questions I would be grateful.
The game I am working on is at http://amicheinteractive.tripod.com
thanks.
Go on an Intense Rampage
Go on an Intense Rampage
As far as I know, the smallest amount of memory you can use in a byte. When you start using bits, you have to mask them out of a byte, and that takes more proccessor time. IMO, unless you were designing it for 1 Ghz computer with only 1mb of ram, you''re best off just using a byte to describe the transparency.
Shoot Pixels Not People
You might want to search for "bit fields" in the MSDN library. There''s a pretty good example of how bit fields work. It is possible to in both C & C++ to define the layout of a structure down to the bit level, instead of using the predefined types.
I''m not sure how the compiler translates this into machine code. Maybe it just uses bit masks internally. It''s something to look into though, if you''re concerned about memory usage and want to pack data tightly together.
I''m not sure how the compiler translates this into machine code. Maybe it just uses bit masks internally. It''s something to look into though, if you''re concerned about memory usage and want to pack data tightly together.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement