From f4b89a25df196c5d930cce62a32c9ed2207dda64 Mon Sep 17 00:00:00 2001 From: Brian Fertig Date: Sat, 22 Aug 2026 14:56:02 -0600 Subject: [PATCH] Add smashable props (TV/chair/cone) with physics-based launch on bus collision - New SmashItemManager entity that spawns items from level data, detects bus contact, swaps to smashed frame, and applies up-and-forward impulse with tumble - Add `SMASH_ITEM` config block for launch speed/angle/spin, density, friction, restitution, and float height - Extend asset manifest and spritesheet (6 frames: intact/smashed TV, chair, cone) - Level editor gains "Smashables" section to place/delete items via click on preview map; exports `items` array in level data - Level editor can now import bundled or file-based levels, preserving exact terrain while locking section editing; metadata and items remain editable for re-export - Score scene reveals smashed item count as a bonus line (+50 each) between kids and time tally - PlayScene wires SmashItemManager lifecycle and passes smashedCount to score scene - README documents smashables feature, editor workflow, and import behavior --- README.md | 10 +++ editor.html | 74 ++++++++++++++++--- src/editor/main.js | 176 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 251 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e7cbcf6..23f94cd 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,16 @@ The **level editor** (`editor.html`) has a "Smashables" section: pick a type existing item (on the map or in the list) to remove it. Exporting the level writes the `items` array into the level file automatically. +The editor can also **load an existing level** (the "Load an existing level" +section) - either pick a bundled level from the dropdown (all levels from +`src/data/levels/index.js`) or load a `levelNN.js` file from disk. Its +terrain is preserved exactly: since it wasn't built from sections, the +sections palette / sequence / size controls lock (dimmed and inert) and the +preview + export render the loaded level's own terrain. Details (id / name / +description / kids) and smashables stay editable, so you can tweak them and +re-export. "Start a new level" clears the import and unlocks the section +controls again. + ## Phaser 4 loading Phaser is vendored locally at `vendor/phaser.esm.js` (downloaded once from diff --git a/editor.html b/editor.html index f88a0a6..a1eac1f 100644 --- a/editor.html +++ b/editor.html @@ -170,6 +170,46 @@ grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; } + .is-locked { + opacity: 0.45; + pointer-events: none; + } + .import-row { + display: flex; + flex-wrap: wrap; + align-items: flex-end; + gap: 16px; + } + .import-row label { + display: flex; + flex-direction: column; + gap: 4px; + font-size: 12px; + color: #9aa7bb; + } + .import-row select, .import-row input[type="file"] { + background: #0b0e14; + border: 1px solid #2c374f; + color: #e8eef7; + border-radius: 4px; + padding: 6px 8px; + font-family: monospace; + font-size: 13px; + } + #clear-level-btn { + background: #2255aa; + color: #fff; + border: 1px solid #1a1f29; + border-radius: 4px; + padding: 8px 12px; + font-family: monospace; + font-size: 13px; + cursor: pointer; + } + #clear-level-btn:disabled { + opacity: 0.35; + cursor: not-allowed; + } #metadata-form label { display: flex; flex-direction: column; @@ -230,34 +270,52 @@
-

Sections

-
+

Load an existing level

+

Import a bundled level or a levelNN.js file. Its terrain is preserved exactly (section editing is locked, since it wasn't built from sections), and you can adjust its details and smashables, then re-export it.

+
+ + + +
+
-
+
+

Sections

+

Add sections to build a new track.

+
+
+ +

Sequence

-
-
+
+