|
|
||
|---|---|---|
| assets | ||
| js | ||
| BASE_DEFENSE_PLAN.md | ||
| ReadMe.md | ||
| index.html | ||
| start_web.bat | ||
| start_web.sh | ||
ReadMe.md
Repository Overview
This repository contains a small Phaser‑based game that manages enemy spawning and level progression using JSON configuration files and a dedicated LevelManager class.
Assets
assets/data/levels.json
Defines the parameters for each game level:
| Level | Spawn Interval (ms) | Enemy Types | Enemy Multiplier |
|---|---|---|---|
| 1 | 2000 | grunt |
1.0 |
| 2 | 1800 | grunt, brute |
1.2 |
| 3 | 1600 | grunt, brute, tank |
1.5 |
spawnInterval– Time between enemy spawns (lower = faster).enemyTypes– Array of unit keys that may appear on the level.enemyMultiplier– Multiplier applied to enemy stats (e.g., health) to increase difficulty.
assets/data/units.json
Describes the base stats for each enemy type used in the game:
| Unit | Health | Speed | XP | Collision Damage | Width (px) | Height (px) |
|---|---|---|---|---|---|---|
| grunt | 30 | 80 | 10 | 15 | 96 | 96 |
| brute | 80 | 60 | 25 | 30 | 96 | 96 |
| tank | 150 | 40 | 50 | 45 | 128 | 128 |
These values are referenced when spawning enemies, calculating damage, and awarding experience points.
Source Code
js/managers/LevelManager.js
A lightweight manager that handles level state and progression:
- Constructor receives the current Phaser scene and the parsed
levels.jsondata. - Stores the current level (
currentLevel) and its configuration (currentConfig). startLevel(num)– Switches to a specific level, updatingcurrentLevelandcurrentConfig.levelUp()– Advances to the next level (if one exists), callsstartLevel, and updates the spawn interval in the scene’sspawnManager.
This class isolates level‑related logic, making it easy to broadcast UI events or extend functionality later.
js/scenes/GameScene.js
The main gameplay scene (a subclass of Phaser.Scene). While the full implementation is omitted, the class skeleton includes the typical Phaser lifecycle methods:
preload()– Load assets (sprites, JSON files, etc.).create()– Set up the game world, instantiate managers (e