Feature/engine separation#72
Merged
Merged
Conversation
…d render FPS settings
# Conflicts: # package-lock.json # package.json
# Conflicts: # package-lock.json # package.json # src/game/index.ts # src/game/types.ts
There was a problem hiding this comment.
Pull request overview
This PR refactors the game engine toward a more modular “engine vs. game” separation by centralizing shared engine types, introducing an engine barrel export, and decoupling the sound system from direct userOptions dependencies to improve configurability and testability.
Changes:
- Centralized shared engine type definitions into
src/game/engine/types.tsand re-exported them for backwards compatibility viasrc/game/types.ts. - Introduced
src/game/engine/index.tsas a unified entry point and updated game modules to import engine components from it. - Refactored
Soundto use injected configuration (SoundEngineConfiguration) for volume and option-change notifications; expandedGameArenato accept configurable rendering/font options.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/game/types.ts | Re-exports shared engine types from the new centralized engine types module. |
| src/game/systems/spawning.ts | Switches sound import to the new engine entry point. |
| src/game/player.ts | Switches sound import to the new engine entry point. |
| src/game/index.ts | Configures the sound engine via Sound.configure() and passes GameArenaOptions when constructing the arena. |
| src/game/engine/types.ts | Adds centralized engine type definitions (coords, sprites, arena options, ticker, sound config/types). |
| src/game/engine/Ticker.ts | Updates type import to come from ./types. |
| src/game/engine/Sound.ts | Refactors sound volume/event wiring to use injected configuration and adds playback-blocked callback support. |
| src/game/engine/index.ts | Adds engine barrel exports for core engine modules and shared engine types. |
| src/game/engine/helpers.ts | Updates type import to come from ./types. |
| src/game/engine/arena.ts | Adds configurable GameArenaOptions (font/colors/grid) and removes direct palette/asset dependencies. |
| src/game/engine/tests/engine.test.ts | Updates tests to configure Sound via the new configuration API rather than mutating userOptions. |
| src/game/enemy.ts | Switches sound import to the new engine entry point. |
| src/game/bullet.ts | Switches sound import to the new engine entry point. |
| src/game/bullet-factory.ts | Switches sound import to the new engine entry point. |
| package.json | Bumps package version to 28.1.0. |
| package-lock.json | Updates lockfile versions to 28.1.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Introduced `debug-vectors.ts` for drawing heading and steering vectors on canvas. - Added `helpers.ts` with utility functions for collision detection, angle rotation, and random color generation. - Created `types.ts` to define common types such as `Heading`, `Coordinates`, and `PositionedRadius`. - Implemented viewport utilities in `viewport.ts` for calculating viewport dimensions and scaling. - Updated `index.ts` to export new modules and types. - Refactored game files to utilize the new arcade engine module imports. - Adjusted TypeScript configuration to include new paths and aliases for the arcade engine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant refactoring and improvements to the sound engine, debug vector rendering, and module import structure, along with corresponding updates to tests and code organization. The main goals are to make the sound engine more configurable and decoupled from game settings, enhance testability, and ensure clear separation of concerns between engine and game modules.
Sound Engine Refactor and Improvements:
Soundclass to accept configuration via a newSound.configure()method, allowing consumers to provide volume calculation logic, event hooks (e.g., for playback blocking), and event-driven volume updates, instead of directly depending onuserOptions. [1] [2] [3] [4] [5] [6]Soundandhelpersfrom the newenginebarrel file, improving modularity and enforcing separation between engine and game modules. [1] [2] [3] [4] [5] [6] [7] [8]Debug Vectors Refactor:
drawDebugVectorsin the game layer to delegate to the engine implementation, allowing for customizable colors and improved testability. [1] [2]Module Import Structure and Enforcement:
Testing and Configuration Updates:
Sound.configure()API, replacing directuserOptionsmutation with test-local configuration and event dispatching. Added tests for sound playback blocking notification and correct volume calculation. [1] [2] [3] [4] [5] [6]Other Maintenance:
package.jsonto29.0.0.These changes collectively improve modularity, maintainability, and testability of the codebase, especially around the sound engine and debug tooling.