Fixed pod not picked up if not moving bug.
authorlimb <limb@bc5cbbab-a4ec-0310-bb52-ff3d296db539>
Mon, 4 Dec 2006 13:35:32 +0000 (13:35 +0000)
committerlimb <limb@bc5cbbab-a4ec-0310-bb52-ff3d296db539>
Mon, 4 Dec 2006 13:35:32 +0000 (13:35 +0000)
Finished initial level-up logic.

git-svn-id: svn+ssh://svn/var/repos/curfender@549 bc5cbbab-a4ec-0310-bb52-ff3d296db539

main.cpp

index 25a62fb..5259072 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -116,6 +116,21 @@ game_object process_motion(game_object object, game_object player){
 
 }
 
+game_object pod_init(game_object pod){
+  pod.active=1;
+  pod.x = 18;  //always start on ground
+  pod.y = rand()%620; //anywhere along the surface
+  pod.direction = rand()%1000;
+  if(pod.direction<500){
+    pod.direction = 4;
+  } else {
+    pod.direction = 6;
+  };
+  pod.speed = 1;
+
+  return pod;
+}
+
 game_object pod_out(game_object pod){
   pod.active=0;
   pod.x = 0;
@@ -127,10 +142,11 @@ game_object pod_out(game_object pod){
 
 int pod_check(game_object pod, game_object player){
   int pod_in = 0;
-  if((pod.x==player.x)&&(abs(player.y-pod.y)<player.speed)){
+  
+  if( (pod.x==player.x)&&((abs(player.y-pod.y)<player.speed&&player.speed>0)||(player.y==pod.y))){
     pod_in = pod.number;
   };
-
+  
   return pod_in;
 }
 
@@ -247,6 +263,7 @@ int main(){
  
   srand(time(NULL));
 
+  level = 1;
   score = 0;
   lives = 4;
 
@@ -486,6 +503,8 @@ game_object pod9;
 
     //process object motion
     player = process_motion(player, player);
+    //for(int podloop = 0; podloop>7; podloop++){ pods[podloop] = process_motion(pods[podloop], player); };
+    
     pod2 = process_motion(pod2, player);
     pod3 = process_motion(pod3, player);
     pod4 = process_motion(pod4, player);
@@ -494,6 +513,7 @@ game_object pod9;
     pod7 = process_motion(pod7, player);
     pod8 = process_motion(pod8, player);
     pod9 = process_motion(pod9, player);
+    
 
     // Draw player object 1
     drawlocation = draw_object(player, drawlocation);
@@ -594,11 +614,25 @@ game_object pod9;
     //check for 0 active pods, saved pods, level victory
     podcount = pod2.active+pod3.active+pod4.active+pod5.active+pod6.active+pod7.active+pod8.active+pod9.active;
     if(podcount<=0){
-      //Advance level
       //Tally bonuses
       //Award lives, if any
+      if(lives<4){lives++;};
       //Print goodies, getch
+      cbreak();
+      mvprintw(10,20,"Level %d Completed.  Press any key to continue.\n", level);
+      getch();
+      halfdelay(1);
+      //Advance level
+      level++;
       //Reactivate pods if not zombied, regen enemies
+      pod2 = pod_init(pod2);
+      pod3 = pod_init(pod3);
+      pod4 = pod_init(pod4);
+      pod5 = pod_init(pod5);
+      pod6 = pod_init(pod6);
+      pod7 = pod_init(pod7);
+      pod8 = pod_init(pod8);
+      pod9 = pod_init(pod9);
     };
 
   }; //end main loop