thelukester92 / swift-engine

An entity-component-system game engine built in the Swift programming language.
MIT License
35 stars 7 forks source link

Implement collision masks #61

Open thelukester92 opened 10 years ago

thelukester92 commented 10 years ago

Implement collision masks, so something like this can be done:

physicsBody.collisionCategory = PLAYER
physicsBody.collisionMask = WORLD | ENEMIES | BULLETS
bulletBody.category = BULLETS

Not only does this eliminate a lot of unnecessary checks for the physics system, but it also eliminates checks in the trigger handler (#60) for something like this:

bulletBody.collisionMask = PLAYER
bulletBody.trigger = true
bulletBody.triggerHandler = { player in player.die() }

As opposed to having to make sure that the other entity in the handler is the player.

thelukester92 commented 10 years ago

The tile layer should probably have a special collision mask. Also, need to prevent the same two entities from triggering the same trigger.