Facebook
From Small Coyote, 3 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 57
  1. #include <allegro5/allegro5.h>
  2. #include <allegro5/allegro_image.h>
  3. #include <allegro5/allegro_acodec.h>
  4. #include <allegro5/allegro_audio.h>
  5. int main() {
  6.     al_init();
  7.     ALLEGRO_DISPLAY* display = al_create_display(400,300);
  8.     al_install_mouse();
  9.     al_init_image_addon();
  10.     al_init_acodec_addon();
  11.     al_install_audio();
  12.     al_reserve_samples(32);
  13.     ALLEGRO_MOUSE_STATE mysz;
  14.     ALLEGRO_BITMAP* pianino = al_load_bitmap("pianino.png");
  15.     ALLEGRO_SAMPLE* dzwieki[8] = {al_load_sample("C.wav"), al_load_sample("D.wav"), al_load_sample("E.wav")
  16.     , al_load_sample("F.wav"), al_load_sample("G.wav"), al_load_sample("A.wav"), al_load_sample("H.wav")
  17.     , al_load_sample("C(oktawa).wav")};
  18.     while(1) {
  19.         al_get_mouse_state(&mysz);
  20.         al_draw_bitmap(pianino, 0, 0, 0);
  21.         al_flip_display();
  22.         al_rest(0.1);
  23.         if (mysz.buttons == 1 && mysz.x/50 < 8 && mysz.x/50 > -1)
  24.             al_play_sample(dzwieki[(mysz.x)/50], 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL);
  25.  
  26.     }
  27.     return 0;
  28. }
  29.