Merge Powerups - UQcsse3200/2023-studio-2 GitHub Wiki
Overview
Merge Potions and Powerups to reduce Code duplication and accomodate it all in Laboratory
Usage
Initialisation:
- Merging Potion Component, Potion Types and Potion factory into powerups
- Merging Config Files
- deleting all unwanted potion files
public class PowerupConfigs {
public PowerupConfig healthPowerup = new PowerupConfig();
public PowerupConfig speedPowerup = new PowerupConfig();
public PowerupConfig extraLifePowerup = new PowerupConfig();
public PowerupConfig doubleCrossPowerup = new PowerupConfig();
public PowerupConfig tempImmunityPowerup = new PowerupConfig();
public PowerupConfig doubleDamagePowerup = new PowerupConfig();
public PowerupConfig snapPowerup = new PowerupConfig();
public PowerupConfig death_potion = new PowerupConfig();
}
Example - Spawning Powerups
private void spawnPowerups() {
GridPoint2 minPos = new GridPoint2(0, 0);
GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2);
GridPoint2 deathPosition = RandomUtils.random(minPos, maxPos);
// Create a health and speed powerup
Entity deathPotion = PowerupFactory.createDeathPotion();
// Spawn the created powerups at the two random locations
spawnEntityAt(deathPotion, deathPosition, true, false);
}