Fix off-screen enemy invisibility with modulo 256 scroll wrapping

This commit is contained in:
2026-06-22 20:02:58 +02:00
parent c98363126b
commit e07e8c6e56
+3 -3
View File
@@ -402,9 +402,9 @@ void engine_update(uint8_t keys, uint8_t prev_keys) {
enemy_py = (enemy_lx + enemy_ly) * 8 + 16; enemy_py = (enemy_lx + enemy_ly) * 8 + 16;
} }
// Add player centering offset (+24, +16) to align with player sprite at (88, 88) // Add player centering offset (+24, +16) to align with player sprite at (88, 88), wrapping coordinates to 256
int16_t enemy_screen_x = enemy_px - scroll_x + 24; int16_t enemy_screen_x = ((enemy_px - scroll_x) & 255) + 24;
int16_t enemy_screen_y = enemy_py - scroll_y + 16; int16_t enemy_screen_y = ((enemy_py - scroll_y) & 255) + 16;
// Determine player-enemy distance for visibility masking // Determine player-enemy distance for visibility masking
int8_t edx = (int8_t)player_lx - (int8_t)enemy_lx; int8_t edx = (int8_t)player_lx - (int8_t)enemy_lx;