Skip to content

CombatArea

yessica-s edited this page Sep 11, 2024 · 5 revisions

The CombatArea Class handles the loading of a terrain factory and entities into the Combat Screen. The main purpose of the class is to call CombatTerrainFactory, providing a terrain for entities (players and enemies) to spawn onto. Responsible for background scaling and spawned positions of entities below.

Capture

`create()

This function handles the spawning of UI, terrain, and entity components onto the Combat Screen. The most significant functions subsequently called are listed below:

  • spawnTerrain() // spawns background for combat as terrain
  • spawnPlayer() // spawns player by retrieving selected player from PlayerFactory and spawning/positining it
  • any of spawnMonkey(), spawnFrog(), spawnChicken(), spawnCombatEnemy() // called to spawn the relevant enemy collided with into the CombatArea

Usage

The CombatArea class is instantiated and called from CombatScreen.java as follows

private final CombatArea gameArea;
public CombatScreen(GdxGame game, Screen screen, ServiceContainer container, Entity player, Entity enemy) {
   ...
   this.gameArea = new CombatArea(player, enemy, game, combatTerrainFactory); // initialise game area, with entities
   gameArea.create();
}
Clone this wiki locally