-
Notifications
You must be signed in to change notification settings - Fork 0
Game Manager
The Game Manager is responsible for controlling the Play State of a level. It initializes gameplay, spawns and configures the player, applies movement presets, activates enemies, tracks gameplay statistics, manages the pause and win screens, and handles level reset and replay functionality.
The manager also serves as the central coordinator for gameplay UI, including the timer, coin counter, pause menu, and level completion screen. It listens for global gameplay events such as player death, coin collection, and level completion to keep the play session synchronized.
List of connecting/parent/subsystems.
Gameplay controls are documented under the Player Controller.
The Game Manager additionally handles the following UI controls:
- Pause Button — Toggles the pause state.
- Resume Button — Returns from the pause menu.
- Reset Button — Reloads the current level.
- Replay Button — Restarts the level after completion.
- Editor Button — Returns to the level editor after playtesting.
List of known bugs.
- None currently.
- Player Initialization – Finds the spawned player, applies the selected movement preset, stores the starting position, and connects gameplay signals.
- Enemy Initialization – Enables enemy processing and applies enemy property resources based on their tile positions.
- Pause System – Pauses and resumes gameplay while swapping between gameplay UI and the pause menu.
- Level Reset – Reloads the current playable level and restores all gameplay state.
- Coin Tracking – Counts collectible coins, tracks collected coins, and updates both gameplay and completion UI.
- Checkpoint Tracking - Keeps track of the player's current checkpoint if they have one, respawning them there on death.
- Gameplay Timer – Records elapsed playtesting time and continuously updates the timer display.
- Win Screen – Stops gameplay upon reaching the goal, displays final completion statistics, and provides replay/editor options.
- Replay Functionality – Immediately restarts the current level from the win screen.
- Return to Editor – Exits play mode and restores the editor state after testing.
- Health Monitoring – Receives player health updates through connected signals for gameplay monitoring and future expansion.
Name the most important variables, their type, and purpose.
-
enum PlayState { PAUSE, PLAY }– Represents whether gameplay is currently paused or active. -
var playState : PlayState– Stores the current gameplay state. -
var goalReached : bool– Prevents pause/reset logic after the level has been completed.
-
var player : CharacterBody2D– Reference to the active player instance. -
var playerStartingPosition : Vector2– Stores the player's initial spawn location. - **
var playerCheckpointPosition: Vector2 = Vector2(-1, -1) = Stores the player's checkpoint spawn position. -
var playerPreset : Resource– The currently selected movement preset applied during play.
-
var testingTime : float– Tracks total elapsed playtesting time. -
var timerRunning : bool– Determines whether the gameplay timer should continue updating.
-
var coinCount : int– Number of collected coins. -
var totalCoins : int– Total collectible coins present in the level.
-
var tileMap : TileMapLayer– Reference used to locate enemies and apply their stored properties.
Initializes the play session by:
- Resetting timer and coin values.
- Counting all collectible coins.
- Finding the newly spawned player.
- Applying the selected movement preset.
- Connecting player health signals.
- Enabling enemies and loading their saved properties.
- Starting the gameplay timer.
- Displaying gameplay UI.
Toggles between paused and active gameplay by:
- Updating
SceneTree.paused. - Swapping gameplay UI with the pause menu.
- Ignoring pause requests after level completion.
- Fully reloads the playable level, run when entering from the MasterManager or when clicking on the restart button
- Resets the checkpoint
Reloads the playable level by:
- Clearing completion state.
- Unpausing the scene.
- Emitting the global reload signal.
- Reinitializing gameplay through
start().
Handles successful level completion by:
- Stopping gameplay.
- Pausing the scene.
- Displaying the win screen.
- Showing final coin and time statistics.
- Hiding gameplay HUD elements.
Restarts the completed level and begins a new play session.
Leaves play mode and returns to the editor while restoring the editor's validated state.
Formats and displays the elapsed time in MM:SS format.
Updates a UI label with the current collected coin count out of the total available.
Responds to the global coin collection signal by increasing the collected coin count and refreshing the UI.
Responds to the global checkpoint signal by setting a new checkpoint position for the player.
Stops the gameplay timer and prints the final completion time for debugging purposes.
- Add support for tracking deaths and attempts during playtesting.
- Record best completion times and coin collection statistics.
- Expand health tracking into gameplay UI.
- Support additional gameplay statistics for validation and analytics.
- None so far.
- The Game Manager is the primary coordinator for playtesting mode.
- Gameplay statistics (coins and timer) are displayed both during gameplay and on the completion screen.
- Most gameplay events are driven through the project's global signal system rather than direct node references, keeping gameplay systems loosely coupled.# Game Manager
Resources
Known Issues
Future Work
Globals
Managers
- Main Menu Manager
- Master Manager
- Camera Manager
- Hotkey Manager
- Import Export Manager
- Audio Manager
- Animation Manager
- PopUp Manager
UI
Managers
- Editor Manager
- Tile Manager
- Entity Manager
- Icon Manager
- Preview Manager
- Tool Manager
- Asset Manager
- Custom Cursor Manager
Tiles & Entities
- Grid Lines
- Preview Line
- Tiles & Entities
- Enemies
- Patrolling Enemy
- Flying Enemy
- Shooting Enemy
- Stationary Enemy
- Moving Platform
- Property Editing
Asset Swapping
UI
Managers
Player