Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added data/textures/ui_icons/audioOff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/textures/ui_icons/audioOn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions data/ui/ui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,64 @@
"scroll_bar_height": 80,
"scroll_bar_leeway": 60,
"scroll_bar_leeway_fix_speed": 200
},
{
"name": "mute_button",
"type": "button",
"anchor": [1, 0],
"pos": [-180, 75],
"size": [100, 100],
"up_entities": [
{
"parent": "mute_button",
"type": "texture",
"texture": "data/textures/ui_icons/audioOn.png",
"anchor": [0.5, 0.5],
"pos": [0, 0],
"size": [100, 100],
"overlay_color": [0, 0, 0, 1]
}
],
"down_entities": [
{
"parent": "mute_button",
"type": "texture",
"texture": "data/textures/ui_icons/audioOn.png",
"anchor": [0.5, 0.5],
"pos": [0, 0],
"size": [100, 100],
"overlay_color": [0.3, 0.3, 0.3, 1]
}
]
},
{
"name": "unmute_button",
"type": "button",
"anchor": [1, 0],
"pos": [-180, 75],
"size": [100, 100],
"up_entities": [
{
"parent": "unmute_button",
"type": "texture",
"texture": "data/textures/ui_icons/audioOff.png",
"anchor": [0.5, 0.5],
"pos": [0, 0],
"size": [100, 100],
"overlay_color": [0, 0, 0, 1]
}
],
"down_entities": [
{
"parent": "unmute_button",
"type": "texture",
"texture": "data/textures/ui_icons/audioOff.png",
"anchor": [0.5, 0.5],
"pos": [0, 0],
"size": [100, 100],
"overlay_color": [0.3, 0.3, 0.3, 1]
}
]
},
{
"name": "pause_button",
Expand Down
24 changes: 17 additions & 7 deletions src/golf/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ static golf_graphics_t *graphics;
static golf_inputs_t *inputs;
static golf_config_t *game_cfg;

bool game_muted = false;

golf_game_t *golf_game_get(void) {
return &game;
}
Expand Down Expand Up @@ -268,8 +270,9 @@ static void _golf_game_update_state_watching_ball(float dt) {
}
golf_storage_save();
}

golf_audio_start_sound("ball_in_hole", "data/audio/confirmation_002.ogg", 1, false, true);
if (!game_muted) {
golf_audio_start_sound("ball_in_hole", "data/audio/confirmation_002.ogg", 1, false, true);
}
}
else if (game.ball.is_out_of_bounds) {
game.ball.pos = game.ball.start_pos;
Expand All @@ -282,7 +285,9 @@ static void _golf_game_update_state_watching_ball(float dt) {
game.cam.angle = game.cam.start_angle;
game.cam.auto_rotate = false;
game.state = GOLF_GAME_STATE_WAITING_FOR_AIM;
golf_audio_start_sound("ball_out_of_bounds", "data/audio/error_008.ogg", 1, false, true);
if (!game_muted) {
golf_audio_start_sound("ball_out_of_bounds", "data/audio/error_008.ogg", 1, false, true);
}
}
else if (!game.ball.is_moving) {
game.state = GOLF_GAME_STATE_WAITING_FOR_AIM;
Expand Down Expand Up @@ -578,7 +583,9 @@ static void _physics_tick(float dt) {

if (contact->impulse_mag > 1 && contact->cull_dot < -0.15f) {
if (game.ball.time_since_impact_sound > 0.1f) {
golf_audio_start_sound("ball_impact", "data/audio/footstep_grass_004.ogg", 1, false, true);
if (!game_muted) {
golf_audio_start_sound("ball_impact", "data/audio/footstep_grass_004.ogg", 1, false, true);
}
game.ball.time_since_impact_sound = 0;
}
}
Expand Down Expand Up @@ -700,7 +707,9 @@ static void _physics_tick(float dt) {
}

if (game.ball.time_out_of_water < 0.1f) {
golf_audio_start_sound("ball_in_water", "data/audio/in_water.ogg", 0.1f, true, false);
if (!game_muted) {
golf_audio_start_sound("ball_in_water", "data/audio/in_water.ogg", 0.1f, true, false);
}
}
else {
golf_audio_stop_sound("ball_in_water", 0.2f);
Expand Down Expand Up @@ -1028,8 +1037,9 @@ void golf_game_hit_ball(vec2 aim_delta) {
game.cam.start_angle = game.cam.angle;

game.physics.collision_history.length = 0;

golf_audio_start_sound("hit_ball", "data/audio/impactPlank_medium_000.ogg", 1, false, true);
if (!game_muted) {
golf_audio_start_sound("hit_ball", "data/audio/impactPlank_medium_000.ogg", 1, false, true);
}
}

void golf_game_pause(void) {
Expand Down
2 changes: 2 additions & 0 deletions src/golf/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,6 @@ void golf_game_hit_ball(vec2 aim_delta);
void golf_game_pause(void);
void golf_game_resume(void);

extern bool game_muted;

#endif
17 changes: 15 additions & 2 deletions src/golf/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,9 @@ static bool _golf_ui_button_name(golf_ui_layout_t *layout, const char *name) {
}

if (clicked) {
golf_audio_start_sound("button_click", "data/audio/drop_003.ogg", 1, false, true);
if (!game_muted) {
golf_audio_start_sound("button_click", "data/audio/drop_003.ogg", 1, false, true);
}
}

return clicked;
Expand Down Expand Up @@ -1006,7 +1008,9 @@ static void _golf_ui_main_menu(float dt) {
}
int clicked_button_num = _golf_ui_level_select_scroll_box_name(layout, "level_select_scroll_box", dt);
if (clicked_button_num >= 0) {
golf_audio_start_sound("button_click", "data/audio/drop_003.ogg", 1, false, true);
if (!game_muted) {
golf_audio_start_sound("button_click", "data/audio/drop_003.ogg", 1, false, true);
}
_golf_ui_start_fade_out(false, true, clicked_button_num, false);
}
}
Expand Down Expand Up @@ -1170,6 +1174,15 @@ static void _golf_ui_in_game(float dt) {
if (_golf_ui_button_name(layout, "pause_button")) {
golf_game_pause();
}
if (game_muted) {
if (_golf_ui_button_name(layout, "unmute_button")) {
game_muted = false;
}
} else {
if (_golf_ui_button_name(layout, "mute_button")) {
game_muted = true;
}
}
}

float temp_val;
Expand Down