Your place is saved automatically on this browser.
With the movement animation working, the next major architectural step is to stop treating x and y as the game state. Pixel coordinates are good for smooth animation, but puzzle rules need stable tile coordinates.
Two coordinate systems
| Coordinate | Purpose | Current example |
|---|---|---|
| playerTileX / playerTileY | Authoritative logical game position. Used for collision, phase rules, scoring, visited tiles and enemies. | Start at (9,7). |
| x / y | Transient hardware-sprite position used while animating between tiles. | Start at (144,112). |
The relationship is currently straightforward because the grid origin is pixel (0,0) and each tile is 16 pixels square:
Current tile-to-pixel mapping
x = playerTileX * tileSize
y = playerTileY * tileSize
tileSize = 16Why 20×16?
The hardware sprite coordinate area used by the current test is 320 pixels wide by 256 pixels high. Dividing by 16 gives 20 columns and 16 rows. Therefore the valid logical coordinates are X = 0 to 19 and Y = 0 to 15.
Logical-grid dimensions
NextBASIC array bounds are written using the highest valid index, so levelMap(19,15) provides entries 0–19 by 0–15: 20×16 logical tile positions.
Initialisation changes
v0.10 grid state
Approve the destination before animating
The directional procedures no longer decide whether a pixel coordinate is inside the screen. Instead they request a logical move. attemptMove calculates the target tile, checks the logical boundaries, and calls animateMove only if the destination is legal.
v0.10 logical movement approval
The recalculation of x and y on lines 6120–6130 is intentional. During animation x/y are advanced one pixel at a time. At the end of the move they are normalised from the authoritative tile coordinate. This prevents cumulative pixel drift if the animation code is ever changed.
Direction procedures become simple requests
Direction → tile delta → directional pattern block
Debugging the logical state
v0.10 prints the current logical tile coordinate on the third text row. This is intentionally a development aid, not a proposed final HUD element.
Temporary tile-coordinate display
Hardware acceptance checks for v0.10
- Every successful key press still moves exactly one tile.
- The displayed logical coordinate changes by exactly one on the expected axis.
- Moving away from a tile and returning to it restores exactly the same pixel position.
- The v0.9 lean/travel/recover animation still looks correct.
- The player cannot move past X 0 or X 19.
- The player cannot move past Y 0 or Y 15.
- A rejected boundary move does not animate or alter the logical coordinate.
