If I have a image who’s bounding box is 150x150 pixels, and can not be any smaller, and I wish to do bitmask method pixel level collision detection, should my bitmask be a 150x150 array 1’s and 0’s ? Is making it a short[][] better than an int[][]? Also whats the operation for ANDing two arrays? Im mean is there a short cut method in Java or do I have to write the method (I already know how to mathematically and two arrays).
either a boolean [][], or a 1bpp packed int [][],
dunno which is better, I suspect it depends what you are planning to do with it.
(though I was always taught that java packs boolean, byte and short []'s anyway)
If I am going to AND two areas I guess I ned to use boolenas. So do I have to wrie my own method or does java already have a method to and two boolean areays?
dunno, dont think so.
btw, you don’t have to use booleans to do an AND, you can use any of the integer types.
OK So is it better to use boolean arrays or ints or shorts? If I want to and two two dimentional arrays of size 150x150?
You could try the BitSet class (in java.util). Lets you set/unset bits on an arbitarily large array. Don’t now how efficient it is, but it oculd be worth a look.
Personally for I would be tempted to just use the raw pixel values of an image, and check for transparency. This is what I am doing for selecting units in the RTS I am working on. THis makes sense as I usually have the pixels to hand anyway, so storing the pixels and a bitmask would probably be overkill.
Yeah your right but I ma not storing the pixel data. So I think personally that using a bitmask is better than storing the pixel ata since the bitmask data takes up les space (I think).