Skip to content

Split MainMenu into a generic WorldScene + Metal Slug's own scene - #26

Merged
diego3 merged 3 commits into
mainfrom
claude/split-worldscene-from-metalslug
Jul 30, 2026
Merged

Split MainMenu into a generic WorldScene + Metal Slug's own scene#26
diego3 merged 3 commits into
mainfrom
claude/split-worldscene-from-metalslug

Conversation

@diego3

@diego3 diego3 commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

Resolves the "blocking design problem" identified in docs/frame_engine_migration_plan.md
(PR #25): view/scene.MainMenu was meant to be the engine's one generic, reusable scene type,
but over the Metal Slug demo's build-out it accumulated real gameplay rules — hit detection,
auto-aimed shooting hardcoded to "projectile_prototype"/"SpawnProjectile" — that have no
business in a general-purpose engine. This had to be split before any repo extraction could
happen; this PR does that split now, inside this repo, before anything moves.

What changed

  • view/scene/mainmenu.goview/scene/world_scene.go: MainMenu is renamed WorldScene
    and keeps only what's genuinely generic — script engine wiring, physics/camera setup, the
    Prototype-clone spawnEntity mechanism, projectile movement, and the AABB helpers (now
    exported as AABB/AABBOverlap, plus PayloadFloat/NormalizeDir) so a game's own scene can
    reuse them. No Metal-Slug-specific logic remains in this file.
  • games/metalslug_demo/scene.go (new): this demo's own Scene, embedding *scene.WorldScene
    and adding exactly the two rules that don't belong in the engine: spawnProjectile (auto-aim
    shooting from the controlled entity) and updateHitDetection (projectile damages enemy).
  • Resolves the application/engine/engine.go FIXME as a side effect: removed the
    package-level view/scene.Factories global (itself a small "no globals" violation per
    ADR-006/CLAUDE.md) — engine.New now takes a map[string]scene.SceneFactory supplied by the
    caller, so main.go/main_wasm.go register their own applications' scene types instead of the
    engine hardcoding them.
  • games/demo1 and games/metalslug_demo now register distinct scene types
    (world_scene/metalslug_scene) instead of both pointing at the same "main_menu" type.

Validation

  • go build ./..., go vet ./..., gofmt -l (clean on every file this PR touches — the one
    gofmt finding, physics/types.go, is pre-existing drift on main, unrelated to this change).
  • go test ./... and go test -race across the touched packages: all passing.
  • WASM cross-compile check (GOOS=js GOARCH=wasm go build) since main_wasm.go changed: passes.
  • Live smoke run of both games/demo1 and games/metalslug_demo: both load their scene, build
    physics bodies, and print the expected body listing under their new scene types
    (world_scene/metalslug_scene) before hitting this sandbox's known, pre-existing ALSA/audio
    limitation — same as every other run in this environment, unrelated to this change.

Generated by Claude Code

Resolves the "blocking design problem" from
docs/frame_engine_migration_plan.md: view/scene.MainMenu had
accumulated Metal-Slug-specific gameplay rules (hit detection,
auto-aimed shooting hardcoded to "projectile_prototype"/
"SpawnProjectile") inside what was meant to be the engine's one
generic, reusable scene type.

- view/scene/mainmenu.go -> view/scene/world_scene.go: WorldScene
  keeps everything genuinely generic (script/physics/camera wiring,
  the Prototype-clone spawnEntity mechanism, AABB helpers now exported
  as AABB/AABBOverlap, PayloadFloat/NormalizeDir). No game-specific
  logic remains.
- games/metalslug_demo/scene.go (new): this demo's own Scene, embedding
  *scene.WorldScene and adding exactly the two rules that don't belong
  in a general-purpose engine: spawnProjectile (auto-aim shooting) and
  updateHitDetection (projectile damages enemy).
- Resolves the application/engine/engine.go FIXME as a side effect:
  removed the package-level view/scene.Factories global (itself a
  small "no globals" violation); engine.New now takes a
  map[string]scene.SceneFactory supplied by the caller (main.go/
  main_wasm.go), so scene registration is per-application, not
  hardcoded engine-side.
- games/demo1 and games/metalslug_demo's config.yaml now register
  distinct scene types ("world_scene" and "metalslug_scene"
  respectively) instead of both pointing at the same "main_menu" type.

Verified with go build/go vet/gofmt, go test (+ -race) across the
touched packages, a WASM cross-compile check, and a live smoke run of
both games/demo1 and games/metalslug_demo (scene Setup + physics body
listing succeeds for both under the new scene types; the run stops at
the sandbox's known pre-existing ALSA/audio-device limitation before
reaching the interactive game loop, unrelated to this change).
@cursor

cursor Bot commented Jul 27, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

Physically moves every package classified as "Move" in
docs/frame_engine_migration_plan.md's inventory into a single new
frameengine/ directory, mirroring that plan's proposed frame-engine
repo layout exactly (frameengine/application/{config,engine,game,data},
event, events, object, physics, ports, process, resource, script,
vec2, view/{ui,input,camera,scene}).

Nothing outside frameengine/ changes behavior -- this is a pure move
plus import-path rewrite (goengine/x -> goengine/frameengine/x) within
the same module. main.go, main_wasm.go, and games/metalslug_demo's
scene.go are updated to import from the new paths; games/, logic/,
and docs/ are untouched, since they're staying in this repo per the
plan's inventory.

Once frame-engine (github.com/diego3/frame-engine) is ready to receive
it, the actual repo split becomes: copy frameengine/*'s contents to
the new repo's root, `go mod init github.com/diego3/frame-engine`, and
strip the "frameengine/" segment from every import path -- no other
restructuring needed, since this directory's internal layout already
*is* the target repo's layout.

Stacked on #26 (the WorldScene/MainMenu split) -- that split had to
land first so this move carries the generic scene.WorldScene, not the
old game-logic-leaking MainMenu.

Verified: go build/go vet/gofmt clean on every touched file, go test
(+ -race, same pre-existing box2d-go checkptr failure as before,
unrelated) all passing, a WASM cross-compile check, and a live smoke
run of both games/demo1 and games/metalslug_demo (identical output to
pre-move).
…kage

Consolidate the core engine into a frameengine/ package
@diego3
diego3 merged commit 756d43c into main Jul 30, 2026
3 checks passed
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