-
Notifications
You must be signed in to change notification settings - Fork 1
Destroying Tiles
Here, you can find details about system of destroying bricks and metal tiles.
When a bullet is fired by robot entity and collides with a bricks or metal tile, it destroys not only these parts of tile which were hit, but also the adjacent ones. This was made to receive the effect close to the same one existing in the original game wherein bricks tiles are destroyable in parts i.e. they can be destroyed partially and from any side, so this may be used as a tactical approach to block enemies leaving the last part perpendicularly to an incoming enemy.
Firstly, after detecting collision between a bullet and bricks or metal tiles, a point of hit is returned. It is adjusted in such a way that a method checks which side bullet came from. Initially, it takes position the same as hit tile. In order to receive good value, one of coordinates must be adjusted for the bullet.
If it comes from vertical side (north or south), then the point has set X coordinate the same as the bullet. However, when it comes from horizontal side (west or east), then the point has adjusted the Y coordinate which is taken from the bullet. This is for setting centered position of overlap box which is made later.
After calculating the centered point of hit, the next step consists of returning size of the overlap box. It works similarly to the previous step, however this time we take into account setting size and adjusting it to receive thin rectangular area. Hit from vertical side means adjusting width - from horizontal, height. In both cases, an appropriate coordinate has set value to the constant adjusted for wider area than bullet can reach to find adjacent tiles making destroying more comfortable.
When both the center and the size for overlap box were adjusted, then overlapping is launched within rectangular area in order to look for hit and adjacent tiles. If found any, then all of them are destroyed.