#include <cstdlib>
#include <time.h>
+const int podmax = 8;
+const int bulletmax = 4;
const int landershotmax = 10;
const int landermax = 4;
//match y, then direction and speed
if(lander.chase>0&&lander.phase==1){
- if(abs(lander.y-pod.y)<4){
+ if(abs(lander.y-pod.y)<3){
lander.speed = 2;
};
if(lander.y==pod.y){
strcpy (gatebeam3.radar, "|");
//pods
- struct game_object pods[8] = {
+ struct game_object pods[podmax] = {
{ 2, 1, 18, rand()%620, 0, 0, 1, 0, 0 },
{ 3, 1, 18, rand()%620, 0, 0, 1, 0, 0 },
{ 4, 1, 18, rand()%620, 0, 0, 1, 0, 0 },
{ 9, 1, 18, rand()%620, 0, 0, 1, 0, 0 }
};
- for(int podloop = 0; podloop<8; podloop=podloop+2){
+ for(int podloop = 0; podloop<podmax; podloop=podloop+2){
if(rand()%1000>=500){
pods[podloop].direction = 4;
} else {
strcpy (pods[podloop].radar, "x");
};
- for(int podloop = 1; podloop<8; podloop=podloop+2){
+ for(int podloop = 1; podloop<podmax; podloop=podloop+2){
strcpy (pods[podloop].line0, " + ");
strcpy (pods[podloop].line1, " + ");
strcpy (pods[podloop].line2, " x ");
};
//bullets
- struct game_object bullets[4] = {
+ struct game_object bullets[bulletmax] = {
{ 40, 0, 0, 0, 5, 0, 0, 0, 0 },
{ 41, 0, 0, 0, 5, 0, 0, 0, 0 },
{ 42, 0, 0, 0, 5, 0, 0, 0, 0 },
{ 43, 0, 0, 0, 5, 0, 0, 0, 0 }
};
- for(int bulletloop = 0; bulletloop<4; bulletloop++){
+ for(int bulletloop = 0; bulletloop<bulletmax; bulletloop++){
strcpy (bullets[bulletloop].line0, " - ");
strcpy (bullets[bulletloop].line1, " - ");
};
//process object motion
player = process_motion(player, player);
- for(int podloop = 0; podloop<8; podloop++){ pods[podloop] = process_motion(pods[podloop], player); };
+ for(int podloop = 0; podloop<podmax; podloop++){ pods[podloop] = process_motion(pods[podloop], player); };
gatebeam1 = process_motion(gatebeam1, player);
gatebeam2 = process_motion(gatebeam2, player);
gatebeam3 = process_motion(gatebeam3, player);
- for(int bulletloop = 0; bulletloop<4; bulletloop++){
+ for(int bulletloop = 0; bulletloop<bulletmax; bulletloop++){
if(bullets[bulletloop].active==1){
bullets[bulletloop] = process_motion(bullets[bulletloop], player);
bullets[bulletloop] = age_bullet(bullets[bulletloop]);
drawlocation = draw_object(player, drawlocation);
// Draw pods objects 2-9
- for(int podloop = 0; podloop<8; 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);
};
// Draw shots objects 40-43
- for(int bulletloop = 0; bulletloop<4; bulletloop++){
+ for(int bulletloop = 0; bulletloop<bulletmax; bulletloop++){
if(bullets[bulletloop].active==1){
drawlocation = draw_object(bullets[bulletloop], drawlocation);
};
radar_plot(gatebeam1, drawlocation);
radar_plot(gatebeam2, drawlocation);
radar_plot(gatebeam3, drawlocation);
- for(int podloop = 0; podloop<8; podloop++){ radar_plot(pods[podloop], drawlocation); };
+ 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); };
radar_plot(player, drawlocation);
};
//check for / process pod pickup
- for(int podloop = 0; podloop<8; podloop++){
+ for(int podloop = 0; podloop<podmax; podloop++){
if((pod_in==0)&&(pods[podloop].active==1)&&(check_collision(pods[podloop], player)==1)){
pod_in = pods[podloop].number;
};
if(pod_in>0){
if((abs(player.y-gate.y)<player.speed)&&(player.x>10)){
//set pod inactive
- for(int podloop = 0; podloop<8; podloop++){ if(pod_in==pods[podloop].number){ pods[podloop] = object_out(pods[podloop]); }; };
+ for(int podloop = 0; podloop<podmax; podloop++){ if(pod_in==pods[podloop].number){ pods[podloop] = object_out(pods[podloop]); }; };
//increment score
score = score + 10;
if(input=='z'){
//we fired
//get next inactive bullet, give it player's direction, speed, height, location +speed in direction, active, set vtime=1.
- for(int bulletloop = 0; bulletloop<4; bulletloop++){
+ for(int bulletloop = 0; bulletloop<bulletmax; bulletloop++){
if(bullets[bulletloop].active==0){
bullets[bulletloop].active=1;
if(player.face==0){ bullets[bulletloop].direction = 4; };
};
//for each active bullet
- for(int bulletloop = 0; bulletloop<4; bulletloop++){
+ for(int bulletloop = 0; bulletloop<bulletmax; bulletloop++){
if(bullets[bulletloop].active==1){
//check each active pod
- for(int podloop = 0; podloop<8; podloop++){
+ for(int podloop = 0; podloop<podmax; podloop++){
if(pods[podloop].active==1){
if(check_collision(bullets[bulletloop], pods[podloop])==1){
//kill pod and bullet
drawlocation = player.y-20;
//kill any carried pods
if(pod_in>0){
- for(int podloop = 0; podloop<8; podloop++){
+ for(int podloop = 0; podloop<podmax; podloop++){
if(pods[podloop].number==pod_in){
pods[podloop] = object_out(pods[podloop]);
pod_in = 0;
drawlocation = player.y-20;
//kill any carried pods
if(pod_in>0){
- for(int podloop = 0; podloop<8; podloop++){
+ for(int podloop = 0; podloop<podmax; podloop++){
if(pods[podloop].number==pod_in){
pods[podloop] = object_out(pods[podloop]);
pod_in = 0;
drawlocation = player.y-20;
//kill any carried pods
if(pod_in>0){
- for(int podloop = 0; podloop<8; podloop++){
+ for(int podloop = 0; podloop<podmax; podloop++){
if(pods[podloop].number==pod_in){
pods[podloop] = object_out(pods[podloop]);
pod_in = 0;
//if(rand()%10000<=10){
if(rand()%1000<=10){
//choose the closest pod
- for(int podloop = 0; podloop<8; podloop++){
+ for(int podloop = 0; podloop<podmax; podloop++){
if(landers[landerloop].chase==0&&pods[podloop].chase==0&&pods[podloop].active==1){
landers[landerloop].chase = pods[podloop].number;
pods[podloop].chase = landers[landerloop].number;
};
};
//alert player print >>>> or <<<< at mid height, flash. set a value, have a function do it in the draw area.
- //travel to it at speed 4
- landers[landerloop].speed = 4;
+ //travel to it at speed 3
+ landers[landerloop].speed = 3;
if(player.y<landers[landerloop].y){ landers[landerloop].direction = 6; alertright = 20;};
if(player.y>=landers[landerloop].y){ landers[landerloop].direction = 4; alertleft = 20;};
landers[landerloop].phase = 1;
//check for 0 active pods, saved pods, level victory
podcount = 0;
- for(int podloop = 0; podloop<8; podloop++){ podcount = podcount + pods[podloop].active; };
+ for(int podloop = 0; podloop<podmax; podloop++){ podcount = podcount + pods[podloop].active; };
if(podcount<=0){
//do the level victory once all landers are dead
landercount = 0;
//Advance level
level++;
//Reactivate pods if not zombied
- for(int podloop = 0; podloop<8; podloop++){ pods[podloop] = pod_init(pods[podloop]); };
+ for(int podloop = 0; podloop<podmax; podloop++){ pods[podloop] = pod_init(pods[podloop]); };
podsin = 0;
//regen landers
for(int landerloop = 0; landerloop<landermax; landerloop++){