Added crawlers.
authorlimb <limb@bc5cbbab-a4ec-0310-bb52-ff3d296db539>
Thu, 5 Apr 2007 17:22:35 +0000 (17:22 +0000)
committerlimb <limb@bc5cbbab-a4ec-0310-bb52-ff3d296db539>
Thu, 5 Apr 2007 17:22:35 +0000 (17:22 +0000)
git-svn-id: svn+ssh://svn/var/repos/curfender@644 bc5cbbab-a4ec-0310-bb52-ff3d296db539

CHANGELOG
layout.txt
main.cpp

index e38318c..ff33cc3 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,4 @@
+Added crawlers, which can shoot and are affected by all weapons.  No pod interaction.
 Added static markers on ground for frame of reference.
 Added laser (Z) powerup.
 Saved individual high score.
index 5a3ee27..73b7804 100644 (file)
@@ -16,8 +16,8 @@
 6\                   [
 7/                   ]                                 
 8                    ^                        <_==>    <x==>  -  -  -  
-9                   /|\            x + x +     
-0-------------------------------------------------------------------------------
+9                   /|\            x + x +                             /=\
+0-------|-------------------|--------------------|--------------------|---------
 1Lv:<=><=><=><=>|                         /        \                           |
 2 O:X I:X BBBB  |                                                              |
 3 Lvl:XXX S:XXX |                                                              |
index 087d20a..cabb771 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -28,6 +28,7 @@ const int podmax = 8;
 const int bulletmax = 10;
 const int landershotmax = 10;
 const int landermax = 4;
+const int crawlermax = 6;
 const float version = 1.0;
 
 int score;
@@ -379,6 +380,21 @@ game_object lander_init(game_object lander){
   return lander;
 }
 
+game_object crawler_init(game_object crawler){
+  crawler.active=1;
+  crawler.x = 18;
+  crawler.y = rand()%600+20;
+  crawler.direction = rand()%1000;
+  if(crawler.direction<500){
+    crawler.direction = 4;
+  } else {
+    crawler.direction = 6;
+  };
+  crawler.speed = 1;
+
+  return crawler;
+}
+
 game_object encrazify(game_object lander, game_object crazy){
   crazy.active=1;
   crazy.x = lander.x;
@@ -836,6 +852,7 @@ int main(){
     strcpy (landers[landerloop].radar, "*");
   };
 
+  //lander shots
   struct game_object landershot[landershotmax] = {
     { 80, 0, 0, 0, 5, 0, 0, 0, 0 },
     { 81, 0, 0, 0, 5, 0, 0, 0, 0 },
@@ -943,6 +960,27 @@ int main(){
     strcpy (refs[refloop].line1, "|");
   };
 
+  //crawlers 
+  struct game_object crawlers[crawlermax] = {
+    { 30, 1, 18, rand()%620, 0, 0, 1, 0, 0 },
+    { 31, 1, 18, rand()%620, 0, 0, 1, 0, 0 },
+    { 32, 1, 18, rand()%620, 0, 0, 1, 0, 0 },
+    { 33, 1, 18, rand()%620, 0, 0, 1, 0, 0 },
+    { 34, 1, 18, rand()%620, 0, 0, 1, 0, 0 },
+    { 35, 1, 18, rand()%620, 0, 0, 1, 0, 0 }
+  };
+  
+  for(int crawlerloop = 0; crawlerloop<crawlermax; crawlerloop++){ 
+    if(rand()%1000>=500){
+      crawlers[crawlerloop].direction = 4;
+    } else {
+      crawlers[crawlerloop].direction = 6;
+    };
+
+    strcpy (crawlers[crawlerloop].line0, "/=\\");
+    strcpy (crawlers[crawlerloop].radar, "^");
+  };
+
   initscr();
 
   //Check screen size 80x24 and exit if not big enough
@@ -964,6 +1002,7 @@ int main(){
   int podsin = 0;
   int landercount = 0;
   int crazycount = 0;
+  int crawlercount = 0;
   int alertleft = 0;
   int alertright = 0;
   int smartbombs = 4;
@@ -1139,7 +1178,7 @@ int main(){
     };
     
     
-      for(int crazyloop = 0; crazyloop<landermax; crazyloop++){ 
+    for(int crazyloop = 0; crazyloop<landermax; crazyloop++){ 
       if(crazies[crazyloop].active==1){ 
        crazies[crazyloop] = crazy_motion(crazies[crazyloop], player);
        crazies[crazyloop] = process_motion(crazies[crazyloop], player);
@@ -1153,6 +1192,10 @@ int main(){
       };
     };
 
+    for(int crawlerloop = 0; crawlerloop<crawlermax; crawlerloop++){
+      crawlers[crawlerloop] = process_motion(crawlers[crawlerloop], player);
+    };
+
     // Draw player object 1
     drawlocation = draw_object(player, drawlocation);
 
@@ -1172,7 +1215,9 @@ int main(){
     };
 
     // Draw pods objects 2-9    
-    for(int podloop = 0; podloop<podmax; podloop++){ drawlocation = draw_object(pods[podloop], drawlocation); };
+    for(int podloop = 0; podloop<podmax; podloop++){
+      drawlocation = draw_object(pods[podloop], drawlocation); 
+    };
 
     // Draw gate object 10
     drawlocation = draw_object(gate, drawlocation);
@@ -1239,6 +1284,11 @@ int main(){
       };
     };
 
+    // Draw crawlers 30-35
+    for(int crawlerloop = 0; crawlerloop<crawlermax; crawlerloop++){
+      drawlocation = draw_object(crawlers[crawlerloop], drawlocation); 
+    };
+
     //Radar plot 18x620 represented in 4x62
     radar_plot(gate, drawlocation);
     radar_plot(gatebeam1, drawlocation);
@@ -1247,6 +1297,7 @@ int main(){
     for(int podloop = 0; podloop<podmax; podloop++){ radar_plot(pods[podloop], drawlocation); };
     for(int landerloop = 0; landerloop<landermax; landerloop++){ radar_plot(landers[landerloop], drawlocation); };
     for(int crazyloop = 0; crazyloop<landermax; crazyloop++){ radar_plot(crazies[crazyloop], drawlocation); };
+    for(int crawlerloop = 0; crawlerloop<crawlermax; crawlerloop++){ radar_plot(crawlers[crawlerloop], drawlocation); };
     radar_plot(player, drawlocation);
 
     //alerts
@@ -1411,6 +1462,22 @@ int main(){
            score = score + 10;
          };
        };
+       //kill crawlers
+       for(int crawlerloop = 0; crawlerloop<crawlermax; crawlerloop++){
+         if((abs(player.y-crawlers[crawlerloop].y)<=40)&&(player.x==crawlers[crawlerloop].x)&&((player.face==0&&(crawlers[crawlerloop].y<player.y))||(player.face==1&&(crawlers[crawlerloop].y>player.y)))){
+           //powerup?
+           if(rand()%1000>800){
+             for(int puploop = 0; puploop<4; puploop++){
+               if(powerups[puploop].active==0){
+                 powerups[puploop] = powerup_init(powerups[puploop], crawlers[crawlerloop]);
+                 break;
+               };
+             };
+           };
+           crawlers[crawlerloop] = object_out(crawlers[crawlerloop]);
+           score = score + 10;
+         };
+       };
        laser--;
       } else {
        //get next inactive bullet, give it player's direction, speed, height, location +speed in direction, active, set vtime=1.
@@ -1488,6 +1555,12 @@ int main(){
          score = score + 20;
        };
       };
+      for(int crawlerloop = 0; crawlerloop<crawlermax; crawlerloop++){
+       if(abs(player.y-crawlers[crawlerloop].y)<=40){
+         crawlers[crawlerloop] = object_out(crawlers[crawlerloop]);
+         score = score + 20;
+       };
+      };
     };
  
     //for each active bullet
@@ -1548,6 +1621,27 @@ int main(){
            };
          };
        };
+       for(int crawlerloop = 0; crawlerloop<crawlermax; crawlerloop++){
+         if(crawlers[crawlerloop].active==1){
+           if(check_collision(bullets[bulletloop], crawlers[crawlerloop])==1){
+             //kill crawler and bullet
+             //powerup?
+             if(rand()%1000>800){
+               for(int puploop = 0; puploop<4; puploop++){
+                 if(powerups[puploop].active==0){
+                   powerups[puploop] = powerup_init(powerups[puploop], crawlers[crawlerloop]);
+                   break;
+                 };
+               };
+             };
+             crawlers[crawlerloop] = object_out(crawlers[crawlerloop]);
+             bullets[bulletloop].vtime = 100;
+             bullets[bulletloop] = age_bullet(bullets[bulletloop]);
+             //add to score
+             score = score + 20;
+           };
+         };
+       };
       };
     };
     
@@ -1621,6 +1715,41 @@ int main(){
       };
     };
 
+    //watch for crawler/player collisions
+    for(int crawlerloop = 0; crawlerloop<crawlermax; crawlerloop++){
+      if(crawlers[crawlerloop].active==1){
+       if(check_collision(player, crawlers[crawlerloop])==1){
+         //kill crawler and player
+         crawlers[crawlerloop] = object_out(crawlers[crawlerloop]);
+         lives--;
+         //add to score
+         score = score + 20;
+         life_loss(lives, score);
+         player = player_init(player);
+         drawlocation = player.y-20;
+         //kill any carried pods
+         if(pod_in>0){
+           for(int podloop = 0; podloop<podmax; podloop++){ 
+             if(pods[podloop].number==pod_in){
+               pods[podloop] = object_out(pods[podloop]);
+               pod_in = 0;
+               strcpy (player.line0, "<==_>");
+               strcpy (player.line1, "<_==>");
+             };
+           };
+         };
+       };
+       if(shieldup==1){
+         for(int shieldloop = 0; shieldloop<12; shieldloop++){
+           if(check_collision(crawlers[crawlerloop], shields[shieldloop])==1){
+             crawlers[crawlerloop] = object_out(crawlers[crawlerloop]);
+             score = score + 20;
+           };
+         };
+       };
+      };
+    };
+
     // Lander shots
     for(int landerloop = 0; landerloop<landermax; landerloop++){
       if(landers[landerloop].active==1&&landers[landerloop].chase<=0){
@@ -1687,6 +1816,39 @@ int main(){
       };
     };
 
+    // Crawler shots
+    for(int crawlerloop = 0; crawlerloop<crawlermax; crawlerloop++){
+      if(crawlers[crawlerloop].active==1&&crawlers[crawlerloop].chase<=0){
+       if(rand()%1000>500){
+         // crawler shoot
+         for(int crawlershotloop = 0; crawlershotloop<landershotmax; crawlershotloop++){ 
+           if(landershot[crawlershotloop].active==0){ 
+             int multiplier = 1;
+             landershot[crawlershotloop].active=1;
+             //set direction
+             if(player.y<crawlers[crawlerloop].y){ 
+               if(player.x<crawlers[crawlerloop].x){ landershot[crawlershotloop].direction = 7; };
+               if(player.x==crawlers[crawlerloop].x){ landershot[crawlershotloop].direction = 4; };
+               if(player.x>crawlers[crawlerloop].x){ landershot[crawlershotloop].direction = 1; };
+               //set multipler based on direction
+               multiplier = -1; 
+             };
+             if(player.y>=crawlers[crawlerloop].y){
+               if(player.x<crawlers[crawlerloop].x){ landershot[crawlershotloop].direction = 9; };
+               if(player.x==crawlers[crawlerloop].x){ landershot[crawlershotloop].direction = 6; };
+               if(player.x>crawlers[crawlerloop].x){ landershot[crawlershotloop].direction = 3; };
+             };
+             landershot[crawlershotloop].speed = crawlers[crawlerloop].speed;
+             landershot[crawlershotloop].x = crawlers[crawlerloop].x;
+             landershot[crawlershotloop].y = crawlers[crawlerloop].y + (crawlers[crawlerloop].speed * multiplier);
+             landershot[crawlershotloop].vtime = 1;
+             break;
+           };
+         };
+       };
+      };
+    };
+
     //for each active lander shot
     for(int landershotloop = 0; landershotloop<landershotmax; landershotloop++){ 
       if(landershot[landershotloop].active==1){ 
@@ -1757,7 +1919,9 @@ int main(){
       //do the level victory once all crazies are dead  
       crazycount = 0;
       for(int crazyloop = 0; crazyloop<landermax; crazyloop++){ crazycount = crazycount + crazies[crazyloop].active; };
-      if(crazycount<=0){
+      crawlercount = 0;
+      for(int crawlerloop = 0; crawlerloop<crawlermax; crawlerloop++){ crawlercount = crawlercount + crawlers[crawlerloop].active; };
+      if(crazycount<=0&&crawlercount<=0){
        if(podsin>0&&landercount<=0){
          //Tally bonuses
          //Award lives, if any
@@ -1795,6 +1959,12 @@ int main(){
              landers[landerloop] = lander_init(landers[landerloop]);
            };
          };
+         //regen crawlers
+         for(int crawlerloop = 0; crawlerloop<crawlermax; crawlerloop++){ 
+           if(crawlers[crawlerloop].active==0){
+             crawlers[crawlerloop] = crawler_init(crawlers[crawlerloop]);
+           };
+         };
        };
        if(podsin<=0&&landercount>0){
          //crazy the landers