#include <time.h>
const int landershotmax = 10;
+const int landermax = 4;
int score;
int lives;
game_object object_out(game_object object){
object.active=0;
- object.x = 0;
- object.y = 0;
+ object.x = -1;
+ object.y = -1;
object.speed = 0;
object.direction = 0;
return object;
return lander;
}
+game_object encrazify(game_object lander, game_object crazy){
+
+ int pause = 0;
+ while(pause!=' '){
+ cbreak();
+ mvprintw(10,20,"Crazy?\n");
+ pause = getch();
+ };
+ halfdelay(1);
+
+ crazy.active=1;
+ crazy.x = lander.x;
+ crazy.y = lander.y;
+ crazy.face = lander.face;
+ crazy.vspeed = lander.vspeed;
+ crazy.vtime = lander.vtime;
+ crazy.direction = lander.direction;
+ crazy.speed = lander.speed;
+
+ return crazy;
+}
+
game_object process_direction(game_object object, int input){
if(input==65){input=8;};
if(input==67){input=6;};
};
//landers
- struct game_object landers[4] = {
+ struct game_object landers[landermax] = {
{ 60, 1, rand()%16, rand()%620, 6, 0, 1, 0, 0 },
{ 61, 1, rand()%16, rand()%620, 4, 0, 1, 0, 0 },
{ 62, 1, rand()%16, rand()%620, 6, 0, 1, 0, 0 },
- { 63, 1, rand()%16, rand()%620, 4, 0, 1, 0, 0 },
+ { 63, 1, rand()%16, rand()%620, 4, 0, 1, 0, 0 }
};
- for(int landerloop = 0; landerloop<4; landerloop++){
+ for(int landerloop = 0; landerloop<landermax; landerloop++){
strcpy (landers[landerloop].line0, "{=}");
strcpy (landers[landerloop].radar, "*");
};
strcpy (landershot[landershotloop].line1, " . ");
};
+//crazies
+ struct game_object crazies[landermax] = {
+ { 90, 0, 0, 0, 6, 0, 1, 0, 0 },
+ { 91, 0, 0, 0, 4, 0, 1, 0, 0 },
+ { 92, 0, 0, 0, 6, 0, 1, 0, 0 },
+ { 93, 0, 0, 0, 4, 0, 1, 0, 0 }
+ };
+
+ for(int crazyloop = 0; crazyloop<landermax; crazyloop++){
+ strcpy (crazies[crazyloop].line0, "}!{");
+ strcpy (crazies[crazyloop].radar, "!");
+ };
+
initscr();
//main loop
};
};
- for(int landerloop = 0; landerloop<4; landerloop++){
+ for(int landerloop = 0; landerloop<landermax; landerloop++){
if(landers[landerloop].active==1){
landers[landerloop] = process_motion(landers[landerloop], player);
};
};
+ for(int crazyloop = 0; crazyloop<landermax; crazyloop++){
+ if(crazies[crazyloop].active==1){
+ crazies[crazyloop] = process_motion(crazies[crazyloop], player);
+ };
+ };
+
for(int landershotloop = 0; landershotloop<landershotmax; landershotloop++){
if(landershot[landershotloop].active==1){
landershot[landershotloop] = process_motion(landershot[landershotloop], player);
drawlocation = draw_object(gatebeam2, drawlocation);
drawlocation = draw_object(gatebeam3, drawlocation);
- // Draw enemies objects 60-63
- for(int landerloop = 0; landerloop<4; landerloop++){
+ // Draw landers objects 60-63
+ for(int landerloop = 0; landerloop<landermax; landerloop++){
if(landers[landerloop].active==1){
drawlocation = draw_object(landers[landerloop], drawlocation);
};
};
+ // Draw crazies objects 90-93
+ for(int crazyloop = 0; crazyloop<landermax; crazyloop++){
+ if(crazies[crazyloop].active==1){
+ drawlocation = draw_object(crazies[crazyloop], drawlocation);
+ };
+ };
+
// Draw shots objects 40-43
for(int bulletloop = 0; bulletloop<4; bulletloop++){
if(bullets[bulletloop].active==1){
radar_plot(gatebeam2, drawlocation);
radar_plot(gatebeam3, drawlocation);
for(int podloop = 0; podloop<8; podloop++){ radar_plot(pods[podloop], drawlocation); };
- for(int landerloop = 0; landerloop<4; landerloop++){ radar_plot(landers[landerloop], 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);
//pod state
};
};
};
- //check each active enemy
- for(int landerloop = 0; landerloop<4; landerloop++){
+ //check each active lander
+ for(int landerloop = 0; landerloop<landermax; landerloop++){
if(landers[landerloop].active==1){
if(check_collision(bullets[bulletloop], landers[landerloop])==1){
//kill lander and bullet
};
};
};
+ //check each active crazy
+ for(int crazyloop = 0; crazyloop<landermax; crazyloop++){
+ if(crazies[crazyloop].active==1){
+ if(check_collision(bullets[bulletloop], crazies[crazyloop])==1){
+ //kill crazy and bullet
+ crazies[crazyloop] = object_out(crazies[crazyloop]);
+ bullets[bulletloop].vtime = 100;
+ bullets[bulletloop] = age_bullet(bullets[bulletloop]);
+ //add to score
+ score = score + 20;
+ };
+ };
+ };
};
};
//watch for lander/player collisions
- for(int landerloop = 0; landerloop<4; landerloop++){
+ for(int landerloop = 0; landerloop<landermax; landerloop++){
if(landers[landerloop].active==1){
if(check_collision(player, landers[landerloop])==1){
//kill lander and player
};
};
+ //watch for crazy/player collisions
+ for(int crazyloop = 0; crazyloop<landermax; crazyloop++){
+ if(crazies[crazyloop].active==1){
+ if(check_collision(player, crazies[crazyloop])==1){
+ //kill crazy and player
+ crazies[crazyloop] = object_out(crazies[crazyloop]);
+ 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<8; podloop=podloop+2){
+ if(pods[podloop].number==pod_in){
+ pods[podloop] = object_out(pods[podloop]);
+ pod_in = 0;
+ strcpy (player.line0, "<==_>");
+ strcpy (player.line1, "<_==>");
+ };
+ };
+ };
+ };
+ };
+ };
+
// Lander shots
- for(int landerloop = 0; landerloop<4; landerloop++){
+ for(int landerloop = 0; landerloop<landermax; landerloop++){
if(landers[landerloop].active==1){
if(rand()%1000>200){
// lander shoot
for(int podloop = 0; podloop<8; podloop++){ pods[podloop] = pod_init(pods[podloop]); };
podsin = 0;
//regen landers
- for(int landerloop = 0; landerloop<4; landerloop++){
+ for(int landerloop = 0; landerloop<landermax; landerloop++){
if(landers[landerloop].active==0){
landers[landerloop] = lander_init(landers[landerloop]);
};
};
} else {
//crazy the landers
+ for(int landerloop = 0; landerloop<landermax; landerloop++){
+ if(landers[landerloop].active==1){
+ crazies[landerloop] = encrazify(landers[landerloop], crazies[landerloop]);
+ landers[landerloop] = object_out(landers[landerloop]);
+ };
+ };
//do the level victory once all crazies are dead
};
};
-
+
}; //end main loop
-
+
endwin();
return 0;