Tough Long Range Enemy - UQdeco2800/2021-studio-6 GitHub Wiki
Description
This enemy is similar to the long range enemy but instead of firing one bullet it fires three at the same time. One bullet is fired directly at the target, one is rotated up 45 degrees to the straight one and the other is rotated down 45 degrees. Encountering this enemy will add a challenge to the game as there will be more objects to avoid.
Programming
In order to implement this enemy type various functionality is required:
createToughLongRangeEnemy() - This method in NPCFactory creates the enemy with all its components and AI tasks
createToughBullet(Entity source, Entity target, GameArea gameArea) - This method in EnemyBulletFactory spawns the three bullets for the enemy. The rotation for each bullet was based on the theorem:
The straight bullet is based on the functionality for the long range enemy, and then using that theorem the correct rotation can be applied to the other two bullets.
In order for the entity to fire these bullets a a ToughFireBulletListener was created.
References
Brett, M. (2016), Formula for rotating a vector in 2D, https://matthew-brett.github.io/teaching/rotation_2d.html