Using Test Scenes
Relevant source files
The following files were used as context for generating this wiki page:The souless project includes several specialized Phaser scenes designed for testing specific game features in isolation. These scenes are crucial for development, allowing for rapid iteration and debugging of maps, UI elements, visual effects, and boss mechanics without needing to play through the entire game. All test scenes are registered in the main game configuration and can be launched directly.
The primary test scenes available are:
| Scene Class | Scene Key | Purpose |
|---|---|---|
MapTestScene | MapTestScene | Test map loading, player physics, character switching, and enemy spawning. |
UITestScene | UITestScene | Test UI components like character selection and skill cooldowns. |
EffectTestScene | EffectTestScene | Test character animations and visual effects in a controlled environment. |
BossTestScene | BossTestScene | Isolate and test boss fight mechanics against a player character. |
Sources: renderer/renderer.js:5-13, src/scenes/MapTestScene.js, src/scenes/UITestScene.js, src/scenes/TestScene.js, src/scenes/BossTestScene.js
Scene Registration
All test scenes, along with the main game scenes, are registered in an array within the main Phaser game configuration. This makes them accessible via their string key (e.g., this.scene.start('UITestScene')).
// renderer/renderer.js
const config = {
// ...
scene: [
MainMenuScene,
IntroScene,
GameScene,
UITestScene,
EndingScene,
BossTestScene,
PauseMenuScene,
EffectTestScene,
UIScene,
],
// ...
};
Sources: renderer/renderer.js:13-23
MapTestScene
This scene is designed to test the functionality of game maps, including asset loading, player interaction, character switching, and enemy management. It allows a developer to quickly load any map defined in mapData.js and test its features.
Sources: src/scenes/MapTestScene.js
Initialization and Setup
The scene is initialized with a mapKey and an optional characterType. If no map is provided, it defaults to final_map. The create method follows a standard setup procedure for a game level.
This diagram shows the setup flow within the create() method of MapTestScene.
Sources: src/scenes/MapTestScene.js:68-81
Key Features
Map Switching
Developers can cycle through all available maps by pressing the 'M' key. The scene restarts itself with the next map key from the MAPS object.
Sources: src/scenes/MapTestScene.js:254-263
Character Switching
The scene implements two ways to switch characters:
- Quick Switch: Pressing
Tabcycles through the available characters (soul,skull,demon). - Selection UI: Holding the backtick (`) key for over 300ms opens an overlay to select a character with arrow keys.
The following diagram illustrates the sequence for switching a character.
Sources: src/scenes/MapTestScene.js:169-192
Controls
| Key | Action |
|---|---|
← / → | Move left/right. |
SPACE | Jump. |
S | Dash. |
SHIFT | Run. |
A | Attack. |
M | Cycle to the next map. |
Tab | Quick switch to the previous character. |
(hold) | Open character selection UI. |
(release) | Confirm character selection. |
Sources: src/scenes/MapTestScene.js:228-252
UITestScene
This scene provides a sandbox for developing and testing UI components without the overhead of the full game logic. It specifically tests the CharacterSelectOverlay and the UISkillCooldown bar.
Sources: src/scenes/UITestScene.js
Mock Environment
To function, UITestScene creates a mock player object and a mock skill unlock system. This allows the UI components to be tested as if they were interacting with a real player entity.
testPlayer: A plain JavaScript object that mimics a player's properties, includinghealth,mana, and askillSystemwith cooldowns.testSkillUnlockSystem: An object that simulates theSkillUnlockSystem, tracking a mock player level and which skills are unlocked.
This diagram shows how UITestScene creates a mock environment to test UI components.
Sources: src/scenes/UITestScene.js:101-200
Controls
| Key | Action |
|---|---|
(hold) | Open Character Select UI. |
← / → | Navigate characters in the UI. |
(release) | Confirm character selection. |
Q/W/E/R/S/A | Trigger cooldown for the corresponding skill. |
Space | Reset all skill cooldowns and restore mock HP/Mana. |
1 / 2 / 3 / 4 | Simulate setting player level to 10/20/30/40 to test skill unlocks. |
Sources: src/scenes/UITestScene.js:41-50, 298-335
TestScene (EffectTestScene)
This scene, named EffectTestScene but keyed as TestScene, is a visual sandbox for testing character skills and their associated visual effects (VFX). It features a multi-floor layout where every available character is spawned, allowing for simultaneous testing of animations and effects across the entire roster.
Sources: src/scenes/TestScene.js
Multi-Floor Layout
The scene creates multiple horizontal platforms, or "floors". On each floor, an instance of every character type from CharacterFactory is created. This unique setup allows developers to trigger an action (like an attack) and see how it is rendered for all characters at once. Each floor is associated with a specific effect key for targeted testing.
Sources: src/scenes/TestScene.js:60-106, 172-201
Controls
| Key | Action |
|---|---|
A / Q | Trigger basic attack for all characters. |
W / E / R | Trigger skill 1, 2, or 3 for all characters. |
1 - 4 | Trigger the effect assigned to the corresponding floor (1F-4F). |
T | Trigger all floor effects simultaneously. |
F | Toggle the horizontal flip (flipX) for all characters. |
SPACE | Toggle auto-play mode, which randomly triggers effects and skills. |
ESC | Return to the GameScene. |
Sources: src/scenes/TestScene.js:203-241
BossTestScene
This is the most focused test scene, created for the sole purpose of testing a boss fight. It loads a single player character and a single boss, allowing for direct and isolated testing of boss AI, attacks, and player combat mechanics.
Sources: src/scenes/BossTestScene.js
Initialization
The scene is initialized with a bossType (e.g., 'mauler_boss') and a characterType for the player. It has a minimal setup, creating only the necessary components for a boss encounter.
The create function is simple:
- Set up gravity and fade in the camera.
- Create a simple ground platform.
- Create the player character instance using
CharacterFactory. - Create the boss instance using
EnemyBase. - Set up a collider between the player, the boss, and the ground.
Sources: src/scenes/BossTestScene.js:23-75
Summary
The test scenes in the souless repository are a powerful tool for modular development. By isolating features like map rendering (MapTestScene), UI components (UITestScene), visual effects (TestScene), and boss mechanics (BossTestScene), developers can work more efficiently and debug complex systems without interference from other parts of the game. Their inclusion and registration in the main game build (renderer/renderer.js) highlight a development methodology that prioritizes testability and iteration.