Let's fix our BitMasks
to work better for our purpose.
setupCollisions
method of our Cycle
class, change the line where we set the Into collide mask for self.shieldCN
to this:self.shieldCN.setIntoCollideMask(BitMask32.range(2,3))
CycleClass_03.py
. WorldClass_02.py
to import CycleClass_03.py
instead of CycleClass_02.py
. Then, save it as WorldClass_03.py
and run it from the command prompt. Attempt to collide the cycles together and we'll see that the collision is detected again, like in the following image:Now our cycles can collide with each other again because they share bits on their BitMasks
.
BitMasks
are often misunderstood because they are both an esoteric concept and also largely invisible when being used. We never really see the BitMasks
themselves, just the result of their use. For that reason, we should make certain of our understanding before we move on.
BitMask?
BitMasks?
BitMasks?
BitMasks
allow a collision to occur?0000 0000 0000 0000 0000 0000 0110 0000 0000 0000 0000 0000 0000 0000 0010 1010