feat: propagate bomb explosion and add shotgun weapon to B button
This commit is contained in:
+43
-16
@@ -78,25 +78,52 @@ void update_bombs(void) {
|
||||
move_sprite(38, px, py);
|
||||
do_explosion_damage(bomb.x, bomb.y);
|
||||
|
||||
if (bomb.y > 0 && maze[bomb.y - 1][bomb.x] == 0) {
|
||||
set_sprite_tile(34, 10);
|
||||
move_sprite(34, px, py - 8);
|
||||
do_explosion_damage(bomb.x, bomb.y - 1);
|
||||
// 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);
|
||||
}
|
||||
do_explosion_damage(bomb.x, yy);
|
||||
}
|
||||
if (bomb.y < MAZE_HEIGHT - 1 && maze[bomb.y + 1][bomb.x] == 0) {
|
||||
set_sprite_tile(35, 10);
|
||||
move_sprite(35, px, py + 8);
|
||||
do_explosion_damage(bomb.x, bomb.y + 1);
|
||||
|
||||
// Giù
|
||||
yy = bomb.y;
|
||||
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);
|
||||
}
|
||||
do_explosion_damage(bomb.x, yy);
|
||||
}
|
||||
if (bomb.x > 0 && maze[bomb.y][bomb.x - 1] == 0) {
|
||||
set_sprite_tile(36, 9);
|
||||
move_sprite(36, px - 8, py);
|
||||
do_explosion_damage(bomb.x - 1, bomb.y);
|
||||
|
||||
// Sinistra
|
||||
uint8_t xx = bomb.x;
|
||||
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);
|
||||
}
|
||||
do_explosion_damage(xx, bomb.y);
|
||||
}
|
||||
if (bomb.x < MAZE_WIDTH - 1 && maze[bomb.y][bomb.x + 1] == 0) {
|
||||
set_sprite_tile(37, 9);
|
||||
move_sprite(37, px + 8, py);
|
||||
do_explosion_damage(bomb.x + 1, bomb.y);
|
||||
|
||||
// Destra
|
||||
xx = bomb.x;
|
||||
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);
|
||||
}
|
||||
do_explosion_damage(xx, bomb.y);
|
||||
}
|
||||
}
|
||||
} else if (bomb.state == BOMB_STATE_EXPLODING) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <gb/gb.h>
|
||||
#include "bomb.h"
|
||||
#include "music.h"
|
||||
#include "rat.h"
|
||||
|
||||
const unsigned char CursorSpriteData[] = {
|
||||
// Bordo quadrato 8x8 (Nero, colore 3 -> 11)
|
||||
@@ -72,6 +73,18 @@ void update_cursor(void) {
|
||||
drop_bomb(cursor_x, cursor_y);
|
||||
}
|
||||
|
||||
// Arma secondaria: Fucile a pompa (Tasto B)
|
||||
static uint16_t shotgun_cooldown = 0;
|
||||
if (shotgun_cooldown > 0) shotgun_cooldown--;
|
||||
|
||||
if ((keys & J_B) && !(previous_keys & J_B)) {
|
||||
if (shotgun_cooldown == 0) {
|
||||
play_sfx_shotgun();
|
||||
kill_rats_at(cursor_x, cursor_y);
|
||||
shotgun_cooldown = 180; // 3 secondi di ricarica a 60 FPS
|
||||
}
|
||||
}
|
||||
|
||||
// Tasto SELECT per attivare/disattivare la musica
|
||||
if ((keys & J_SELECT) && !(previous_keys & J_SELECT)) {
|
||||
toggle_music();
|
||||
|
||||
+1
-4
@@ -247,10 +247,7 @@ void main(void) {
|
||||
|
||||
uint8_t keys = joypad();
|
||||
|
||||
// Debug cheat: forza vittoria con il tasto B
|
||||
if ((keys & J_B) && !(main_prev_keys & J_B)) {
|
||||
victory_flag = 1;
|
||||
}
|
||||
// Debug cheat rimosso: il tasto B ora è usato per l'arma secondaria
|
||||
|
||||
// Controllo per la Pausa
|
||||
if ((keys & J_START) && !(main_prev_keys & J_START)) {
|
||||
|
||||
+15
-5
@@ -588,11 +588,21 @@ void play_game_over_music(void) {
|
||||
}
|
||||
|
||||
void play_sfx_explosion(void) {
|
||||
// Esplosione forte e lunga sul canale 4
|
||||
NR42_REG = 0xF7;
|
||||
NR43_REG = 0x6E;
|
||||
NR44_REG = 0xC0;
|
||||
sfx_timer = 30; // Proteggi CH4 e CH1
|
||||
// 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
|
||||
}
|
||||
|
||||
void play_sfx_shotgun(void) {
|
||||
// Sparo di fucile molto forte, corto e secco sul canale 4
|
||||
NR41_REG = 0x01; // Corto
|
||||
NR42_REG = 0xF2; // Volume max, decadimento super rapido
|
||||
NR43_REG = 0x33; // Frequenza da sparo
|
||||
NR44_REG = 0xC0; // Trigger
|
||||
sfx_timer = 20;
|
||||
}
|
||||
|
||||
void play_sfx_bomb_drop(void) {
|
||||
|
||||
@@ -9,6 +9,7 @@ void play_sfx_moan(void);
|
||||
void play_sfx_plop(void);
|
||||
void play_sfx_explosion(void);
|
||||
void play_sfx_bomb_drop(void);
|
||||
void play_sfx_shotgun(void);
|
||||
|
||||
void play_game_over_music(void);
|
||||
void play_title_music(void);
|
||||
|
||||
Reference in New Issue
Block a user