Skip to content

feat: add mobile joystick and jump button - #58

Merged
theghost1980 merged 1 commit into
mainfrom
codex/add-mobile-joystick-and-jump-button
Feb 8, 2026
Merged

theghost1980 merged 1 commit into
mainfrom
codex/add-mobile-joystick-and-jump-button

Conversation

@saturnoTest

Copy link
Copy Markdown
Member

Motivation

  • Provide touch-friendly on-screen controls (joystick + jump button) for mobile/touch devices without changing existing desktop keyboard/pointer gameplay.
  • Ensure controls only appear on touch-capable devices or narrow viewports so desktop behavior remains unchanged.
  • Reuse existing UI assets (e.g. UI_ROUND_FLAT) and respect uiScale/resize so controls are non-intrusive.

Description

  • Added mobile control constants and state to GameScene and a shouldUseMobileControls check using this.sys.game.device.input.touch, this.input.pointer1?.wasTouch and viewportWidth < 520 as fallback.
  • Implemented createMobileControls, layoutMobileControls, updateJoystick, resetJoystick, and tryJump to create a bottom-left joystick (base + thumb using UI_ROUND_FLAT) and a bottom-right JUMP button, with scrollFactor=0, alpha, sizing, and safe margins.
  • Joystick interaction: pointer down/move/up handlers clamp thumb movement to a radius, normalize X to [-1..1], apply a deadzone (0.15) and set moveDirection to -1/0/1 accordingly; jump button calls tryJump which enforces grounded jump and plays jump SFX.
  • Integrated with existing input: when mobile controls are enabled the old full-screen pointer-down/up movement handlers are not registered to avoid conflicts; desktop keyboard (A/D/SPACE) remains unchanged; controls are repositioned on handleResize and joystick is reset on game over.

Testing

  • Ran npm run typecheck (invokes tsc) and it completed successfully with no type errors.
  • Ran npm run build (invokes tsc -b and vite build) and it completed successfully producing a production bundle.
  • Captured a headless mobile snapshot using Playwright emulation to verify the joystick and jump button render in a mobile viewport, and the script completed successfully.

Codex Task

@saturnoTest
saturnoTest requested a review from a team February 8, 2026 01:28
@theghost1980
theghost1980 merged commit 717754f into main Feb 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants