Skip to content

buddy/apps: add brickbreaker game - #4

Open
lisabee123 wants to merge 1 commit into
moremas:mainfrom
lisabee123:apps/brickbreaker
Open

buddy/apps: add brickbreaker game#4
lisabee123 wants to merge 1 commit into
moremas:mainfrom
lisabee123:apps/brickbreaker

Conversation

@lisabee123

Copy link
Copy Markdown

Summary

Adds a Breakout-style game to buddy/device/apps/ — fourth app in the suite alongside Claude Buddy, Hello, and Snake. Single self-contained file, same chrome / input model / exit pattern as the other apps so the launcher picks it up automatically and it feels like a native member of the bundle.

Tested live on a Cardputer-Adv provisioned with this bundle.

What's in it

  • 240×135 layout: 20 px DARK header with the shared ORANGE hairline at y=20, 8×4 brick wall up top, paddle along the bottom above the standard hint strip.
  • Inputs via MatrixKeyboard polled at 40 ms (the loop shape snake.py and hello_cardputer.py already use). Two control schemes:
    • A/D to move (gamer default)
    • , / / as the Cardputer arrow-cluster equivalents
    • W / ; / Space to launch the ball and to restart from the end screen
    • Q / ESC to exit (via machine.reset() in finally, the same no-return-to-launcher fallback claude_buddy and snake use)
  • 32-brick wall, 3 lives, 5-zone paddle reflection (edges deflect at the steepest angle, center bounces straight up).
  • AABB ball↔brick collision with dominant-axis reversal — picks whichever side the ball penetrated deeper that frame so the ball doesn't visually clip through brick corners on diagonal hits.
  • Top row scores 4, bottom row 1 (the bottom row geometrically clears first; rewarding the harder-to-reach rows).

Why a fourth app

The bundle was built around BLE (Claude Buddy) plus a couple of offline games for attendees who haven't unlocked the Claude Desktop dev menu yet. Snake covers grid-based; brickbreaker covers timing-and-aim. Both pure-LCD-and-keyboard so they work without WiFi or Claude Desktop, which matters at events where the network is the most flaky thing in the room.

Notes for review

  • No new shared modules. The bundle's existing peer files (buddy_ble.py, buddy_chars.py, etc.) aren't touched. brickbreaker.py inlines its own palette so it can be installed standalone via install_apps.py --src <path> if someone wants only the game.
  • Layout math is documented in the module docstring — pixel-precise layout for 240×135 is fiddly enough that rederiving it from the code is annoying.
  • Physics tuning: 2 px/axis per tick at 40 ms (50 px/s) and a 7 px brick height was chosen so every brick row is hit reliably without an inter-tick collision sweep. If you want it faster, bump _BALL_STEP — but watch for tunneling at any value where _BALL_STEP * 2 >= _BRICK_H.

Test plan

  • python -m py_compile buddy/device/apps/brickbreaker.py passes
  • Pushed to a Cardputer-Adv via install_apps.py --src buddy; appears in the launcher
  • Playtest pass: confirm 5-zone paddle reflection feels right, bricks don't clip on diagonals, all-clear win screen and 3-lives game-over both reachable
  • Confirm Q / ESC exit cleanly drops back to the launcher (no last-frame flash)

🤖 Generated with Claude Code

A self-contained breakout-style game alongside snake.py /
hello_cardputer.py. Same suite conventions:

- 240x135 chrome, ORANGE hairline header, hint strip footer,
  shared 5-color palette so it reads as part of the same device.
- MatrixKeyboard polled at 40 ms with `kb.tick()` + `kb.get_key()`.
  Two control schemes:
    A/D            (gamer default)
    `,` / `/`      (Cardputer arrow-cluster glyphs)
  W / `;` / Space launches the ball and acts as restart on the
  end screen. Q / ESC exits via `machine.reset()` in `finally`,
  same no-return-to-launcher pattern UIFlow 2.0 forces on us.
- Single file in buddy/device/apps/ — no shared peer modules, so
  it installs with one `install_apps.py` upload.

Gameplay: 8x4 brick wall (32 bricks), 3 lives, 5-zone paddle
reflection, AABB ball-brick collision with dominant-axis reversal
to avoid corner-clip artifacts. Top row scores 4, bottom 1 (top
is hardest to reach last). Ball steps 2 px/axis at 40 ms = 50 px/s
per axis, fast enough to play, slow enough that all collisions
register at 7 px brick height.

Tested via py_compile; behavior tested live on a Cardputer-Adv
provisioned with this bundle.
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.

1 participant