mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-05 00:38:00 +01:00
add rain sound
This commit is contained in:
parent
4ac9439289
commit
50eec13ceb
3 changed files with 10 additions and 2 deletions
2
main.c
2
main.c
|
@ -72,7 +72,7 @@ int main(int argc, char **argv){
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (!al_reserve_samples(1)){
|
||||
if (!al_reserve_samples(2)){
|
||||
fprintf(stderr, "failed to reserve samples!\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
2
main.h
2
main.h
|
@ -20,7 +20,7 @@ struct Menu {
|
|||
ALLEGRO_BITMAP *mountain_bitmap, *mountain;
|
||||
float cloud_position, cloud2_position;
|
||||
int mountain_position;
|
||||
ALLEGRO_SAMPLE *sample;
|
||||
ALLEGRO_SAMPLE *sample, *rain_sample;
|
||||
ALLEGRO_FONT *font_title, *font_subtitle;
|
||||
};
|
||||
|
||||
|
|
8
menu.c
8
menu.c
|
@ -45,6 +45,7 @@ void Menu_Preload(struct Game *game) {
|
|||
game->menu.image = al_load_bitmap( "menu.png" );
|
||||
game->menu.mountain = al_load_bitmap( "mountain.png" );
|
||||
game->menu.sample = al_load_sample( "menu.wav" );
|
||||
game->menu.rain_sample = al_load_sample( "rain.wav" );
|
||||
game->menu.cloud = al_load_bitmap( "cloud.png" );
|
||||
game->menu.cloud2 = al_load_bitmap( "cloud2.png" );
|
||||
game->menu.pinkcloud = al_load_bitmap( "pinkcloud.png" );
|
||||
|
@ -59,6 +60,11 @@ void Menu_Preload(struct Game *game) {
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
if (!game->menu.rain_sample){
|
||||
fprintf(stderr, "Audio clip sample#2 not loaded!\n" );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// Scale menu bitmap
|
||||
game->menu.menu_bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display));
|
||||
game->menu.menu_fade_bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display));
|
||||
|
@ -102,6 +108,7 @@ void Menu_Preload(struct Game *game) {
|
|||
|
||||
void Menu_Unload(struct Game *game) {
|
||||
al_destroy_sample(game->menu.sample);
|
||||
al_destroy_sample(game->menu.rain_sample);
|
||||
ALLEGRO_EVENT ev;
|
||||
for(int fadeloop=255; fadeloop>=0; fadeloop-=10){
|
||||
al_wait_for_event(game->event_queue, &ev);
|
||||
|
@ -122,6 +129,7 @@ void Menu_Unload(struct Game *game) {
|
|||
|
||||
void Menu_Load(struct Game *game) {
|
||||
al_play_sample(game->menu.sample, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_LOOP, NULL);
|
||||
al_play_sample(game->menu.rain_sample, 0.4, -0.3, 1.0, ALLEGRO_PLAYMODE_LOOP, NULL);
|
||||
ALLEGRO_EVENT ev;
|
||||
for(int fadeloop=0; fadeloop<256; fadeloop+=10){
|
||||
al_wait_for_event(game->event_queue, &ev);
|
||||
|
|
Loading…
Reference in a new issue