Skip to content

Feature/engine separation#72

Merged
manix84 merged 12 commits into
mainfrom
feature/engine-separation
May 30, 2026
Merged

Feature/engine separation#72
manix84 merged 12 commits into
mainfrom
feature/engine-separation

Conversation

@manix84
Copy link
Copy Markdown
Owner

@manix84 manix84 commented May 30, 2026

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:

  • Refactored the Sound class to accept configuration via a new Sound.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 on userOptions. [1] [2] [3] [4] [5] [6]
  • Updated all sound engine consumers to import Sound and helpers from the new engine barrel file, improving modularity and enforcing separation between engine and game modules. [1] [2] [3] [4] [5] [6] [7] [8]

Debug Vectors Refactor:

  • Moved core debug vector logic into the engine and updated drawDebugVectors in the game layer to delegate to the engine implementation, allowing for customizable colors and improved testability. [1] [2]
  • Enhanced engine tests to verify correct debug vector rendering, including color and drawing behavior. [1] [2]

Module Import Structure and Enforcement:

  • Added a test to ensure production engine modules do not import from game modules, enforcing a clean dependency direction. [1] [2]

Testing and Configuration Updates:

  • Refactored engine tests to use the new Sound.configure() API, replacing direct userOptions mutation 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:

  • Updated the project version in package.json to 29.0.0.
  • Fixed type import paths in engine modules for consistency.

These changes collectively improve modularity, maintainability, and testability of the codebase, especially around the sound engine and debug tooling.

Copilot AI review requested due to automatic review settings May 30, 2026 23:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts and re-exported them for backwards compatibility via src/game/types.ts.
  • Introduced src/game/engine/index.ts as a unified entry point and updated game modules to import engine components from it.
  • Refactored Sound to use injected configuration (SoundEngineConfiguration) for volume and option-change notifications; expanded GameArena to 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.

Comment thread packages/arcade-engine/src/Sound.ts
Copilot AI review requested due to automatic review settings May 30, 2026 23:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 28 changed files in this pull request and generated 2 comments.

Comment thread package.json Outdated
Comment thread src/game/__tests__/module-imports.test.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 28 changed files in this pull request and generated 2 comments.

Comment thread src/game/viewport.ts Outdated
Comment thread src/game/viewport.ts
manix84 added 2 commits May 31, 2026 00:34
- 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.
@manix84 manix84 enabled auto-merge (squash) May 30, 2026 23:36
@manix84 manix84 merged commit d1e943b into main May 30, 2026
4 checks passed
@manix84 manix84 deleted the feature/engine-separation branch May 30, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants