void movemissile() { samExplosion2 = load_sample("C:\\Sanchit\\Game Pack\\Sprites\\explosion2.wav"); int x = points[curpoint].x ; int y = points[curpoint].y ; scare_mouse(); rectfill(buffer,x-6,y-3,x+6,y+1,BLACK); if (getpixel(screen,x,y) == GREEN) { destroyed++; updatescore(); rectfill(buffer, 2, 14, 636, 352, BLACK); } else { putpixel(buffer,x,y-3,SMOKE); circlefill(buffer,x,y,2,BLUE); } unscare_mouse(); curpoint++; if (curpoint >= totalpoints) { play_sample(samExplosion2, 128, 128, 1000, 0); destroyed++; explosion2(screen, x, y, BLACK); textout_ex( screen, font, "Game Over", 300, 230, makecol( 255, 0, 0), makecol( 0, 0, 0)); rest(2000); textprintf(screen,font,300,245,makecol(255,255,255), "Final Score=%d", score); rest(2000); stop_sample(samSong); stop_sample(samExplosion2); score=-1; openscreen(); } }
int savecity() { buffer = create_bitmap(640,480); samSong = load_sample("C:\\Sanchit\\Game Pack\\Sprites\\savecity.wav"); samExplosion1 = load_sample("C:\\Sanchit\\Game Pack\\Sprites\\explosion1.wav"); textout(buffer,font,"Save City (ESC to quit)",0,1,WHITE); updatescore(); // rect(buffer, 0, 12, SCREEN_W-2, SCREEN_H-2, RED); city = load_bitmap("C:\\Sanchit\\Game Pack\\Sprites\\city.bmp", NULL); for (n = 0; n < 5; n++) masked_blit(city, buffer, 0, 0, 20+n*120, SCREEN_H-city->h-2, city->w, city->h); crosshair = load_bitmap("C:\\Sanchit\\Game Pack\\Sprites\\crosshair.bmp", NULL); set_mouse_sprite(crosshair); set_mouse_sprite_focus(15,15); show_mouse(buffer); play_sample(samSong, 128, 128, 1000, 1); while (!key[KEY_ESC]) { //above the red was border get destroyed rect(buffer, 0, 12, SCREEN_W-2, SCREEN_H-2, RED); mx = mouse_x; my = mouse_y; mb = (mouse_b & 1); if (destroyed) firenewmissile(); if (mb) { explosion1(screen,mx,my,GREEN); play_sample(samExplosion1, 40, 128, 1000, 0); } movemissile(); blit(buffer,screen,0,0,0,0,640,480); if(key[KEY_BACKSPACE]) { score=-1; firenewmissile(); stop_sample(samSong); openscreen(); } if(key[KEY_ESC]) { exit(1); } if(score>=0 && score <5) rest(10); else if(score>=5 && score<10) rest(9); else if(score>=10 && score<15) rest(8); else if(score>=15 && score<20) rest(7); else if(score>=20 && score<25) rest(6); else if(score>=25 && score<30) rest(5); else if(score>=30 && score<35) rest(4); else if(score>=35 && score<40) rest(3); else if(score>=40 && score<45) rest(2); else if(score>=45) rest(1); } set_mouse_sprite(NULL); destroy_bitmap(city); destroy_bitmap(crosshair); // openscreen(); return 0; }
void main() { if(InitGraphics() == -1) return; initialisedata(); clearviewport(); rectangle(0,0,(maxx+1)*width+2, (maxy+1)*width+2); sx = (maxx+1)*width+6; sy = (maxy+1)*width+2; int loop = 0; while(!endgame) { loop++; for (int i = 0; i < NUM_PLAYERS; i++) { drawplayer(plist[i]); } showscoreboard(); delay(DELAY_INTERVAL); for (i = 0; i < NUM_PLAYERS; i++) { showbox(plist[i]); } if (kbhit()) { handlekeypress(); } if (endgame) break; // 1 to n is computer plaer, 0 is me for (i = 1; i < NUM_PLAYERS; i++) { decidemove(plist[i]); } for (i = 0; i < NUM_PLAYERS; i++) { adjustdir(plist[i]); moveit(plist[i]); } for (i = 0; i < NUM_PLAYERS; i++) { updatescore(plist[i]); if (plist[i].score >= WINNING_SCORE) { endgame = true; setfillstyle(1, BLUE); bar(200,120,439,300); outtextxy(250,200,"GAME OVER"); if (i == 0) { outtextxy(250,250,"YOU WIN"); } else { outtextxy(250,250,"YOU LOSE"); } showscoreboard(); char tr = getch(); } } } }