Skip to content

Powerups

kk4w4i edited this page Oct 10, 2023 · 30 revisions

Overview

Powerups create a more fun and engaging experience by granting the user enhanced abilities, each with a unique duration and effect. Powerups are commonly found in random locations within the map and can be picked up with the 'F' key.

Design

Powerup assets were sourced from a free asset pack and were selected as they are aesthetic, simple, and easy to create more. Additionally, the 16x16 pixel layout fits the overall Game Design objective.

tile011_scaled_9x_pngcrushed tile018_scaled_9x_pngcrushed 268500888-827319a5-fdb4-41c2-a584-61a74d727474 image image image image

Gameplay

When a player approaches a powerup and presses the F key, the following effects will apply:

Base Powerups

Base powerups are only obtainable by picking them up when they are dropped after defeating an enemy.

Health Powerup: Restores the player to total health.

Movement Powerup: Increases the player's default movement speed by 66% for 1.5 seconds.

Craftable Powerups

These powerups provide an advancement to the gameplay whcih can only be obtained by crafting them in the laboratory done by your companion.

Extra Life Powerup: Increases the number of players' lives by 1, unless the number of players lives is already 4 (max amount allowed).

Required Materials:

  • Health Powerup: 4

Double Cross: Picks a random enemy to fight for the player for 12 seconds.

Required Materials:

  • Health Powerup: 2

  • Movement Powerup: 2

Double Damage: Doubles damage dealt by the player for 12 seconds.

Required Materials:

  • Movement Powerup: 4

Snap: Eliminates half of the enemies present on the map.

Required Materials:

  • Health Powerup: 4

  • Movement Powerup: 4

Immunity: Grants player immunity from any damage for 6 seconds.

Required Materials:

  • Health Powerup: 3

  • Movement Powerup: 2

Crafting

Crafting is a feature that allows the player to access craftable powerups that are more advanced and used further into the gameplay.

Usage

Initialisation:

  1. Initialise a new PowerupComponent
  2. Specify the type of powerup and PhysicsLayer.
  3. Apply the powerup to the entity.

Example:

PowerupComponent powerup = new PowerupComponent(PowerupType._POWERUP_TYPE_, PhysicsLayer._PHYSICS_LAYER_);
Entity entity = new Entity();  // typically the player entity
powerup.applyEffect(entity);

Powerups can be treated as regular Entities and therefore have Components as well as a scale and position within the game world (See Entities for more details). All created Powerups are automatically registered with the EntityService and can be found in an array with the following call:

ServiceLocator.getEntityService().getEntitiesByComponent(PowerupComponent.class);

Example - Spawning Powerups

private void spawnPowerups() {
    // Choose two random locations within the game map
    GridPoint2 minPos = new GridPoint2(0, 0);
    GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2);
    GridPoint2 healthPosition = RandomUtils.random(minPos, maxPos);
    GridPoint2 speedPosition = RandomUtils.random(minPos, maxPos);

    // Create a health and speed powerup
    Entity healthPowerup = PowerupFactory.createHealthPowerup();
    Entity speedPowerup = PowerupFactory.createSpeedPowerup();

    // Spawn the created powerups at the two random locations
    spawnEntityAt(healthPowerup, healthPosition, true, false);
    spawnEntityAt(speedPowerup, speedPosition, true, false);
  }

Iteration

Initially, powerups were applied on collision with the player; however, to allow for a more engaging experience with other teams' future implementations, such as mini-games or enemy death drops, an InteractableComponent was created in collaboration with Team 5 to allow a powerup applyEffect() to be run as the player presses a key (F).

This integration is essential as, in the future, it will provide the player more visual feedback on completing a mini-game or killing an enemy - as previously, the powerup would be instantly picked up and likely unnoticed by the player.

Testing plan

Powerups have been tested in accordance with the Powerups Testing Plan

Class interaction / UML Diagrams

uml (1) To enlarge: Right click -> Open image in new tab

Clone this wiki locally