int pause = 0;
int shieldsleft = 400;
int tripshot = 0;
+int laser = 0;
struct game_object {
int number; //object number
int fodder = rand()%1000;
- if(fodder>=750){
+ if(fodder>=8000){
strcpy (powerup.line0, "T");
};
- if(fodder>=500&&fodder<750){
+ if(fodder>=600&&fodder<800){
strcpy (powerup.line0, "S");
};
- if(fodder>=250&&fodder<500){
+ if(fodder>=400&&fodder<600){
strcpy (powerup.line0, "L");
};
- if(fodder<250){
+ if(fodder>=200&&fodder<400){
strcpy (powerup.line0, "B");
};
+ if(fodder<200){
+ strcpy (powerup.line0, "Z");
+ };
return powerup;
};
int alertright = 0;
int smartbombs = 4;
int shieldup = 0;
+ int drawlaser = 0;
cbreak();
halfdelay(1);
};
};
- // Draw enemy shots 80-83
+ //draw laser beam
+ if(drawlaser==1){
+
+ int offset = 0;
+
+ offset = player.y-drawlocation;
+
+ if(drawlocation>=540&&player.y<620-drawlocation){
+ offset = 620-drawlocation+player.y; //right of player wrap correction
+ };
+
+ if(drawlocation<0&&player.y>=540){
+ offset = abs(drawlocation)-abs(620-player.y); //left of player wrap correction
+ };
+
+ if(player.face == 0){
+ //draw
+ for(int x=offset-1;x>=0;x--){
+ mvprintw(player.x,x,"-");
+ };
+
+ };
+ if(player.face == 1){
+ //draw
+ for(int x=offset+5;x<=79;x++){
+ mvprintw(player.x,x,"-");
+ };
+ };
+ drawlaser=0;
+ };
+
+ // Draw enemy shots 80-83
for(int landershotloop = 0; landershotloop<landershotmax; landershotloop++){
if(landershot[landershotloop].active==1){
drawlocation = draw_object(landershot[landershotloop], drawlocation);
if(strncmp(powerups[puploop].line0, "B", 1)==0){
smartbombs++;
};
+ if(strncmp(powerups[puploop].line0, "Z", 1)==0){
+ laser = laser + 100;
+ };
};
};
//check for / process player fire
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<bulletmax; bulletloop++){
- if(bullets[bulletloop].active==0){
- bullets[bulletloop].active=1;
- if(player.face==0){ bullets[bulletloop].direction = 4; };
- if(player.face==1){ bullets[bulletloop].direction = 6; };
- bullets[bulletloop].speed = player.speed + 2;
- bullets[bulletloop].x = player.x;
- int multiplier = 1;
- if(player.direction == 4){multiplier = -1; };
- bullets[bulletloop].y = player.y + (player.speed * multiplier);
- bullets[bulletloop].vtime = 1;
- break;
+ //if laser, do that
+ if(laser>0){
+ drawlaser=1;
+ //kill landers
+ for(int landerloop = 0; landerloop<landermax; landerloop++){
+ if((abs(player.y-landers[landerloop].y)<=40)&&(player.x==landers[landerloop].x)&&((player.face==0&&(landers[landerloop].y<player.y))||(player.face==1&&(landers[landerloop].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], landers[landerloop]);
+ break;
+ };
+ };
+ };
+ landers[landerloop] = object_out(landers[landerloop]);
+ score = score + 10;
+ };
};
- };
- if(tripshot>=1){
+ //kill crazies
+ for(int crazyloop = 0; crazyloop<landermax; crazyloop++){
+ if((abs(player.y-crazies[crazyloop].y)<=40)&&(player.x==crazies[crazyloop].x)&&((player.face==0&&(crazies[crazyloop].y<player.y))||(player.face==1&&(crazies[crazyloop].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], crazies[crazyloop]);
+ break;
+ };
+ };
+ };
+ crazies[crazyloop] = object_out(crazies[crazyloop]);
+ score = score + 10;
+ };
+ };
+ laser--;
+ } else {
+ //get next inactive bullet, give it player's direction, speed, height, location +speed in direction, active, set vtime=1.
for(int bulletloop = 0; bulletloop<bulletmax; bulletloop++){
if(bullets[bulletloop].active==0){
bullets[bulletloop].active=1;
if(player.face==0){ bullets[bulletloop].direction = 4; };
if(player.face==1){ bullets[bulletloop].direction = 6; };
bullets[bulletloop].speed = player.speed + 2;
- bullets[bulletloop].x = player.x-1;
+ bullets[bulletloop].x = player.x;
int multiplier = 1;
if(player.direction == 4){multiplier = -1; };
bullets[bulletloop].y = player.y + (player.speed * multiplier);
bullets[bulletloop].vtime = 1;
- tripshot--;
break;
};
};
- for(int bulletloop = 0; bulletloop<bulletmax; bulletloop++){
- if(bullets[bulletloop].active==0){
- bullets[bulletloop].active=1;
- if(player.face==0){ bullets[bulletloop].direction = 4; };
- if(player.face==1){ bullets[bulletloop].direction = 6; };
- bullets[bulletloop].speed = player.speed + 2;
- bullets[bulletloop].x = player.x+1;
- int multiplier = 1;
- if(player.direction == 4){multiplier = -1; };
- bullets[bulletloop].y = player.y + (player.speed * multiplier);
+ if(tripshot>=1){
+ for(int bulletloop = 0; bulletloop<bulletmax; bulletloop++){
+ if(bullets[bulletloop].active==0){
+ bullets[bulletloop].active=1;
+ if(player.face==0){ bullets[bulletloop].direction = 4; };
+ if(player.face==1){ bullets[bulletloop].direction = 6; };
+ bullets[bulletloop].speed = player.speed + 2;
+ bullets[bulletloop].x = player.x-1;
+ int multiplier = 1;
+ if(player.direction == 4){multiplier = -1; };
+ bullets[bulletloop].y = player.y + (player.speed * multiplier);
bullets[bulletloop].vtime = 1;
tripshot--;
break;
+ };
+ };
+ for(int bulletloop = 0; bulletloop<bulletmax; bulletloop++){
+ if(bullets[bulletloop].active==0){
+ bullets[bulletloop].active=1;
+ if(player.face==0){ bullets[bulletloop].direction = 4; };
+ if(player.face==1){ bullets[bulletloop].direction = 6; };
+ bullets[bulletloop].speed = player.speed + 2;
+ bullets[bulletloop].x = player.x+1;
+ int multiplier = 1;
+ if(player.direction == 4){multiplier = -1; };
+ bullets[bulletloop].y = player.y + (player.speed * multiplier);
+ bullets[bulletloop].vtime = 1;
+ tripshot--;
+ break;
+ };
};
};
};