66/* By: hluiz-ma <hluiz-ma@student.42porto.com> +#+ +:+ +#+ */
77/* +#+#+#+#+#+ +#+ */
88/* Created: 2024/11/29 16:37:53 by marsoare #+# #+# */
9- /* Updated: 2025/03/22 17:51:52 by hluiz-ma ### ########.fr */
9+ /* Updated: 2025/03/24 19:13:09 by hluiz-ma ### ########.fr */
1010/* */
1111/* ************************************************************************** */
1212
@@ -24,17 +24,25 @@ int mouse_press(int button, int x, int y, t_game *game)
2424 (void )y ;
2525 if (!game )
2626 return (0 );
27- if (button == MOUSE_LEFT )
27+ if (button == MOUSE_LEFT && game -> active_weapon == 0 )
2828 {
29- if (game -> active_weapon == 0 )
30- game -> p1 .is_firing = 1 ;
31- else if (game -> portal_system )
32- handle_portal_gun_input (game , button );
29+ game -> p1 .is_firing = 1 ;
30+ if (game -> sounds && game -> sounds -> is_initialized )
31+ play_sound (game -> sounds -> gun );
3332 }
34- else if (button == MOUSE_RIGHT )
33+ else if (button == MOUSE_LEFT && game -> active_weapon == 1
34+ && game -> portal_system )
3535 {
36- if (game -> portal_system && game -> active_weapon == 1 )
37- handle_portal_gun_input (game , button );
36+ handle_portal_gun_input (game , button );
37+ if (game -> sounds && game -> sounds -> is_initialized )
38+ play_sound (game -> sounds -> portal );
39+ }
40+ else if (button == MOUSE_RIGHT && game -> portal_system
41+ && game -> active_weapon == 1 )
42+ {
43+ handle_portal_gun_input (game , button );
44+ if (game -> sounds && game -> sounds -> is_initialized )
45+ play_sound (game -> sounds -> portal );
3846 }
3947 return (0 );
4048}
0 commit comments