collision-and-physics

Guides implementation of ball collision, rebound physics, and game-state logic in Z80 assembly Breakout code.

Updated Nov 29, 2024
One-click install
npx skills add https://github.com/SpeedRD/Arkanoid_Z80 --skill collision-and-physics-speedrd
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: collision-and-physics
Source: https://github.com/SpeedRD/Arkanoid_Z80/tree/main/.claude/skills/collision-and-physics
Command: npx skills add https://github.com/SpeedRD/Arkanoid_Z80 --skill collision-and-physics-speedrd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Modifying the collision and physics code of a Z80 assembly Breakout game (colisiones.asm, pelota.asm) is error-prone: subtle invariants around fixed-point velocity, attribute-based cell classification, and stack discipline have each caused real shipped bugs. This Skill documents the implemented design, the invariants tests enforce, and the reasoning that constrains any change. ## Core Features & Use Cases - Physics invariants reference: Documents the 8.8 fixed-point position/velocity model, the |v|=256 magnitude rule, one-cell-per-frame step limit, and non-zero row velocity requirement. - Collision semantics: Explains position-first cell classification, two-cell brick destruction with single decrement, colour-8 indestructible bricks, and the seven-entry paddle rebound table. - Game-flow rules: Covers lethal floor handling, lives, game over vs completion screens, reset routine responsibilities, and the jp-not-call rule for leaving the frame loop. - Use Case: Before changing the paddle rebound angle or adding a level, consult the pre-change checklist (§12) to verify the erase-restore test, wall range comparisons, and rebound table variety still hold. ## Quick Start Ask the assistant to review a planned change to colisiones.asm against the collision-and-physics checklist before editing the assembly code.

Frequently Asked Questions about collision-and-physics

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I change the ball rebound angle in a Breakout game?

Edit the seven-entry rebound_table mapping paddle hit index 0-6 to velocity pairs, keeping |v| at exactly 256 for every entry. Never flatten the table to a single angle, because variable rebound is what makes clearing all bricks solvable rather than map-determined.

How do I make the ball faster in a fixed-point assembly game?

Do not increase the velocity magnitude beyond 256, since one cell per frame is the maximum step and shallow angles cannot reach higher magnitudes. Instead, shorten the frame delay in the timing loop to speed up the ball.

Why does the ball pass through bricks without colliding?

This happens when a velocity component exceeds $0100, so the ball steps more than one cell per frame and skips the cell containing the brick. Keep |velocity| at or below $0100 on each axis.

Why does the ball leave a trail erasing bricks and borders?

The erase step must write back the saved attribute byte (BallSaved), not zero. Writing 0 paints the cell black and destroys whatever was underneath, since the playfield is the attribute file with no background layer.

Can bricks be identified by their attribute colour value?

No. Attribute values are ambiguous: $38 is both the ball and colour-7 bricks, $10 is the paddle or a colour-2 brick, and $00 is empty or a destroyed brick. Classification must test position first and consult the attribute only after ruling out border and paddle rows.

When should the shadow-map fallback be used instead of attribute-based collision?

Only when per-brick state exceeds one attribute byte (such as multi-hit bricks), when position-first classification stops being reliable, or when counting bricks cheaply becomes impossible. Otherwise the attribute file remains the single source of truth.