};
game_object gravitize(game_object object){
+
if(object.vspeed<4&&object.vspeed>0&&object.vtime%4==0){
object.vspeed = object.vspeed + 1;
};
strcpy (gatebeam3.line3, " ] ");
strcpy (gatebeam3.radar, "|");
- game_object pod2;
- pod2.number = 2;
- pod2.active = 1;
- pod2.x = 18; //always start on ground
- pod2.y = rand()%620; //anywhere along the surface
- pod2.direction = rand()%1000;
- if(pod2.direction<500){
- pod2.direction = 4;
- } else {
- pod2.direction = 6;
- };
- pod2.face = 0;
- pod2.speed = 1;
- pod2.vspeed = 0;
- pod2.vtime = 0;
- strcpy (pod2.line0, " x ");
- strcpy (pod2.line1, " x ");
- strcpy (pod2.line2, " + ");
- strcpy (pod2.line3, " + ");
- strcpy (pod2.radar, "x");
-
- game_object pod3;
- pod3.number = 3;
- pod3.active = 1;
- pod3.x = 18; //always start on ground
- pod3.y = rand()%620; //anywhere along the surface
- pod3.direction = rand()%1000;
- if(pod3.direction<500){
- pod3.direction = 4;
- } else {
- pod3.direction = 6;
- };
- pod3.face = 0;
- pod3.speed = 1;
- pod3.vspeed = 0;
- pod3.vtime = 0;
- strcpy (pod3.line0, " + ");
- strcpy (pod3.line1, " + ");
- strcpy (pod3.line2, " x ");
- strcpy (pod3.line3, " x ");
- strcpy (pod3.radar, "x");
-
- game_object pod4;
- pod4.number = 4;
- pod4.active = 1;
- pod4.x = 18; //always start on ground
- pod4.y = rand()%620; //anywhere along the surface
- pod4.direction = rand()%1000;
- if(pod4.direction<500){
- pod4.direction = 4;
- } else {
- pod4.direction = 6;
+ struct game_object pods[8] = {
+ { 2, 1, 18, rand()%620, 6, 0, 1, 0, 0},
+ { 3, 1, 18, rand()%620, 4, 0, 1, 0, 0},
+ { 4, 1, 18, rand()%620, 6, 0, 1, 0, 0},
+ { 5, 1, 18, rand()%620, 4, 0, 1, 0, 0},
+ { 6, 1, 18, rand()%620, 6, 0, 1, 0, 0},
+ { 7, 1, 18, rand()%620, 4, 0, 1, 0, 0},
+ { 8, 1, 18, rand()%620, 6, 0, 1, 0, 0},
+ { 9, 1, 18, rand()%620, 4, 0, 1, 0, 0}
+ };
+
+ for(int podloop = 0; podloop<8; podloop=podloop+2){
+ strcpy (pods[podloop].line0, " x ");
+ strcpy (pods[podloop].line1, " x ");
+ strcpy (pods[podloop].line2, " + ");
+ strcpy (pods[podloop].line3, " + ");
+ strcpy (pods[podloop].radar, "x");
};
- pod4.face = 0;
- pod4.speed = 1;
- pod4.vspeed = 0;
- pod4.vtime = 0;
- strcpy (pod4.line0, " x ");
- strcpy (pod4.line1, " x ");
- strcpy (pod4.line2, " + ");
- strcpy (pod4.line3, " + ");
- strcpy (pod4.radar, "x");
-
-game_object pod5;
- pod5.number = 5;
- pod5.active = 1;
- pod5.x = 18; //always start on ground
- pod5.y = rand()%620; //anywhere along the surface
- pod5.direction = rand()%1000;
- if(pod5.direction<500){
- pod5.direction = 4;
- } else {
- pod5.direction = 6;
- };
- pod5.face = 0;
- pod5.speed = 1;
- pod5.vspeed = 0;
- pod5.vtime = 0;
- strcpy (pod5.line0, " + ");
- strcpy (pod5.line1, " + ");
- strcpy (pod5.line2, " x ");
- strcpy (pod5.line3, " x ");
- strcpy (pod5.radar, "x");
-
-game_object pod6;
- pod6.number = 6;
- pod6.active = 1;
- pod6.x = 18; //always start on ground
- pod6.y = rand()%620; //anywhere along the surface
- pod6.direction = rand()%1000;
- if(pod6.direction<500){
- pod6.direction = 4;
- } else {
- pod6.direction = 6;
- };
- pod6.face = 0;
- pod6.speed = 1;
- pod6.vspeed = 0;
- pod6.vtime = 0;
- strcpy (pod6.line0, " x ");
- strcpy (pod6.line1, " x ");
- strcpy (pod6.line2, " + ");
- strcpy (pod6.line3, " + ");
- strcpy (pod6.radar, "x");
-
-game_object pod7;
- pod7.number = 7;
- pod7.active = 1;
- pod7.x = 18; //always start on ground
- pod7.y = rand()%620; //anywhere along the surface
- pod7.direction = rand()%1000;
- if(pod7.direction<500){
- pod7.direction = 4;
- } else {
- pod7.direction = 6;
- };
- pod7.face = 0;
- pod7.speed = 1;
- pod7.vspeed = 0;
- pod7.vtime = 0;
- strcpy (pod7.line0, " + ");
- strcpy (pod7.line1, " + ");
- strcpy (pod7.line2, " x ");
- strcpy (pod7.line3, " x ");
- strcpy (pod7.radar, "x");
-
-game_object pod8;
- pod8.number = 8;
- pod8.active = 1;
- pod8.x = 18; //always start on ground
- pod8.y = rand()%620; //anywhere along the surface
- pod8.direction = rand()%1000;
- if(pod8.direction<500){
- pod8.direction = 4;
- } else {
- pod8.direction = 6;
- };
- pod8.face = 0;
- pod8.speed = 1;
- pod8.vspeed = 0;
- pod8.vtime = 0;
- strcpy (pod8.line0, " x ");
- strcpy (pod8.line1, " x ");
- strcpy (pod8.line2, " + ");
- strcpy (pod8.line3, " + ");
- strcpy (pod8.radar, "x");
-
-game_object pod9;
- pod9.number = 9;
- pod9.active = 1;
- pod9.x = 18; //always start on ground
- pod9.y = rand()%620; //anywhere along the surface
- pod9.direction = rand()%1000;
- if(pod9.direction<500){
- pod9.direction = 4;
- } else {
- pod9.direction = 6;
+
+ for(int podloop = 1; podloop<8; podloop=podloop+2){
+ strcpy (pods[podloop].line0, " + ");
+ strcpy (pods[podloop].line1, " + ");
+ strcpy (pods[podloop].line2, " x ");
+ strcpy (pods[podloop].line3, " x ");
+ strcpy (pods[podloop].radar, "x");
};
- pod9.face = 0;
- pod9.speed = 1;
- pod9.vspeed = 0;
- pod9.vtime = 0;
- strcpy (pod9.line0, " + ");
- strcpy (pod9.line1, " + ");
- strcpy (pod9.line2, " x ");
- strcpy (pod9.line3, " x ");
- strcpy (pod9.radar, "x");
-
- game_object pods[8] = { { pod2 }, { pod3 }, { pod4 }, { pod5 }, { pod6 }, { pod7 }, { pod8 }, { pod9 } };
initscr();
//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);
- pod5 = process_motion(pod5, player);
- pod6 = process_motion(pod6, player);
- pod7 = process_motion(pod7, player);
- pod8 = process_motion(pod8, player);
- pod9 = process_motion(pod9, player);
+ for(int podloop = 0; podloop<8; podloop++){ pods[podloop] = process_motion(pods[podloop], player); };
gatebeam1 = process_motion(gatebeam1, player);
gatebeam2 = process_motion(gatebeam2, player);
// Draw player object 1
drawlocation = draw_object(player, drawlocation);
- // Draw pods objects 2-9
- drawlocation = draw_object(pod2, drawlocation);
- drawlocation = draw_object(pod3, drawlocation);
- drawlocation = draw_object(pod4, drawlocation);
- drawlocation = draw_object(pod5, drawlocation);
- drawlocation = draw_object(pod6, drawlocation);
- drawlocation = draw_object(pod7, drawlocation);
- drawlocation = draw_object(pod8, drawlocation);
- drawlocation = draw_object(pod9, drawlocation);
-
+ // Draw pods objects 2-9
+ for(int podloop = 0; podloop<8; podloop++){ drawlocation = draw_object(pods[podloop], drawlocation); };
+
// Draw gate object 10
drawlocation = draw_object(gate, drawlocation);
drawlocation = draw_object(gatebeam1, drawlocation);
radar_plot(gatebeam1, drawlocation);
radar_plot(gatebeam2, drawlocation);
radar_plot(gatebeam3, drawlocation);
- radar_plot(pod2, drawlocation);
- radar_plot(pod3, drawlocation);
- radar_plot(pod4, drawlocation);
- radar_plot(pod5, drawlocation);
- radar_plot(pod6, drawlocation);
- radar_plot(pod7, drawlocation);
- radar_plot(pod8, drawlocation);
- radar_plot(pod9, drawlocation);
- radar_plot(player, drawlocation);
+ for(int podloop = 0; podloop<8; podloop++){ radar_plot(pods[podloop], drawlocation); };
//debug
//mvprintw(21,1,"y:%d drawloc:%d", pod2.y, drawlocation);
};
//check for / process pod pickup
- if((pod_in==0)&&(pod2.active==1)){pod_in = pod_check(pod2, player);};
- if((pod_in==0)&&(pod3.active==1)){pod_in = pod_check(pod3, player);};
- if((pod_in==0)&&(pod4.active==1)){pod_in = pod_check(pod4, player);};
- if((pod_in==0)&&(pod5.active==1)){pod_in = pod_check(pod5, player);};
- if((pod_in==0)&&(pod6.active==1)){pod_in = pod_check(pod6, player);};
- if((pod_in==0)&&(pod7.active==1)){pod_in = pod_check(pod7, player);};
- if((pod_in==0)&&(pod8.active==1)){pod_in = pod_check(pod8, player);};
- if((pod_in==0)&&(pod9.active==1)){pod_in = pod_check(pod9, player);};
+ for(int podloop = 0; podloop<8; podloop++){ if((pod_in==0)&&(pods[podloop].active==1)){pod_in = pod_check(pods[podloop], player);}; };
if(pod_in>0){
strcpy (player.line0, "<==x>");
if(pod_in>0){
if((abs(player.y-gate.y)<player.speed)&&(player.x>10)){
//set pod inactive
- if(pod_in==2){pod2 = pod_out(pod2);};
- if(pod_in==3){pod3 = pod_out(pod3);};
- if(pod_in==4){pod4 = pod_out(pod4);};
- if(pod_in==5){pod5 = pod_out(pod5);};
- if(pod_in==6){pod6 = pod_out(pod6);};
- if(pod_in==7){pod7 = pod_out(pod7);};
- if(pod_in==8){pod8 = pod_out(pod8);};
- if(pod_in==9){pod9 = pod_out(pod9);};
-
+ for(int podloop = 0; podloop<8; podloop++){ if(pod_in==pods[podloop].number){ pods[podloop] = pod_out(pods[podloop]); }; };
+
//increment score
score = score + 10;
pod_in = 0;
};
};
//check for / process player fire
-
+
//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;
+ podcount = 0;
+ for(int podloop = 0; podloop<8; podloop++){ podcount = podcount + pods[podloop].active; };
if(podcount<=0){
//Tally bonuses
//Award lives, if any
//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);
+ for(int podloop = 0; podloop<8; podloop++){ pods[podloop] = pod_init(pods[podloop]); };
};
}; //end main loop