fix: resolve explosion range and audio issues with shotgun/bomb
This commit is contained in:
+31
-18
@@ -19,11 +19,17 @@ typedef struct {
|
||||
|
||||
static Bomb bomb;
|
||||
|
||||
static const uint8_t exp_sprite_pool[] = {
|
||||
20, 21, 22, 23, 29, 30, 31, 32, 33, 34, 35, 36, 37
|
||||
};
|
||||
#define EXP_POOL_SIZE 13
|
||||
|
||||
void init_bombs(void) {
|
||||
bomb.state = BOMB_STATE_INACTIVE;
|
||||
set_sprite_data(5, 6, BombSpriteData);
|
||||
for(uint8_t i = 34; i <= 38; i++) {
|
||||
move_sprite(i, 0, 0);
|
||||
move_sprite(38, 0, 0); // Bomba centrale
|
||||
for(uint8_t i = 0; i < EXP_POOL_SIZE; i++) {
|
||||
move_sprite(exp_sprite_pool[i], 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,9 +43,10 @@ void drop_bomb(uint8_t x, uint8_t y) {
|
||||
}
|
||||
}
|
||||
|
||||
static void hide_explosion() {
|
||||
for(uint8_t i = 34; i <= 38; i++) {
|
||||
move_sprite(i, 0, 0);
|
||||
static void hide_explosion(void) {
|
||||
move_sprite(38, 0, 0);
|
||||
for(uint8_t i = 0; i < EXP_POOL_SIZE; i++) {
|
||||
move_sprite(exp_sprite_pool[i], 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,18 +81,21 @@ void update_bombs(void) {
|
||||
|
||||
play_sfx_explosion();
|
||||
|
||||
set_sprite_tile(38, 8);
|
||||
set_sprite_tile(38, 8); // Centro esplosione
|
||||
move_sprite(38, px, py);
|
||||
do_explosion_damage(bomb.x, bomb.y);
|
||||
|
||||
uint8_t pool_idx = 0;
|
||||
|
||||
// Su
|
||||
uint8_t yy = bomb.y;
|
||||
while (yy > 0) {
|
||||
yy--;
|
||||
if (maze[yy][bomb.x] != 0) break;
|
||||
if (yy == bomb.y - 1) {
|
||||
set_sprite_tile(34, 10);
|
||||
move_sprite(34, px, py - 8);
|
||||
if (pool_idx < EXP_POOL_SIZE) {
|
||||
uint8_t sp = exp_sprite_pool[pool_idx++];
|
||||
set_sprite_tile(sp, 10); // Fiamma verticale
|
||||
move_sprite(sp, px, (yy * 8) + 20);
|
||||
}
|
||||
do_explosion_damage(bomb.x, yy);
|
||||
}
|
||||
@@ -95,9 +105,10 @@ void update_bombs(void) {
|
||||
while (yy < MAZE_HEIGHT - 1) {
|
||||
yy++;
|
||||
if (maze[yy][bomb.x] != 0) break;
|
||||
if (yy == bomb.y + 1) {
|
||||
set_sprite_tile(35, 10);
|
||||
move_sprite(35, px, py + 8);
|
||||
if (pool_idx < EXP_POOL_SIZE) {
|
||||
uint8_t sp = exp_sprite_pool[pool_idx++];
|
||||
set_sprite_tile(sp, 10); // Fiamma verticale
|
||||
move_sprite(sp, px, (yy * 8) + 20);
|
||||
}
|
||||
do_explosion_damage(bomb.x, yy);
|
||||
}
|
||||
@@ -107,9 +118,10 @@ void update_bombs(void) {
|
||||
while (xx > 0) {
|
||||
xx--;
|
||||
if (maze[bomb.y][xx] != 0) break;
|
||||
if (xx == bomb.x - 1) {
|
||||
set_sprite_tile(36, 9);
|
||||
move_sprite(36, px - 8, py);
|
||||
if (pool_idx < EXP_POOL_SIZE) {
|
||||
uint8_t sp = exp_sprite_pool[pool_idx++];
|
||||
set_sprite_tile(sp, 9); // Fiamma orizzontale
|
||||
move_sprite(sp, (xx * 8) + 12, py);
|
||||
}
|
||||
do_explosion_damage(xx, bomb.y);
|
||||
}
|
||||
@@ -119,9 +131,10 @@ void update_bombs(void) {
|
||||
while (xx < MAZE_WIDTH - 1) {
|
||||
xx++;
|
||||
if (maze[bomb.y][xx] != 0) break;
|
||||
if (xx == bomb.x + 1) {
|
||||
set_sprite_tile(37, 9);
|
||||
move_sprite(37, px + 8, py);
|
||||
if (pool_idx < EXP_POOL_SIZE) {
|
||||
uint8_t sp = exp_sprite_pool[pool_idx++];
|
||||
set_sprite_tile(sp, 9); // Fiamma orizzontale
|
||||
move_sprite(sp, (xx * 8) + 12, py);
|
||||
}
|
||||
do_explosion_damage(xx, bomb.y);
|
||||
}
|
||||
|
||||
@@ -75,12 +75,26 @@ void update_cursor(void) {
|
||||
|
||||
// Arma secondaria: Fucile a pompa (Tasto B)
|
||||
static uint16_t shotgun_cooldown = 0;
|
||||
static uint8_t shotgun_blast_timer = 0;
|
||||
|
||||
if (shotgun_cooldown > 0) shotgun_cooldown--;
|
||||
if (shotgun_blast_timer > 0) {
|
||||
shotgun_blast_timer--;
|
||||
if (shotgun_blast_timer == 0) {
|
||||
move_sprite(24, 0, 0); // Nascondi l'effetto sparo
|
||||
}
|
||||
}
|
||||
|
||||
if ((keys & J_B) && !(previous_keys & J_B)) {
|
||||
if (shotgun_cooldown == 0) {
|
||||
play_sfx_shotgun();
|
||||
kill_rats_at(cursor_x, cursor_y);
|
||||
|
||||
// Mostra l'effetto dello sparo (usiamo lo sprite 24 e il tile 8 che è il centro dell'esplosione)
|
||||
set_sprite_tile(24, 8);
|
||||
move_sprite(24, cursor_x * 8 + 12, cursor_y * 8 + 20);
|
||||
shotgun_blast_timer = 15; // Visibile per un quarto di secondo
|
||||
|
||||
shotgun_cooldown = 180; // 3 secondi di ricarica a 60 FPS
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -589,29 +589,29 @@ void play_game_over_music(void) {
|
||||
|
||||
void play_sfx_explosion(void) {
|
||||
// Esplosione molto forte e lunga sul canale 4
|
||||
NR41_REG = 0x3F; // Lunghezza
|
||||
NR42_REG = 0xF7; // Volume max, decadimento lento
|
||||
NR43_REG = 0x47; // Frequenza bassa/rumore scuro
|
||||
NR44_REG = 0xC0; // Trigger
|
||||
sfx_timer = 40; // Proteggi CH4 e CH1
|
||||
NR41_REG = 0x00;
|
||||
NR42_REG = 0xF7; // Volume max (0xF), decay lento (7)
|
||||
NR43_REG = 0x57; // Rumore molto basso e cupo
|
||||
NR44_REG = 0x80; // Trigger (senza length counter)
|
||||
sfx_timer = 45; // Proteggi CH4
|
||||
}
|
||||
|
||||
void play_sfx_shotgun(void) {
|
||||
// Sparo di fucile molto forte, corto e secco sul canale 4
|
||||
NR41_REG = 0x01; // Corto
|
||||
NR41_REG = 0x00;
|
||||
NR42_REG = 0xF2; // Volume max, decadimento super rapido
|
||||
NR43_REG = 0x33; // Frequenza da sparo
|
||||
NR44_REG = 0xC0; // Trigger
|
||||
NR43_REG = 0x22; // Rumore bianco medio, secco
|
||||
NR44_REG = 0x80; // Trigger (senza length counter)
|
||||
sfx_timer = 20;
|
||||
}
|
||||
|
||||
void play_sfx_bomb_drop(void) {
|
||||
// Un suono di innesco "tsst" (miccia)
|
||||
NR41_REG = 0x01; // Corto
|
||||
NR41_REG = 0x00;
|
||||
NR42_REG = 0xA2; // Volume alto, decadimento rapido
|
||||
NR43_REG = 0x22; // Frequenza alta, noise
|
||||
NR44_REG = 0xC0; // Trigger
|
||||
sfx_timer = 15; // Proteggi per la durata del suono
|
||||
NR43_REG = 0x12; // Frequenza alta, sibilo
|
||||
NR44_REG = 0x80; // Trigger (senza length counter)
|
||||
sfx_timer = 15;
|
||||
}
|
||||
|
||||
void play_title_music(void) {
|
||||
|
||||
Reference in New Issue
Block a user