From 302bcc592d76d95e5b66418cb79b0c0725e7007d Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 1 Mar 2026 18:24:21 +0000 Subject: [PATCH] Rebind Space to jump, gate editor behind localStorage flag Space is now the alternate jump key (was shoot). Web shell shows game controls by default and hides editor UI unless localStorage.show_editor is set to 'true'. The E key and ?edit URL are blocked when the editor is not enabled. Also fix Makefile to track web/shell.html as a WASM link dependency so shell changes trigger a rebuild. --- DESIGN.md | 4 +- Makefile | 8 +- src/engine/input.c | 2 +- web/shell.html | 178 ++++++++++++++++++++++++++++----------------- 4 files changed, 120 insertions(+), 72 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index d10cdb7..4882b1f 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -203,8 +203,8 @@ Current directives: `TILESET`, `SIZE`, `SPAWN`, `GRAVITY`, `WIND`, `BG_COLOR`, ` | Action | Key | Status | |-----------|--------------|---------------| | Move | Arrow keys | Implemented | -| Jump | Z | Implemented | -| Shoot | X / Space | Implemented | +| Jump | Z / Space | Implemented | +| Shoot | X | Implemented | | Aim up | UP (+ shoot) | Implemented | | Aim diag | UP+LEFT/RIGHT (+ shoot) | Implemented | | Dash | C | Implemented | diff --git a/Makefile b/Makefile index e8b5f82..f5abe6d 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,13 @@ OBJ_ALL := $(SRC_ALL:src/%.c=$(OBJ_DIR)/%.o) all: $(BIN) -$(BIN): $(OBJ_ALL) | outdirs +# On WASM builds the shell template is baked into the output HTML, +# so re-link whenever it changes. +ifdef WASM +EXTRA_LINK_DEPS := web/shell.html +endif + +$(BIN): $(OBJ_ALL) $(EXTRA_LINK_DEPS) | outdirs $(CC) $(OBJ_ALL) -o $@ $(LDFLAGS) outdirs: diff --git a/src/engine/input.c b/src/engine/input.c index d2126d4..2f2dfe8 100644 --- a/src/engine/input.c +++ b/src/engine/input.c @@ -40,7 +40,7 @@ static SDL_Scancode s_bindings[ACTION_COUNT] = { /* Alternate bindings (0 = no alternate) */ static SDL_Scancode s_alt_bindings[ACTION_COUNT] = { - [ACTION_SHOOT] = SDL_SCANCODE_SPACE, + [ACTION_JUMP] = SDL_SCANCODE_SPACE, }; void input_init(void) { diff --git a/web/shell.html b/web/shell.html index 6b2c415..db7625d 100644 --- a/web/shell.html +++ b/web/shell.html @@ -60,6 +60,17 @@ max-width: 1300px; } #hint { color: #666; } + #game-controls { + display: flex; + align-items: center; + gap: 8px; + margin-top: 8px; + font-size: 12px; + color: #666; + flex-wrap: wrap; + justify-content: center; + max-width: 1300px; + } .ctrl-btn { color: #4ecdc4; background: transparent; @@ -100,7 +111,7 @@ -
+ +
+ Arrows=move + | + Z/Space=jump + | + X=shoot + | + C=dash + | + Up=aim up +
Loading...
{{{ SCRIPT }}}