const int bulletmax = 10;
const int landershotmax = 10;
const int landermax = 4;
+const int crawlermax = 6;
const float version = 1.0;
int score;
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;
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 },
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
int podsin = 0;
int landercount = 0;
int crazycount = 0;
+ int crawlercount = 0;
int alertleft = 0;
int alertright = 0;
int smartbombs = 4;
};
- 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);
};
};
+ for(int crawlerloop = 0; crawlerloop<crawlermax; crawlerloop++){
+ crawlers[crawlerloop] = process_motion(crawlers[crawlerloop], player);
+ };
+
// Draw player object 1
drawlocation = draw_object(player, drawlocation);
};
// 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);
};
};
+ // 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);
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
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.
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
};
};
};
+ 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;
+ };
+ };
+ };
};
};
};
};
+ //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){
};
};
+ // 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){
//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
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