Skip to content

Enemy Factory

Logan Booth edited this page Sep 1, 2026 · 6 revisions

Overview

EnemyFactory creates enemy entities for the game. It loads stats and behaviour values from configs/Enemies.json and returns fully configured entities ready to be spawned by a game area. All enemy types share a common base, with specific methods for each type with different sprites and attack behaviour.

Source

source/core/src/main/com/csse3200/game/entities/factories/EnemyFactory.java

Usage

EnemyFactory is a static utility class and can't be instantiated. Call the creation method for the enemy type you want.

Entity shooter = EnemyFactory.createSkeletonArcher(player);
spawnEntityAt(shooter, randomPos, true, true);

The returned entity isn't registered with the game so you have to spawn it through your game area as shown above. Textures must be loaded beforehand so add images/skeleton_archer.png and images/arrow.png to the texture list.

Enemy Types

Type Method Attack
Skeleton Warrior createSkeletonWarrior Melee, with wind-up delay
Skeleton Archer createSkeletonArcher Ranged projectile

Adding a new enemy type

  1. Add a config block to configs/Enemies.json
  2. Add a matching field to EnemyConfigs
  3. Add the sprite to source/core/assets/images
  4. Add a createX(Entity target) method to EnemyFactory following the current pattern: call createEnemy, add a TextureRenderComponent, call scaleEntity(), and add any specific type of attack.
  5. Register the new texture in the game area's texture list

Clone this wiki locally