CLIGUI 2025-01-05 23:10 (Edited)
This example shows how to detect if a sprite is touching a cell on a moving background. Turn on debug mode to view the cell number.
How it works:
First the scroll coordinates are divided by 8 turning them into cell coordinates, then theses X and Y value are each offset so that they are at the sprites location (rather then the upper left corner of the screen). This is done by adding the cell X and Y values of the sprite to the cell X and Y values from the scroller.
The obstacles (any character after 15 in the sprite registry) stop the sprite by only allowing It to move when the cell, in the direction it is moving, is before 15 on the sprite registry.
Notes:
How much overlap is needed to detect what cell the sprite is on varies. To fix this the sprite must move with the cell grid and be placed in the center of a cell.
In the first example the sprite Is not moving with the cell grid. To view the cell grid draw a square frame in the first cell of the GFX designer.