hot-path perf: skip off-screen enemies in bullet collision; null-check bullet updaters; dedupe wrapped delta in updateEnemy

This commit is contained in:
t. boddy 2026-05-04 18:29:32 -04:00
parent 86935184b2
commit d317938047
5 changed files with 41 additions and 45 deletions

View file

@ -315,11 +315,10 @@ static void updateEnemy(u8 i){
break;
}
// enemy->player collision
// enemy->player collision (reuses dx from above — position unchanged this frame)
if(enemies[i].onScreen && !gameOver && player.recoveringClock == 0 && player.respawnClock == 0){
fix32 edx = getWrappedDelta(enemies[i].pos.x, player.pos.x);
fix32 edy = enemies[i].pos.y - player.pos.y;
if(edx >= FIX32(-16) && edx <= FIX32(16) && edy >= FIX32(-16) && edy <= FIX32(16)){
if(dx >= FIX32(-16) && dx <= FIX32(16) && edy >= FIX32(-16) && edy <= FIX32(16)){
sfxExplosion();
// spawn big explosion at player position
spawnExplosion(player.pos.x, player.pos.y, 3, TRUE); // yellow