Electric Orb (Projectile) - UQcsse3200/2024-studio-2 GitHub Wiki
Overview
The electric orb is shot by Eel enemies, and unlike other projectiles does not damage the player but instead paralyses them (for 2 seconds).
Sprite sheet is:
Electric Orb Implementation
The Electric Orb is mostly implemented in the Projectile Factory, like other projectiles, but does use some functionality outside this to paralyse the player.
Creation of Electric Orb, along with texture and animation:
public static Entity createElectricOrb(Entity target) {
String path = configs.electricOrb.getSpritePath();
TextureAtlas atlas = ServiceLocator.getResourceService().getAsset(path, TextureAtlas.class);
AnimationRenderComponent animator = new AnimationRenderComponent(atlas);
animator.addAnimation("down", 0.25f, Animation.PlayMode.LOOP);
animator.addAnimation("left", 0.25f, Animation.PlayMode.LOOP);
animator.addAnimation("diagonal", 0.25f, Animation.PlayMode.LOOP);
Entity orb = createBaseProjectile(target, configs.electricOrb, 1f, animator, new OrbAnimationController());
orb.setEnemyType(Entity.EnemyType.ELECTRICORB);
return orb;
}
With most of the creation being handled by the Projectile Factory.
In order to paralyse the player, when a collision with the player is detected, a call to the paralyze() method in the player's KeyboardInputComponent is made, stopping the player from being able to move for 2 seconds. This is accomplished by suppressing walk events for the player while they are paralysed. Unparalysing the player is handled by the KeyboardInputComponent, as the Electric Orb is disposed of on collision and hence wouldn't be able to unparalyse the player.