/**********************************************************\ * Bugs : a bit-mapped arcade game for the AT&T UNIX PC. * * * * By : Hans Jespersen * * * \**********************************************************/ #include "bugs.h" movemyshot() { int index; wrastop(wn,shot,2,0,0,0,0,myshot.x,myshot.y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patblack); if( myshot.y < SHOTINC ) { shotflag = 0; myshot.y = BASE_LEVEL; } else { myshot.y -= SHOTINC; wrastop(wn,shot,2,0,0,0,0,myshot.x,myshot.y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patwhite); } for( index = 0; index <= nbugs; index++ ){ if( collide( myshot, REAL_SHOT_WIDTH, SHOT_HEIGHT, buglist[index], REAL_BUG_WIDTH, BUG_HEIGHT ) ){ wrastop(wn,shot,2,0,0,0,0,myshot.x,myshot.y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patblack); shotflag = 0; if( beepflag ) beep(); killbug( index ); } } for( index = 0; index <= nshots; index++ ){ if( collide( myshot, REAL_SHOT_WIDTH, SHOT_HEIGHT, shotlist[index], REAL_SHOT_WIDTH, SHOT_HEIGHT ) ){ wrastop(wn,shot,2,0,0,0,0,myshot.x,myshot.y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patblack); shotflag = 0; if( beepflag ) beep(); killshot( index ); score += SHOTSCORE; printscore(); } } for( index = 0; index < MAXSHELTERS; index++ ){ if( collide( myshot, REAL_SHOT_WIDTH, SHOT_HEIGHT, shelterlist[index], SHELTER_WIDTH, SHELTER_HEIGHT ) ){ wrastop(wn,shot,2,0,0,0,0,myshot.x,myshot.y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patblack); shotflag = 0; if( beepflag ) beep(); } } } movebugshot( index ) int index; { int i; struct position tmpbase; /* exclude laser canon from collision check */ tmpbase.x = mybase.x; tmpbase.y = mybase.y + 4; if( index <= nshots ) { if( shotlist[index].y <= BASE_LEVEL ) { wrastop(wn,shot,2,0,0,0,0,shotlist[index].x,shotlist[index].y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patblack); shotlist[index].y += SHOTINC; wrastop(wn,shot,2,0,0,0,0,shotlist[index].x,shotlist[index].y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patwhite); if( collide( shotlist[index], REAL_SHOT_WIDTH, SHOT_HEIGHT, tmpbase, REAL_BASE_WIDTH, BASE_HEIGHT ) ) { quitflag = TRUE; explode(); } for( i = 0; i < MAXSHELTERS; i++ ){ if( collide( shotlist[index], REAL_SHOT_WIDTH, SHOT_HEIGHT, shelterlist[i], SHELTER_WIDTH, SHELTER_HEIGHT ) ){ wrastop(wn,shot,2,0,0,0,0,shotlist[index].x,shotlist[index].y,REAL_SHOT_WIDTH,SHOT_HEIGHT,SRCAND,DSTSRC,patblack); killshot( index ); } } } else { killshot( index ); } } if( ++shotnum >= MAXSHOTS ) shotnum = 0; } bugshoot( index ) int index; { if( nshots < MAXSHOTS - 1 ) { if( rand() % chance == 0 ) { nshots++; shotlist[nshots].x = buglist[index].x + BUG_WIDTH / 2; shotlist[nshots].y = buglist[index].y + BUG_HEIGHT; } } } explode(){ int i; for(i=0;i<150;i++){ wrastop(wn,base,2,0,0,0,0,mybase.x,mybase.y,REAL_BASE_WIDTH,BASE_HEIGHT,SRCAND,DSTSRC,patwhite); wrastop(wn,base,2,0,0,0,0,mybase.x,mybase.y,REAL_BASE_WIDTH,BASE_HEIGHT,SRCAND,DSTSRC,patgray); wrastop(wn,base,2,0,0,0,0,mybase.x,mybase.y,REAL_BASE_WIDTH,BASE_HEIGHT,SRCAND,DSTSRC,patblack); wrastop(wn,base,2,0,0,0,0,mybase.x,mybase.y,REAL_BASE_WIDTH,BASE_HEIGHT,SRCAND,DSTSRC,patltgray); } }