Can shoot pods.
authorlimb <limb@bc5cbbab-a4ec-0310-bb52-ff3d296db539>
Mon, 4 Dec 2006 20:28:40 +0000 (20:28 +0000)
committerlimb <limb@bc5cbbab-a4ec-0310-bb52-ff3d296db539>
Mon, 4 Dec 2006 20:28:40 +0000 (20:28 +0000)
git-svn-id: svn+ssh://svn/var/repos/curfender@560 bc5cbbab-a4ec-0310-bb52-ff3d296db539

CHANGELOG
main.cpp

index dff5158..1104d58 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,4 @@
+Can shoot pods.
 Started bullet work
 Put pods in a struct array.
 Animated gate.
index 4f9d14c..12220b9 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -27,6 +27,18 @@ struct game_object {
   char radar[1]; //radar symbol
 };
 
+int check_collision(game_object object1, game_object object2){
+  int collided = 0;
+
+  if(object1.x==object2.x){
+    if(abs(object1.y-object2.y)<=2){
+      collided=1;
+    };
+  };
+
+  return collided;
+};
+
 game_object age_bullet(game_object object){
   if(object.vtime>=80){
     object.active = 0;
@@ -450,6 +462,7 @@ int main(){
   int input = 0;
   int lastkey = 0; //debug
   int podcount = 0;
+  int podsin = 0;
 
   cbreak();
   halfdelay(1);
@@ -507,7 +520,10 @@ int main(){
     for(int podloop = 0; podloop<8; podloop++){ radar_plot(pods[podloop], drawlocation); };
     
     //debug
-    mvprintw(21,1,"Lastkey:%d", lastkey);
+    //mvprintw(21,1,"Lastkey:%d", lastkey);
+
+    //pod state
+    mvprintw(21,1,"Out: %d In: %d", podcount, podsin);
 
     //get the cursor out of the way
     mvprintw(23,79,"|");
@@ -544,6 +560,7 @@ int main(){
        
        //increment score
        score = score + 10;
+       podsin++;
         pod_in = 0;
        strcpy (player.line0, "<==_>");
        strcpy (player.line1, "<_==>");
@@ -558,7 +575,7 @@ int main(){
          bullets[bulletloop].active=1;
          if(player.face==0){ bullets[bulletloop].direction = 4; };
          if(player.face==1){ bullets[bulletloop].direction = 6; };
-         bullets[bulletloop].speed = player.speed + 1;
+         bullets[bulletloop].speed = player.speed + 2;
          bullets[bulletloop].x = player.x;
          int multiplier = 1;
          if(player.direction == 4){multiplier = -1; };
@@ -569,13 +586,26 @@ int main(){
       };
     };
     
-    lastkey = input;
+    //lastkey = input; debug
     //check bullets
     //for each active bullet
-    //check each active pod
+    for(int bulletloop = 0; bulletloop<4; bulletloop++){ 
+      if(bullets[bulletloop].active==1){ 
+       //check each active pod
+       for(int podloop = 0; podloop<8; podloop++){
+         if(pods[podloop].active==1){
+           if(check_collision(bullets[bulletloop], pods[podloop])==1){
+             //kill pod and bullet
+             pods[podloop] = pod_out(pods[podloop]);
+             bullets[bulletloop].vtime = 100;
+             bullets[bulletloop] = age_bullet(bullets[bulletloop]);
+           };
+         };
+       };
+       //check each active enemy
+      };
+    };
     
-    //check each active enemy
-
     //check for 0 active pods, saved pods, level victory
     podcount = 0;
     for(int podloop = 0; podloop<8; podloop++){ podcount = podcount + pods[podloop].active; };
@@ -592,6 +622,7 @@ int main(){
       level++;
       //Reactivate pods if not zombied, regen enemies
       for(int podloop = 0; podloop<8; podloop++){ pods[podloop] = pod_init(pods[podloop]); };
+      podsin = 0;
     };
 
   }; //end main loop