-
Notifications
You must be signed in to change notification settings - Fork 1
GameArea and GameController
Cameron Badman edited this page Oct 16, 2024
·
9 revisions
The GameController
class is responsible for managing complex operations related to game areas, rooms, and level transitions within the game. It coordinates player movement, room changes, and the overall state of the game. This class employs dependency injection to integrate the GameArea
, allowing for flexible and testable design.
-
player
: The main player entity that interacts with the game world. -
levelFactory
: A factory that generates game levels based on the current state and settings. -
currentLevel
: The level currently being played by the player. -
currentRoom
: The room within the current level where the player is located. -
currentLevelNumber
: An integer representing the current level index. -
spawnRoom
: A boolean flag indicating whether a new room should be spawned. -
minimapFactory
: A factory responsible for creating and updating the minimap for navigation. -
gameArea
: The game area injected into the controller, facilitating interactions with the game environment.
-
void create()
: Initializes the game area by loading assets and setting up the initial level and room. -
Entity getPlayer()
: Returns the player entity. -
getCurrentRoom()
: Returns the room the player is currently in. -
getCurrentLevel()
: Returns the current level object. -
void changeRooms(String roomKey)
: Changes the current room based on the specified room key. -
void spawnCurrentRoom()
: Spawns the current room if it has not yet been spawned. -
void changeLevel(int levelNumber)
: Updates the game to a new level based on the specified level number.
LevelFactory levelFactory = new LevelFactory();
Entity player = new Entity();
GameArea gameArea = new GameArea(); // Dependency Injection
GameController gameController = new GameController(gameArea, levelFactory, player, false, new MapLoadConfig());
The GameArea
class represents an area in the game where rooms are spawned. It manages the terrain and entities within that area, with a focus on facilitating room spawning during gameplay.
-
terrain
: The terrain component that defines the layout of the game area. -
areaEntities
: A list of entities that exist within the area. -
normalMusic
: Music played during regular gameplay. -
bossMusic
: Music played during boss encounters.
-
void dispose()
: Disposes of all internal entities in the area, stopping music and releasing resources. -
void displayUI(String areaName)
: Displays the user interface for the game area with the given name. -
void spawnEntity(Entity entity)
: Adds an entity to the game area at its current position. -
void spawnEntityAt(Entity entity, GridPoint2 tilePos, boolean centerX, boolean centerY)
: Places an entity on a specific tile position on the terrain, optionally centering it. -
void disposeEntity(Entity entity)
: Disposes of a specific entity from the game area. -
void setTerrain(TerrainComponent terrain)
: Assigns the terrain to be used in the game area. -
void playMusic(int musicType)
: Plays music based on the specified type (0 for normal, 1 for boss). -
CopyOnWriteArrayList<Entity> getListOfEntities()
: Returns a copy of the list of entities in the area. -
String[] getSoundFilepaths()
: Returns an array of file paths for sound effects used in the game area. -
String[] getTextureAtlasFilepaths()
: Returns an array of file paths for texture atlases used in the game area. -
String[] getTextureFilepaths()
: Returns an array of file paths for textures used in the game area. -
String[] getMusicFilepaths()
: Returns an array of file paths for music files used in the game area.
GameArea gameArea = new GameArea();
TerrainComponent terrain = new TerrainComponent();
gameArea.setTerrain(terrain);
Entity room = new Entity(); // Represents a room
gameArea.spawnEntity(room);
Design Choices
Utilities
Animals
Menus/screens
Character
- Character Animations
- Character's Inventory On Display
- Character's Inventory System
- Character's HealthBar
- Character's Interaction with Items
- Character achievements
- Saving Character
- Player-(and-other-NPC)-invincibility-frames
- Player Factory
- Scoring System
- Test Plan for Inventory System
- Test Plan for Player's Interaction with Items
- Test Plan for Player's Inventory Display
- Test Plan for Saving Character State
- Test Plan for Scoring System
Map
Weapon
- Weapon Overview
- Weapon Types
- Weapon Structure
- Weapon Stats Display
- Testing Plan for Weapon Factory
- Testing Plan for Firing Controller Component
- Testing Plan for Position Tracker Component
- Testing Plan for Weapon Animation Controller component
- Testing Plan for Concrete Melee Weapon class
- Testing Plan for Concrete Ranged Weapon class