Skip to content

Refresh whack-a-mole example for v19 API#1374

Merged
obiot merged 2 commits intomasterfrom
fix/whack-a-mole-refresh
Apr 11, 2026
Merged

Refresh whack-a-mole example for v19 API#1374
obiot merged 2 commits intomasterfrom
fix/whack-a-mole-refresh

Conversation

@obiot
Copy link
Copy Markdown
Member

@obiot obiot commented Apr 11, 2026

Summary

Test plan

🤖 Generated with Claude Code

- ExampleWhacAMole.ts: replace video.init() with new Application()
- HUD.ts: replace standalone font.draw() (removed in #1364) with
  BitmapText children added to HUDContainer
- play.ts: type onResetEvent/onDestroyEvent with Application parameter,
  use app reference instead of game singleton

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 11, 2026 10:03
Copy link
Copy Markdown
Contributor

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

Updates the whac-a-mole example to align with the melonJS v19+ API by switching to the Application entry point and modernizing HUD rendering to avoid deprecated standalone BitmapText.draw() usage.

Changes:

  • Replace legacy video.init() startup with new Application(...) in the example entry point.
  • Refactor HUD score rendering from a custom Renderable using standalone font drawing to BitmapText instances added as HUD children.
  • Update PlayScreen to use the app instance (app.reset(), app.world) instead of the global game singleton in the stage lifecycle hooks.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
packages/examples/src/examples/whac-a-mole/ExampleWhacAMole.ts Switches example startup to new Application(...) instead of video.init().
packages/examples/src/examples/whac-a-mole/play.ts Migrates stage lifecycle logic to use the Application instance (app) for reset/world operations.
packages/examples/src/examples/whac-a-mole/HUD.ts Replaces custom score Renderable + standalone draw calls with BitmapText children updated over time.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 8 to +13
export class PlayScreen extends Stage {
/**
* action to perform on state change
*/
onResetEvent() {
game.reset();
override onResetEvent(app) {
app.reset();
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

onResetEvent's app parameter is implicitly any, which fails the examples TS config (strict/noImplicitAny). Also this.HUD is assigned later but the PlayScreen class doesn't declare a HUD field, which will be a TypeScript error (Property 'HUD' does not exist on type 'PlayScreen'). Type the parameter as Application and add a typed HUD class property (optionally HUD?: HUDContainer if it can be absent).

Copilot uses AI. Check for mistakes.
Comment thread packages/examples/src/examples/whac-a-mole/play.ts Outdated
Comment thread packages/examples/src/examples/whac-a-mole/play.ts Outdated
Comment thread packages/examples/src/examples/whac-a-mole/HUD.ts
Comment thread packages/examples/src/examples/whac-a-mole/HUD.ts Outdated
- play.ts: add Application type to onResetEvent/onDestroyEvent, declare
  HUD property, fix MoleManager constructor call (no args)
- HUD.ts: cache last score/hiscore to avoid per-frame setText overhead,
  fix misleading "draw first" comment

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@obiot obiot merged commit 904abbd into master Apr 11, 2026
6 checks passed
@obiot obiot deleted the fix/whack-a-mole-refresh branch April 11, 2026 10:46
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