Z80 Assembly 37: Tile-Based Collision and Map Boundaries

Collision on a Tilemap In a tile-based game, collision detection isn’t just about object-to-object overlap; it’s about checking if a moving sprite is trying to occupy a tile marked as solid (e.g., a wall, water, or rock). The Core Logic: Before updating a sprite’s position, check the Tile ID at the new (target) location. Step 1: Converting Sprite Position to Tile Index The first challenge is converting the sprite’s precise pixel coordinates (X, Y) into the coarse array index needed to read the tilemap. ...

September 27, 2025

Z80 Assembly 35: Collision Resolution (Bouncing and Stopping Movement)

The Need for Resolution Collision Detection (Part 26) only tells you that two objects overlap. Collision Resolution is the logic that moves the objects apart and adjusts their speed (velocity) so that they don’t overlap in the next frame. Without resolution, sprites will get stuck inside walls. Step 1: Backtracking (The Safest Move) The most reliable way to resolve an overlap is to simply move the collided object back to its previous, non-colliding position. ...

September 27, 2025

Z80 Assembly 26: Collision Detection (Bounding Boxes and Bitwise Checks)

Bounding Box Collision (The Quick Check) Collision detection is computationally expensive. The fastest method is the Bounding Box check. This method checks if the rectangular area occupied by two objects (their boxes) overlap on the X and Y axes. If the boxes don’t overlap, the objects cannot be touching. The Principle: An overlap exists if: Object A’s right edge (A.X + A.Width) is > Object B’s left edge (B.X), AND Object A’s left edge (A.X) is < Object B’s right edge (B.X + B.Width), AND The same two conditions are met for the Y-axis. Z80 Implementation (X-Axis Check): ...

September 27, 2025