Today, I made my goal to write a simple Bitmask class. A bit mask is basically just a 2D array of booleans.
The class I made loads in an image, looks at each pixel and any pixel not transparent gets a 1. Any other colors and it gets a 0. Eventually, these will be used for alpha masking and per pixel collision.
Stuff to add to the bitmasks:
- Overlap detection: Report the maximum overlap of two bitmasks for each axis.
- Rewrite in C++, using the Python-C API, so it's more efficient. Right now, using python, each "bit" is really an int, taking up much more space than necessary. If I rewrite in C++, I'll actually be able to use booleans. Of course, that also means I either have to bust out some sort of png library for C++, or send to C++ huge multidemensial arrays. A png library would be much faster, but I'm not familiar with any, so who knows how complicated it could get.
OH! I could use SDL to load and parse the images. And I know SDL. I'll just have to see if you can load in an image without initializing all the root SDL stuff or creating a screen and whatnot.
Monday, September 15, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment