boom sound integration test
authorlimb <limb@bc5cbbab-a4ec-0310-bb52-ff3d296db539>
Thu, 28 May 2009 19:01:54 +0000 (19:01 +0000)
committerlimb <limb@bc5cbbab-a4ec-0310-bb52-ff3d296db539>
Thu, 28 May 2009 19:01:54 +0000 (19:01 +0000)
git-svn-id: svn+ssh://svn/var/repos/curfender@806 bc5cbbab-a4ec-0310-bb52-ff3d296db539

main.cpp

index 4e74f49..08266b1 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -602,6 +602,45 @@ void boom_object(game_object boomstuff, game_object object){
   };
 }
 
+int play_sound_effect(Mix_Chunk *chunk){
+  int channel = Mix_PlayChannel(-1, chunk, 0);
+  return channel;
+};
+
+void boom_object_test(game_object boomstuff, game_object object, Mix_Chunk *sound, int channel){
+  int deathcycle=1;
+  int loop=1;
+  boomstuff.active=1;
+  channel = play_sound_effect(sound);
+  while(deathcycle<=7){
+    for(int boomx=object.x-10;boomx<=object.x+10;boomx++){
+      for(int boomy=object.y-10;boomy<=object.y+10;boomy++){
+       if(sqrt((abs(object.y-boomy)*abs(object.y-boomy))+(abs(object.x-boomx)*abs(object.x-boomx)))<=deathcycle){
+         if(rand()%1000>900){
+           boomstuff.x = boomx;
+           boomstuff.y = boomy;
+           if(rand()%1000>500){
+             boomstuff.face = 0;
+           } else {
+             boomstuff.face = 1;
+           };
+           for(int iterations=0;iterations<=loop;iterations++){
+             drawlocation = draw_object(boomstuff, drawlocation);
+           };
+           //get the cursor out of the way
+           mvprintw(23,79,"-");
+           refresh();
+         };
+       };
+      };
+    };
+    deathcycle++;
+  };
+  if(object.number!=1){
+    usleep(50000);
+  };
+}
+
 int life_loss(int lives, int score){
   if(lives>=1){
     pause_game = 0;
@@ -696,11 +735,6 @@ void determine_powerup(game_object powerups[], game_object object, int odds){
 
 };
 
-int play_sound_effect(Mix_Chunk *chunk){
-  int channel = Mix_PlayChannel(-1, chunk, 0);
-  return channel;
-};
-
 game_object player_init(game_object player){
   player.x = 18;
   player.y = rand()%600+20;
@@ -1248,7 +1282,6 @@ int main(){
         exit(1);
       }
 
-      
       if(stat("data/boom.ogg", &datatest)==0){
         shotsound = Mix_LoadWAV("data/shot.ogg");
         boomsound = Mix_LoadWAV("data/boom.ogg");
@@ -1784,8 +1817,8 @@ int main(){
            if(check_collision(bullets[bulletloop], landers[landerloop])==1){
              //kill lander and bullet
              determine_powerup(powerups, landers[landerloop], 800);
-             if(sound==1){boomchannel = play_sound_effect(boomsound);};
-             boom_object(boomstuff, landers[landerloop]);
+             //if(sound==1){boomchannel = play_sound_effect(boomsound);};
+             boom_object_test(boomstuff, landers[landerloop], boomsound, boomchannel);
              landers[landerloop] = object_out(landers[landerloop]);
              bullets[bulletloop].vtime = 100;
              bullets[bulletloop] = age_bullet(bullets[bulletloop]);