Physics: Collision Filtering
Although this does seem quite flexible it has some serious limitations, mostly because the mask and group are just uint32's which seriously minimises the number of masks and group you can have for one game. Originally I was thinking about going through and creating some generic groups e.g.:
The physics system would handle the collision logic, i.e. when there is a collision between a bullet and an enemy an EntityDestroy Message is sent for both of those entities.
There was a lot of bugs that cropped up with this, specifically because my message system is instant i.e. an entity destroy message is sent, the Entity Destruction System will go straight into the handler for this and if the entities was then removed it would cause complications because the physics system is still in a for loop of all the Entities.
To combat this I created a destruction queue and handled this in the update function of the Entity Destruction System.
There were also a lot of random bugs with the entity destruction as I had never really fully tested it that way. The memory was always cleaned up when I closed the program but that was different from choosing an entity in the middle of the container and removing it and all of it's components and the systems it was subscribed to. I also had a similar issue with removing Mesh Instances, I had never actually removed singular instances from the scene before so that had to be implemented.
I got through it all in the end and all seems much better now. Anyway enough talking, here is where it is at:
So there it is, I have what is essentially some of the most basic functionality for Space Invaders:
- Enemy's Dropdown when Colliding with the Boundaries
- Enemy is Destroyed when a bullet hits it.
- Bullet is Destroyed when it collides with an Enemy.
- Player can sideways
- Player can shoot bullets
- Player is restricted by Boundaries
I'm really impressed with how this is going, and I am relieved that I can finally complete a task that I have been receiving e-mail task overdue notifications about for weeks now.
So what's next on the cards?
I am going to plough on, the next few things that I need to look at are:
- Enemy and Player Health and Lives
- Enemy firing ( initially will be pseudo random )
- Dealing with Game State, Level Start, Level Failure, Level Completion