Long Range Enemy - UQdeco2800/2021-studio-6 GitHub Wiki

Description

This enemy is a medium sized enemy, which also has the longest range attack of all the enemies. It deals a moderate amount of damage and moves at a moderate pace. Its attack is a long range blood squirt, which follows the player around.

Visual Design

This enemy is a pixelated eye, which was inspired by the images referenced below. This design was chosen as it fits into the gory and creepy theme of the game. Its design includes a singular bloodshot eyeball with a dark outline that floats in the air and rotates. It also has dark red veins and a bright red iris to contribute to the game theme. Additionally, the projectile blood squirt attack also adds to the gory theme of the game.

Sound Effects

The sound chosen to play when this enemy attacks is a squirting/squelching like sound to convey a similar depiction as the graphic created, being an eyeball.

Programming

Being a long range enemy we need it to fire some kind of bullet/projectile at the player. This functionality consists of a few parts

  • Bullet Entity : the actual bullet
  • Enemy AI : how the bullet is fired
  • Collisions : how the bullet interacts with the world

The bullet entity is an entity which resides in the BulletFactory class. When a bullet is desired a createBullet method is called and given a source entity to fire from, a target entity to fire at, and a reference to the current Gamearea which is used to spawn the bullet into the gameworld. The vector calculations are done in this createBullet method to direct the bullet's trajectory from the source to the target. In addition to moving a bullet from a source to a target it is important to note that our bullets are shaped like arrows and need to be rotated to be targeting the player, this is as simple as making sure the texture is pointed in the right cardinal direction then using the Atan2 function to rotate the texture.

Now we have a bullet to fire we need some way for our enemy to fire the bullet. We use the AI Task System existing in the game and create an additional task to fire the bullet. Firing a bullet consists of two steps, an AI task which triggers fire event and a component which listens for the fire event which then calls the createBullet method with the right parameters. There are two AI tasks for firing bullets, one is a simplistic task FireBulletTaskwhich always tracks the player and fires a bullet at a specified duration, there is then a more advanced task DistanceFireBulletTask which takes into account the distance to the player and will only fire within a certain radius.

Our bullets are firing at the player we now need them to collide with the player so we can deal some damage. I have used and already existing hitbox components which allow us to attack the player, I have created a BulletCollider class which handles de-spawning the bullet when it has hit the player

References

Long range enemy: [1]‘Blood Eyeball Cartoon On White Background Stock Illustration - Illustration of cartoon, medicine: 57237111’. https://www.dreamstime.com/stock-illustration-blood-eyeball-cartoon-white-background-halloween-vector-illustration-image57237111 (accessed Aug. 31, 2021).