-
Notifications
You must be signed in to change notification settings - Fork 4
(Tower and Mob) Projectile Mechanics
-
Starting point
-
Speed
- Need to think about a scalable interval
- Fluidity in movement
-
Direction
- Starting off with linear
- Adjustability during movement
- Pivot from starting point with respective angle
-
Collision
- Disappear at contact. Deals damage/Apply effect
- Continues after contact. Deals damage/Apply effect
- Bounce at contact
- Randomised Direction
- Targeting Direction
- Default spacing-value on contact should be adjustable
-
Duplication: Multi‐target Projectiles
- Spacing of duplication
- Direction
-
Size
- Hitbox (of mob/tower)
- Projectiles from both towers and enemies that cause damage
- Projectile animations
- Different projectile types
The projectile looks like this:
To make a projectile, use the spawnProjectile() or spawnMultiProjectile(), which one you use will depend on the number of projectiles you want to spawn. There are several params in each method allowing the creation of projectiles versatility. The following are the params used in the functions to spawn projectiles. The direction param should be one of the following variables: towardsTowers or towardsMobs, which is stored in the ForestGameArea class.
position (Vector2) The position of the Entity that's shooting the projectile.
target (Entity) The enemy entities of the "shooter".
direction (int) The direction the projectile should head towards.
space (int) The space between the projectiles' destination.
speed (Vector2) The speed of the projectiles.
quantity (int) The number of projectiles to spawn.
// Examples:
spawnProjectile(new Vector2(0, 10), player, towardsMobs, new Vector2(2f, 2f));
spawnMultiProjectile(new Vector2(0, 10), ghostking, towardsMobs, 20, new Vector2(2f, 2f), 7);
//Code for each of the functions
private void spawnProjectile(Vector2 position, Entity target, int space, int direction, Vector2 speed) {
Entity Projectile = ProjectileFactory.createFireBall(target, new Vector2(direction, position.y + space), speed);
Projectile.setPosition(position);
spawnEntity(Projectile);
}
private void spawnMultiProjectile(Vector2 position, Entity target, int direction, int space, Vector2 speed, int quantity) {
int half = amount / 2;
for (int i = 0; i < amount; i++) {
spawnProjectile(position, target, space * half, direction, speed);
--half;
}
}