Sprint 4: Potions Code - UQdeco2800/2022-studio-2 GitHub Wiki
Code
Placing Potions into the game roughly followed this pattern where the entity name, type and GridPoint 2 locations are changed per potion
private void spawnSpeedPotion() {
Entity speedPotion = PotionFactory.createSpeedPotion();
itemsOnMap.add(speedPotion);
spawnEntityAt(speedPotion, new GridPoint2(90, 11), true, true);
}
The last of the potions were updated to be functional. These included Defence Potion and Stamina Potion
Defence Potion
public static Entity createDefencePotion() { Entity potion = createBasePotion() .addComponent(new TextureRenderComponent("images/Potions/defence_potion.png")) .addComponent(new PotionEffectComponent(PhysicsLayer.PLAYER, "damageReduction")); potion.getComponent(TextureRenderComponent.class).scaleEntity(); potion.scaleHeight(1.5f); return potion; }
The defence potion works by making the player block a specific amount of damage. This replaced DamageReductionPotion as it essentially worked the same way. The texture used for the potion was taken from Sprint 1 team's art designs for the initial potions which came in very useful
The Defence Potion is for the lower levels, so the scary, spooky version of the different potion types was used. This implies that although extremely powerful, there is some cost that the player will eventually pay for drinking this unholy potion.
Stamina Potion
public static Entity createStaminaPotion() {
Entity staminaPotion = createBasePotion()
.addComponent(new TextureRenderComponent("images/Potions/swiftness_potion.png"
))
.addComponent(new PotionEffectComponent(PhysicsLayer.PLAYER, "stamina"));
staminaPotion.getComponent(TextureRenderComponent.class).scaleEntity();
staminaPotion.scaleHeight(1.0f);
return staminaPotion;
}
The stamina potion worked in a similar manner to health potion in that it increased the players stamina by a specific amount instead of health. This is useful for the lower levels to allow the player to dash at important time during the final boss fight. The texture used for the potion was taken from Sprint 1 team's art designs for the initial potions which came in very useful
A simple blue potion that is not too different from the speed potion cosmetic, as it improves stamina it is expected that it should be obvious that it is a movement based potion type