diff --git a/assets/sounds/block1.wav b/assets/sounds/block1.wav deleted file mode 100644 index 8008803..0000000 Binary files a/assets/sounds/block1.wav and /dev/null differ diff --git a/assets/sounds/block2.wav b/assets/sounds/block2.wav deleted file mode 100644 index e133a6a..0000000 Binary files a/assets/sounds/block2.wav and /dev/null differ diff --git a/assets/sounds/block3.wav b/assets/sounds/block3.wav deleted file mode 100644 index 4a3e1e6..0000000 Binary files a/assets/sounds/block3.wav and /dev/null differ diff --git a/assets/sounds/crit.wav b/assets/sounds/crit.wav deleted file mode 100644 index d38dd49..0000000 Binary files a/assets/sounds/crit.wav and /dev/null differ diff --git a/assets/sounds/dodge1.wav b/assets/sounds/dodge1.wav deleted file mode 100644 index 05b1f71..0000000 Binary files a/assets/sounds/dodge1.wav and /dev/null differ diff --git a/assets/sounds/dodge2.wav b/assets/sounds/dodge2.wav deleted file mode 100644 index 942ba60..0000000 Binary files a/assets/sounds/dodge2.wav and /dev/null differ diff --git a/assets/sounds/dodge3.wav b/assets/sounds/dodge3.wav deleted file mode 100644 index 9b0a8c0..0000000 Binary files a/assets/sounds/dodge3.wav and /dev/null differ diff --git a/assets/sounds/itempickup.wav b/assets/sounds/itempickup.wav deleted file mode 100644 index 714878e..0000000 Binary files a/assets/sounds/itempickup.wav and /dev/null differ diff --git a/assets/sounds/levelcomplete.wav b/assets/sounds/levelcomplete.wav deleted file mode 100644 index f3abfd0..0000000 Binary files a/assets/sounds/levelcomplete.wav and /dev/null differ diff --git a/assets/sounds/sword1.wav b/assets/sounds/sword1.wav deleted file mode 100644 index 6afe429..0000000 Binary files a/assets/sounds/sword1.wav and /dev/null differ diff --git a/assets/sounds/sword2.wav b/assets/sounds/sword2.wav deleted file mode 100644 index b4d997f..0000000 Binary files a/assets/sounds/sword2.wav and /dev/null differ diff --git a/assets/sounds/sword3.wav b/assets/sounds/sword3.wav deleted file mode 100644 index 633b2ac..0000000 Binary files a/assets/sounds/sword3.wav and /dev/null differ diff --git a/assets/sounds/uiclick1.wav b/assets/sounds/uiclick1.wav deleted file mode 100644 index e431c89..0000000 Binary files a/assets/sounds/uiclick1.wav and /dev/null differ diff --git a/assets/sounds/uiclick2.wav b/assets/sounds/uiclick2.wav deleted file mode 100644 index 485932c..0000000 Binary files a/assets/sounds/uiclick2.wav and /dev/null differ diff --git a/src/audio.c b/src/audio.c index 36db553..b273369 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1,6 +1,5 @@ #include "audio.h" #include "raylib.h" -#include "common.h" #include #include @@ -71,79 +70,50 @@ void audio_play_move(void) { play_tone(200.0f, 0.05f, 0.3f); } -void audio_play_attack(GameState *gs) { +void audio_play_attack(void) { // Mid-range hit sound - // play_tone(400.0f, 0.1f, 0.5f); - int choice = GetRandomValue(1, 3); - switch (choice) { - case 1: - PlaySound(gs->sounds.attack1); - break; - case 2: - PlaySound(gs->sounds.attack2); - break; - case 3: - PlaySound(gs->sounds.attack3); - break; - default: - PlaySound(gs->sounds.attack1); - break; - } + play_tone(400.0f, 0.1f, 0.5f); } -void audio_play_item_pickup(GameState *gs) { +void audio_play_item_pickup(void) { // High-pitched pickup sound - PlaySound(gs->sounds.pickup); + play_tone(800.0f, 0.15f, 0.4f); } -void audio_play_enemy_death(GameState *gs) { +void audio_play_enemy_death(void) { // Descending death sound play_tone(300.0f, 0.1f, 0.5f); play_tone(150.0f, 0.15f, 0.4f); } -void audio_play_player_damage(GameState *gs) { +void audio_play_player_damage(void) { // Harsh damage sound play_tone(150.0f, 0.1f, 0.6f); play_tone(100.0f, 0.1f, 0.4f); } -void audio_play_stairs(GameState *gs) { +void audio_play_stairs(void) { // Ascending stairs sound - PlaySound(gs->sounds.staircase); + play_tone(400.0f, 0.1f, 0.3f); + play_tone(600.0f, 0.1f, 0.3f); + play_tone(800.0f, 0.15f, 0.3f); } -void audio_play_dodge(GameState *gs) { +void audio_play_dodge(void) { // High-pitched whoosh - // play_tone(900.0f, 0.08f, 0.3f); - int choice = GetRandomValue(1, 3); - switch (choice) { - case 1: - PlaySound(gs->sounds.dodge1); - break; - case 2: - PlaySound(gs->sounds.dodge2); - break; - case 3: - PlaySound(gs->sounds.dodge3); - break; - default: - PlaySound(gs->sounds.dodge1); - break; - } - return; + play_tone(900.0f, 0.08f, 0.3f); } -void audio_play_block(GameState *gs) { +void audio_play_block(void) { // Low-then-mid metallic clang play_tone(250.0f, 0.06f, 0.5f); play_tone(350.0f, 0.04f, 0.3f); } -void audio_play_crit(GameState *gs) { +void audio_play_crit(void) { // Sharp crack with high-pitched follow - audio_play_attack(gs); - PlaySound(gs->sounds.crit); + play_tone(600.0f, 0.05f, 0.7f); + play_tone(900.0f, 0.1f, 0.5f); } void audio_play_proc(void) { diff --git a/src/audio.h b/src/audio.h index 56ecd92..3c2cb36 100644 --- a/src/audio.h +++ b/src/audio.h @@ -1,6 +1,5 @@ #ifndef AUDIO_H #define AUDIO_H -#include "common.h" // Initialize audio system void audio_init(void); @@ -12,28 +11,28 @@ void audio_close(void); void audio_play_move(void); // Play attack sound -void audio_play_attack(GameState *gs); +void audio_play_attack(void); // Play item pickup sound -void audio_play_item_pickup(GameState *gs); +void audio_play_item_pickup(void); // Play enemy death sound -void audio_play_enemy_death(GameState *gs); +void audio_play_enemy_death(void); // Play player damage sound -void audio_play_player_damage(GameState *gs); +void audio_play_player_damage(void); // Play stairs/level change sound -void audio_play_stairs(GameState *gs); +void audio_play_stairs(void); // Play dodge sound -void audio_play_dodge(GameState *gs); +void audio_play_dodge(void); // Play block sound -void audio_play_block(GameState *gs); +void audio_play_block(void); // Play critical hit sound -void audio_play_crit(GameState *gs); +void audio_play_crit(void); // Play status effect proc sound void audio_play_proc(void); diff --git a/src/common.h b/src/common.h index bd8454d..9af8771 100644 --- a/src/common.h +++ b/src/common.h @@ -2,7 +2,6 @@ #define COMMON_H #include "settings.h" -#include // Tile types typedef enum { TILE_WALL, TILE_FLOOR, TILE_STAIRS } TileType; @@ -113,15 +112,6 @@ typedef struct { StatusEffectType effect_type; // used to pick color for proc labels } FloatingText; -// AudioAssets -typedef struct { - Sound attack1, attack2, attack3; - Sound pickup; - Sound staircase; - Sound dodge1, dodge2, dodge3; - Sound crit; -} AudioAssets; - // GameState - encapsulates all game state for testability and save/load typedef struct { Player player; @@ -149,8 +139,6 @@ typedef struct { int screen_shake; // frames of screen shake remaining int shake_x; int shake_y; - AudioAssets sounds; } GameState; - #endif // COMMON_H diff --git a/src/main.c b/src/main.c index 073b84f..8313f81 100644 --- a/src/main.c +++ b/src/main.c @@ -65,18 +65,12 @@ static void spawn_floating_label(GameState *gs, int x, int y, const char *label, static const char *proc_label_for(StatusEffectType effect) { switch (effect) { - case EFFECT_POISON: - return "POISON!"; - case EFFECT_BLEED: - return "BLEED!"; - case EFFECT_BURN: - return "BURN!"; - case EFFECT_STUN: - return "STUN!"; - case EFFECT_WEAKEN: - return "WEAKEN!"; - default: - return ""; + case EFFECT_POISON: return "POISON!"; + case EFFECT_BLEED: return "BLEED!"; + case EFFECT_BURN: return "BURN!"; + case EFFECT_STUN: return "STUN!"; + case EFFECT_WEAKEN: return "WEAKEN!"; + default: return ""; } } @@ -187,18 +181,17 @@ static void post_action(GameState *gs, Enemy *attacked_enemy) { if (combat_was_dodged()) { spawn_floating_label(gs, ex, ey, "DODGE", EFFECT_NONE); - audio_play_dodge(gs); + audio_play_dodge(); } else { if (combat_get_last_damage() > 0) spawn_floating_text(gs, ex, ey, combat_get_last_damage(), combat_was_critical()); - audio_play_attack(gs); if (combat_was_blocked()) { spawn_floating_label(gs, ex, ey - 10, "BLOCK", EFFECT_NONE); - audio_play_block(gs); + audio_play_block(); } if (combat_was_critical()) { spawn_floating_label(gs, ex + 8, ey - 10, "CRIT!", EFFECT_NONE); - audio_play_crit(gs); + audio_play_crit(); } StatusEffectType applied = combat_get_applied_effect(); if (applied != EFFECT_NONE) { @@ -207,7 +200,7 @@ static void post_action(GameState *gs, Enemy *attacked_enemy) { } if (!attacked_enemy->alive) { spawn_floating_label(gs, ex, ey - 20, "SLAIN", EFFECT_NONE); - audio_play_enemy_death(gs); + audio_play_enemy_death(); } } } @@ -217,7 +210,7 @@ static void post_action(GameState *gs, Enemy *attacked_enemy) { // Check if player took damage if (combat_was_player_damage() && combat_get_last_damage() > 0) { - audio_play_player_damage(gs); + audio_play_player_damage(); gs->screen_shake = 8; spawn_floating_text(gs, gs->player.x * TILE_SIZE + 8, gs->player.y * TILE_SIZE, combat_get_last_damage(), combat_was_critical()); @@ -349,7 +342,7 @@ static int handle_inventory_input(GameState *gs) { static int handle_descend_input(GameState *gs) { if (IsKeyPressed(KEY_Y)) { if (gs->player.floor < NUM_FLOORS) { - audio_play_stairs(gs); + audio_play_stairs(); init_floor(gs, gs->player.floor + 1); gs->last_message = "Descended to next floor!"; gs->message_timer = 60; @@ -388,7 +381,7 @@ static int handle_movement_input(GameState *gs) { add_log(gs, pickup_msg); gs->last_message = "Picked up item!"; gs->message_timer = 60; - audio_play_item_pickup(gs); + audio_play_item_pickup(); } else { gs->last_message = "Inventory full!"; gs->message_timer = 60; @@ -402,7 +395,7 @@ static int handle_movement_input(GameState *gs) { if (gs->player.inventory_count > 0 && player_use_first_item(&gs->player)) { gs->last_message = "Used potion!"; gs->message_timer = 60; - audio_play_item_pickup(gs); + audio_play_item_pickup(); return 1; } } @@ -468,24 +461,11 @@ static int handle_input(GameState *gs) { return handle_movement_input(gs); } -void load_audio_assets(GameState *gs) { - gs->sounds.attack1 = LoadSound("./assets/sounds/sword1.wav"); - gs->sounds.attack2 = LoadSound("./assets/sounds/sword2.wav"); - gs->sounds.attack3 = LoadSound("./assets/sounds/sword3.wav"); - gs->sounds.pickup = LoadSound("./assets/sounds/itempickup.wav"); - gs->sounds.staircase = LoadSound("./assets/sounds/levelcomplete.wav"); - gs->sounds.dodge1 = LoadSound("./assets/sounds/dodge1.wav"); - gs->sounds.dodge2 = LoadSound("./assets/sounds/dodge2.wav"); - gs->sounds.dodge3 = LoadSound("./assets/sounds/dodge3.wav"); - gs->sounds.crit = LoadSound("./assets/sounds/crit.wav"); - return; -} - // Main game loop static void game_loop(void) { GameState gs; memset(&gs, 0, sizeof(GameState)); - load_audio_assets(&gs); + // Initialize first floor rng_seed(12345); init_floor(&gs, 1); @@ -573,8 +553,7 @@ static void game_loop(void) { int main(void) { // Initialize audio audio_init(); - // Initialize random number generator - SetRandomSeed(88435); + // Initialize window InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT + 60, "Roguelike"); SetTargetFPS(60);