cleanup
This commit is contained in:
parent
30734885e4
commit
b2c0eaf30b
3 changed files with 6 additions and 34 deletions
|
|
@ -94,14 +94,11 @@ s32 bulletDist;
|
|||
static void collideWithEnemy(u8 i){
|
||||
for(s16 j = 0; j < ENEMY_COUNT; j++) {
|
||||
if(enemies[j].active){
|
||||
// Calculate wrapped distances
|
||||
fix32 deltaX = getWrappedDelta(bullets[i].pos.x, enemies[j].pos.x);
|
||||
fix32 deltaY = bullets[i].pos.y - enemies[j].pos.y;
|
||||
|
||||
// Quick bounding box check using wrapped distance
|
||||
if(deltaY >= -BULLET_CHECK && deltaY <= BULLET_CHECK &&
|
||||
deltaX >= -BULLET_CHECK && deltaX <= BULLET_CHECK){
|
||||
// Precise distance check
|
||||
bulletDist = getApproximatedDistance(
|
||||
fix32ToInt(deltaX),
|
||||
fix32ToInt(deltaY));
|
||||
|
|
@ -122,7 +119,7 @@ static void collideWithPlayer(u8 i){
|
|||
s32 dist = getApproximatedDistance(
|
||||
fix32ToInt(deltaX),
|
||||
fix32ToInt(deltaY));
|
||||
if(dist <= 4){ // Player hit radius
|
||||
if(dist <= 4){
|
||||
killBullet(i);
|
||||
// player.lives--;
|
||||
// if(player.lives <= 0) gameOver = TRUE;
|
||||
|
|
@ -134,7 +131,6 @@ static void updateBullet(u8 i){
|
|||
bullets[i].pos.x += bullets[i].vel.x;
|
||||
bullets[i].pos.y += bullets[i].vel.y;
|
||||
|
||||
// Wrap bullet position
|
||||
if(bullets[i].pos.x >= GAME_WRAP){
|
||||
bullets[i].pos.x -= GAME_WRAP;
|
||||
}
|
||||
|
|
@ -142,19 +138,15 @@ 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
|
||||
return;
|
||||
}
|
||||
|
||||
if(bullets[i].clock > 0) bullets[i].updater(i);
|
||||
if(bullets[i].player) collideWithEnemy(i);
|
||||
else collideWithPlayer(i);
|
||||
|
|
@ -162,12 +154,6 @@ static void updateBullet(u8 i){
|
|||
s16 sx = getScreenX(bullets[i].pos.x, player.camera);
|
||||
s16 sy = fix32ToInt(bullets[i].pos.y);
|
||||
u8 off = bullets[i].player ? P_BULLET_OFF : BULLET_OFF;
|
||||
|
||||
// Set visibility to prevent VDP 512px wrap ghosting
|
||||
// bool onScreen = (sx >= VISIBLE_X_MIN && sx <= VISIBLE_X_MAX &&
|
||||
// sy >= VISIBLE_Y_MIN && sy <= VISIBLE_Y_MAX);
|
||||
// SPR_setVisibility(bullets[i].image, onScreen ? VISIBLE : HIDDEN);
|
||||
|
||||
SPR_setPosition(bullets[i].image, sx - off, sy - off);
|
||||
bullets[i].clock++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue