cleanup
This commit is contained in:
parent
0b905f2690
commit
e8ed3e0faf
6 changed files with 25 additions and 52 deletions
|
|
@ -63,16 +63,9 @@ void spawnBullet(struct bulletSpawner spawner, void(*updater)){
|
|||
bullets[i].active = TRUE;
|
||||
bullets[i].pos.x = spawner.x;
|
||||
bullets[i].pos.y = spawner.y;
|
||||
bullets[i].speed = spawner.speed;
|
||||
bullets[i].angle = spawner.angle;
|
||||
bullets[i].player = spawner.player;
|
||||
bullets[i].explosion = FALSE;
|
||||
bullets[i].clock = 0;
|
||||
for(u8 j = 0; j < COUNT_INT; j++){
|
||||
bullets[i].bools[j] = spawner.bools[j];
|
||||
bullets[i].ints[j] = spawner.ints[j];
|
||||
bullets[i].fixes[j] = spawner.fixes[j];
|
||||
}
|
||||
if(spawner.vel.x || spawner.vel.y){
|
||||
bullets[i].vel.x = spawner.vel.x;
|
||||
bullets[i].vel.y = spawner.vel.y;
|
||||
|
|
@ -146,6 +139,19 @@ static void updateBullet(u8 i){
|
|||
bullets[i].pos.x += GAME_WRAP;
|
||||
}
|
||||
|
||||
// Cull bullets that go off-screen
|
||||
// Horizontal: use wrapped distance to handle world wrap correctly
|
||||
fix32 dx = getWrappedDelta(bullets[i].pos.x, player.pos.x);
|
||||
bool offScreenX = (dx < FIX32(-256) || dx > FIX32(256));
|
||||
|
||||
// Vertical: simple linear check (no Y wrapping)
|
||||
bool offScreenY = (bullets[i].pos.y < FIX32(-16) || bullets[i].pos.y > GAME_H_F + FIX32(16));
|
||||
|
||||
if(offScreenX || offScreenY){
|
||||
killBullet(i);
|
||||
return; // Skip rest of update for culled bullet
|
||||
}
|
||||
|
||||
if(bullets[i].clock > 0) bullets[i].updater(i);
|
||||
if(bullets[i].player) collideWithEnemy(i);
|
||||
else collideWithPlayer(i);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue