-
Notifications
You must be signed in to change notification settings - Fork 0
Instant Buff Pickup Animation
The float animation that occurs after a player picks up a HP booster/HP deplete buff. Common in games and helps the player keep track of what is happening when one of these buffs are collected.
-
BuffFactory
Creates the floating animation as anEntity
-
ForestGameArea
Holds the spawning function to spawn the animation onto the map -
BuffManager
Handles the spawning/despawning of the animation on the map -
FloatTask
Handles the floating movement of the animation
The BuffFactory
class handles the instantiation of the Entity
.
public static Entity createBuffAnimation(BuffManager.BuffPickup pickup, BuffManager manager) {
/* Get the texture for the pickup */
String texture = manager.getPickupTexture(pickup);
AITaskComponent buffComponent = new AITaskComponent().addTask(new FloatTask(new Vector2(0f, 3f)));
Entity buffPickup = new Entity().addComponent(new TextureRenderComponent(texture))
.addComponent(new PhysicsComponent().setBodyType(BodyDef.BodyType.DynamicBody))
.addComponent(new PhysicsMovementComponent())
.addComponent(buffComponent);
The buffPickup
entity has an AITaskComponent
with a FloatTask
, which allows the entity to float the range specified in the constructor, through utilising a MovementTask
@Override
public void start() {
super.start();
startPos = owner.getEntity().getPosition();
movementTask = new MovementTask(getTarget());
movementTask.create(owner);
movementTask.start();
}
The different types of animations are stored in a LinkedHashMap
with the key entry being the BuffPickup
type and the second being a list of 2 integers. The first is whether the buff has been collided with and the second is whether the animation has spawned onto the map. Both use 0 to represent false and 1 to represent true.
private LinkedHashMap<BuffPickup, List<Integer>> buffPickups;
public BuffManager(MainGameScreen mainGame, GameArea currentMap) {
this.buffPickups.put(BuffPickup.positive, Arrays.asList(0, 0));
this.buffPickups.put(BuffPickup.negative, Arrays.asList(0, 0));
}
The values in the list are updated when a player collides with the right buff.
public void selectBuffFunctionality(BuffTypes type, Entity buff,
BuffInformation buffInfo) {
/* PlayerBuffs functions to call when there is a new instant buff */
switch (type) {
case B_HP_UP:
this.buffPickups.get(BuffPickup.positive).set(0, 1);
return;
}
They are also updated in the spawnPickup
function, which handles the spawning and despawning of the animation and is called in the update
function.
private void spawnPickup() {
for (BuffPickup pickup: this.buffPickups.keySet()) {
if (this.buffPickups.get(pickup).get(0) == 1) {
pickupCreationTime = ServiceLocator.getTimeSource().getTime();
buffPickup = mainGame.getCurrentMap().spawnBuffDebuffPickup(pickup, this);
this.buffPickups.get(pickup).set(0, 0);
this.buffPickups.get(pickup).set(1, 1);
}
if (this.buffPickups.get(pickup).get(1) == 1) {
if (ServiceLocator.getTimeSource().getTimeSince(pickupCreationTime) >= 1.5 * SECONDS) {
removeBuff(buffPickup);
this.buffPickups.get(pickup).set(1, 0);
}
}
}
}
public void update() {
spawnPickup();
}
To add another animation type, add the type to the BuffPickup
enum.
public enum BuffPickup {
positive, negative
}
And in the constructor method, add the type into the LinkedHashMap
public BuffManager(MainGameScreen mainGame, GameArea currentMap) {
this.buffPickups.put(BuffPickup.positive, Arrays.asList(0, 0));
}
- Player UI
- Popup Menus
- Obstacles
- Boss Enemies
- Progress Tracker
- Checkpoint Design and Functionality
- Score System
- Lives System
- Game Background
- Multiple game-level
- Visual Improvements
- Tutorial Level
- Character Design and Animations
- Character Damage Animations
- Player Animation Functionalities
- Player and Serpent Portal Transition
- Pop-up Menus
- Obstacles
- Lives & Score User Testing
- Buffs & Debuffs
- Buffs & Debuffs redesign
- Obstacle Animation
- Background Design
- Level 2 Background Appearance
- Enemy Monster User Testing
- Level 1 Floor Terrain Testing
- Introduction Screens User Testing
- Character Movement Interviews & User Testing
- Sound user testing
- Level 2 Obstacles and enemy
- Story, Loading, Level 4 and Win Condition Sound Design User Testing
- Giant Bug and Purple Squid animation user testing
- General Gameplay and Tutorial Level User Testing
- Level 4 Terrain User Testing
- Game Outro User Testing