Make home-page snake game playable on mobile - #5
Merged
Conversation
|
Add touch controls (tap to start, swipe to steer) alongside the existing keyboard input, refactor the game loop into start/move functions, fix the missing #flashing element reference that threw on start, and reposition the game screen on small viewports.
Render each row on its own line with white-space: pre so the monospace grid no longer wraps mid-row and splits tiles across two columns on mobile. Also render the initial grid on start.
Show the desktop-PC ASCII art on small screens again by wrapping the art and game overlay in a shared .scene container that is scaled down to fit the viewport, keeping the game rendered on the monitor screen instead of hiding the art.
Lower the ASCII art on small screens so its top edge no longer tucks behind the header icons, and reduce the top margin of the intro card so the text sits closer to the game instead of leaving a large gap.
Standardize the site logo, work/posts links and theme toggle to the same height and vertical position so the header row lines up, and hide the 'hello world' easter-egg text so only the play prompt is shown.
stefkn
force-pushed
the
feat/mobile-snake-controls
branch
from
August 31, 2026 07:20
236a981 to
6488c07
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The ASCII snake game on the home page was keyboard-only (press 'g' to start, WASD to move), so it was unusable on mobile.
Changes
startGame()+move(key)so keyboard and touch share the same logic (instead of faking aKeyboardEventfor the auto-move interval).#flashingwas referenced but never existed in the markup, which threw aTypeErrorthe moment the game started..screen-contentonmax-width: 700pxso the game is actually visible on phones.touch-action: none(toggled via a.playingclass) prevents the page from scrolling/zooming during swipes.Notes
id="background"(one inindex.astro, one inIndexBackground.astro) predates this change; touch listeners bind to the first (outer) element and events bubble, so it still works.Testing
npx astro check— 0 errors.npx astro build— succeeds; touch handlers/hints present in the bundle.