# include # include # include # include # include # include "apvector.h" # include "apstring.h" # include # include //# include "CMUgraphicsLib/CMUgraphics.h" # include # include typedef bool map[600][800]; typedef int map2[600][300]; window window1(800, 600, 10, 20); window window2(300, 600, 815, 20); window window3(1,1,900, 900); struct tankposition { int x; int y; }; struct weapon { apstring Weapon_name; int Ammo_per_purchase; int Weapon_price; int Weapon_damage; int Weapon_radius; }; struct tank { tankposition pos; int weapon_array[10]; int my_money; int lifepoints; int player; color c; int win; }; struct windstruct { char direction; int speed; }; struct anglestruct { double degrees; }; typedef weapon list[10]; typedef tank tanktype[2]; typedef int selectiontype[11]; char pathoption(); void clrscr(); void defaultbuy(tanktype &player, list Weapon_info); void weapon_menu(tanktype &player, list Weapon_info, int buyer_int); void createwind(windstruct &wind); void weapondefinition(list Weapon_info); void tankdefinition(int &win, int p, int &player, int &money, int &lifepoints, color &c, color t); void terrainselect(map matrix1, color &outside); void mountains(map matrix1, color &background); void forest(map matrix1, color &background); void evacuated_city(map matrix1, color &background); void arctic(map matrix1, color &background); void desert(map matrix1, color &background); void tankplacement(map matrix1, tankposition &tank1, tankposition &tank2); void tankreplace(map matrix1, tankposition &tank, int radius); void drawtank(tankposition tank, color t, int turn); void projectile(map matrix1, weapon choice, char want, int turn, tanktype &tank, anglestruct angle, double velocity, color sky, windstruct wind); void blast(map matrix1, int damage, tankposition pos, tanktype &tank, int radius, color sky); void fire(map matrix1, char want, int turn, tanktype &tank, color sky, windstruct wind, list weaponsall); void drawlifepoints(int lifepoints, int player); void drawwind(windstruct wind); void drawanglevelocity(double angledegrees, double velocity, color t); void playerturn(tanktype tank, int turn, color t); int weaponlistdis(selectiontype &link, tank tank1); void window2reset(); void WaitNClear(window &inputWindow); void window2setnum(int x, int y, int size, int i); void window2clrscr(); void askplayer(int x, tanktype &tanknum, list Weapon_info); int numgames(); void weapon_menu2(tanktype &player, list Weapon_info, int buyer_int, int weapon_int); void weapon_menu3(tanktype &player, list Weapon_info, int buyer_int); const double PI = 3.1415926535897932384626433832795; map2 w2; int main () { tanktype tanknum; map World; list weaponsall; windstruct wind; color outside; char want; int games; bool win; int winner; apstring wait; win = FALSE; weapondefinition(weaponsall); tankdefinition(tanknum[0].win, 1, tanknum[0].player, tanknum[0].my_money, tanknum[0].lifepoints, tanknum[0].c, RED); tankdefinition(tanknum[1].win, 2, tanknum[1].player, tanknum[1].my_money, tanknum[1].lifepoints, tanknum[1].c, BLUE); games = numgames(); want = pathoption(); defaultbuy(tanknum, weaponsall); while (win == FALSE) { for (int i = 1; i < 3; i++) askplayer(i, tanknum, weaponsall); createwind(wind); terrainselect(World, outside); drawwind(wind); drawlifepoints(100,0); drawlifepoints(100,1); drawwind(wind); tankplacement(World, tanknum[0].pos, tanknum[1].pos); drawtank(tanknum[0].pos, tanknum[0].c, 0); drawtank(tanknum[1].pos, tanknum[1].c, 1); while ((tanknum[0].lifepoints > 0) && (tanknum[1].lifepoints > 0)) { fire(World, want, 0, tanknum, outside, wind, weaponsall); drawlifepoints(tanknum[0].lifepoints, 0); drawlifepoints(tanknum[1].lifepoints, 1); drawwind(wind); if (tanknum[0].lifepoints > 0) { fire(World, want, 1, tanknum, outside, wind, weaponsall); drawlifepoints(tanknum[0].lifepoints, 0); drawlifepoints(tanknum[1].lifepoints, 1); drawwind(wind); } } for (int y = 0; y < 2; y++) if (tanknum[y].lifepoints > 0) { tanknum[y].win++; winner = y; } cout << "Player " << winner + 1 << " Wins This Round" << endl; cout << "Current Score: " << endl; cout << "Player 1: " << tanknum[0].win << endl; cout << "Player 2: " << tanknum[1].win << endl; if (tanknum[winner].win >= games / 2 + 1) { cout << "Player " << winner + 1 << " Is The Ultimate Winner" << endl; win = TRUE; } else { cout << "Enter A Character To Proceed To The Next Round: "; cin >> wait; } } return 0; } void window2setnum(int x, int y, int size, int i) { window2.SetPen(BLACK, 3); window2.SetBrush(RED); for (int rw = 0; rw < size + 1; rw++) for (int col = 0; col < size + 1; col++) w2[y + rw][x + col] = i; } void clrscr() { COORD coordScreen = { 0, 0 }; DWORD cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbi; DWORD dwConSize; HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); GetConsoleScreenBufferInfo(hConsole, &csbi); dwConSize = csbi.dwSize.X * csbi.dwSize.Y; FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten); GetConsoleScreenBufferInfo(hConsole, &csbi); FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten); SetConsoleCursorPosition(hConsole, coordScreen); } void window2clrscr() { window2.SetPen(WHITE); window2.SetBrush(WHITE); window2.DrawRectangle(0, 0, window2.GetWidth(), window2.GetHeight()); } void window2reset() { for (int r = 0; r < 600; r++) for (int c = 0; c < 300; c++) w2[r][c] = 0; } void mountains (map matrix1, color &background) { background = CADETBLUE; for (int row = 0; row <600; ++ row) { for (int colmn = 0; colmn < 800; ++colmn) { matrix1[row][colmn] = 0; } } window1.SetBrush(background); window1.SetPen(background); window1.DrawRectangle(0, 0, 800, 600, FILLED); for (int r = 520; r < 600; ++r) { for (int c = 0; c < 800; ++c) { matrix1[r][c] = 1; } } window1.SetPen(BROWN); window1.SetBrush(BROWN); window1.DrawRectangle(0, 520, 800, 600, FILLED); for (int rows = 300; rows < 520; ++rows) { for (int columns = 0; columns < 150; ++columns) { matrix1[rows][columns] = 1; } } window1.DrawRectangle(0, 300, 150, 520, FILLED); for (int k = 0; k < 200; ++k) { for (int c1 = 0 + k; c1 < 400 - k; ++c1) { matrix1[519 - (2 * k)][c1] = 1; matrix1[518 - (2 * k)][c1] = 1; } } window1.DrawTriangle(200, 118, 0, 519, 400, 519, FILLED); for (int j = 0; j < 100; ++j) { for (int c3 = 400 + j; c3 < 600 - j ; ++c3) { matrix1[520 - (2 * j)][c3] = 1; matrix1[519 - (2 * j)][c3] = 1; } } window1.DrawTriangle(400, 520, 600, 520, 500, 319, FILLED); for (int r4 = 400; r4 < 520; ++r4) { for (int c4 = 575; c4 < 800; ++ c4) { matrix1[r4][c4] = 1; } } window1.DrawRectangle(575, 400, 800, 520, FILLED); for (int n = 0; n < 180; ++n) { for (int c6 = 540 + n; c6 < 720- n; ++c6) { matrix1[480 - (3 * n)][c6] = 1; matrix1[479 - (3 * n)][c6] = 1; matrix1[478 - (3 * n)][c6] = 1; } } window1.DrawTriangle(540, 480, 720, 480, 630, 208, FILLED); window1.SetPen(WHITE); window1.SetBrush(WHITE); window1.DrawCircle(300, 90, 20, FILLED); window1.DrawEllipse(305, 60, 400, 125, FILLED); window1.DrawCircle(400, 90, 20, FILLED); window1.DrawCircle(400, 60, 20, FILLED); window1.DrawEllipse(405, 30, 500, 95, FILLED); window1.DrawCircle(500, 60, 20, FILLED); window1.DrawCircle(195, 70, 15, FILLED); window1.DrawEllipse(200, 40, 295, 105, FILLED); window1.DrawCircle(295, 70, 15, FILLED); window1.DrawCircle(300, 60, 40, FILLED); window1.DrawCircle(575, 150, 15, FILLED); window1.DrawEllipse(575, 125, 680, 175, FILLED); window1.DrawCircle(675, 150, 15, FILLED); window1.DrawCircle(610, 135, 25, FILLED); window1.SetBrush(ORANGE); window1.SetPen(ORANGE); window1.DrawTriangle(740, 75, 660, 75, 700, 145, FILLED); window1.DrawTriangle(700, 55, 660, 125, 740, 125, FILLED); window1.SetBrush(YELLOW); window1.SetPen(YELLOW); window1.DrawCircle(700, 100, 30, FILLED); } void forest(map matrix1, color &background) { background = DEEPSKYBLUE; for (int row = 0; row <600; ++ row) { for (int colmn = 0; colmn < 800; ++colmn) { matrix1[row][colmn] = 0; } } for (int r = 420; r < 600; ++r) { for (int c = 0; c < 800; ++c) { matrix1[r][c] = 1; } } /* window window1(800, 600, 10, 20); for (int rw = 0; rw < 600; ++rw) { for (int clm = 0; clm < 800; ++clm) { if (matrix1[rw][clm] == 0) { window1.SetPen(background); window1.DrawPixel(clm, rw); } else { window1.SetPen(GREEN); window1.DrawPixel(clm, rw); } } }*/ //window window1(800, 600, 10, 20); window1.SetPen(background); window1.SetBrush(background); window1.DrawRectangle(0, 0, 800, 600, FILLED); window1.SetPen(GREEN); window1.SetBrush(GREEN); window1.DrawRectangle(0, 420, 800, 600, FILLED); for (int k = 0; k < 50; ++k) { for (int c1 = 60 + (k * k); c1 < 600 - (k * k); ++c1) { matrix1[419 - (7 * k)][c1] = 1; matrix1[418 - (7 * k)][c1] = 1; matrix1[417 - (7 * k)][c1] = 1; matrix1[416 - (7 * k)][c1] = 1; matrix1[415 - (7 * k)][c1] = 1; matrix1[414 - (7 * k)][c1] = 1; matrix1[413 - (7 * k)][c1] = 1; } for (int c2 = 80 + (k * k); c2 < 250 - (k * k); ++c2) { matrix1[380 - (5 * k)][c2] = 1; matrix1[379 - (5 * k)][c2] = 1; matrix1[378 - (5 * k)][c2] = 1; matrix1[377 - (5 * k)][c2] = 1; matrix1[376 - (5 * k)][c2] = 1; } for (int c3 = 180 + (k * k); c3 < 300 -(k * k); ++c3) { matrix1[335 - (6 * k)][c3] = 1; matrix1[334 - (6 * k)][c3] = 1; matrix1[333 - (6 * k)][c3] = 1; matrix1[332 - (6 * k)][c3] = 1; matrix1[331 - (6 * k)][c3] = 1; matrix1[330 - (6 * k)][c3] = 1; } for (int c4 = 280 + (k * k); c4 < 400 - (k * k); ++c4) { matrix1[350 - (3 * k)][c4] = 1; matrix1[349 - (3 * k)][c4] = 1; matrix1[348 - (3 * k)][c4] = 1; } for (int c5 = 450 + (k * k); c5 < 590 - (k * k); ++c5) { matrix1[390 - (4 * k)][c5] = 1; matrix1[389 - (4 * k)][c5] = 1; matrix1[388 - (4 * k)][c5] = 1; matrix1[387 - (4 * k)][c5] = 1; } for (int c6 = 610 + (k * k); c6 < 750 - (k * k); ++c6) { matrix1[420 - (5 * k)][c6] = 1; matrix1[419 - (5 * k)][c6] = 1; matrix1[418 - (5 * k)][c6] = 1; matrix1[417 - (5 * k)][c6] = 1; matrix1[416 - (5 * k)][c6] = 1; } for (int c7 = 650 + (k * k); c7 < 700 - (k * k); ++c7) { matrix1[390 - (3 * k)][c7] = 1; matrix1[389 - (3 * k)][c7] = 1; matrix1[388 - (3 * k)][c7] = 1; } } window1.SetPen(DARKGREEN); window1.SetBrush(DARKGREEN); window1.DrawCircle(270, 340, 40, FILLED); window1.DrawCircle(270, 300, 30, FILLED); window1.SetPen(BROWN); window1.SetBrush(BROWN); window1.DrawRectangle(265, 375, 275, 415, FILLED); for (int m = 0; m < 4; ++m) { window1.SetPen(GREEN); window1.SetBrush(GREEN); window1.DrawCircle(200 + (m * 50), 370, 40, FILLED); window1.DrawCircle(200 + (m * 50), 330, 30, FILLED); window1.SetPen(BROWN); window1.SetBrush(BROWN); window1.DrawRectangle(195 + (m * 50), 405, 205 + (m * 50), 445, FILLED); } for (int n = 0; n < 3; ++n) { window1.SetPen(FORESTGREEN); window1.SetBrush(FORESTGREEN); window1.DrawCircle(230 + (n * 70), 360, 40, FILLED); window1.DrawCircle(230 + (n * 70), 320, 30, FILLED); window1.SetPen(BROWN); window1.SetBrush(BROWN); window1.DrawRectangle(225 + (n * 70), 395, 235 + (n * 70), 435, FILLED); } for (int p = 0; p < 8; ++p) { window1.SetPen(DARKGREEN); window1.SetBrush(DARKGREEN); window1.DrawCircle(120 + (p * 50), 400, 40, FILLED); window1.DrawCircle(120 + (p * 50), 360, 30, FILLED); window1.SetPen(BROWN); window1.SetBrush(BROWN); window1.DrawRectangle(115 + (p * 50), 435, 125 + (p * 50), 485, FILLED); } for (int j = 0; j < 5; ++j) { window1.SetPen(GREEN); window1.SetBrush(GREEN); window1.DrawCircle(160 + (j * 80), 390, 40, FILLED); window1.DrawCircle(160 + (j * 80), 350, 30, FILLED); window1.SetPen(BROWN); window1.SetBrush(BROWN); window1.DrawRectangle(155 + (j * 80), 425, 165 + (j * 80), 475, FILLED); } window1.SetPen(DARKGREEN); window1.SetBrush(DARKGREEN); window1.DrawCircle(545, 410, 40, FILLED); window1.DrawCircle(545, 375, 30, FILLED); window1.SetPen(BROWN); window1.SetBrush(BROWN); window1.DrawRectangle(535, 445, 545, 475, FILLED); window1.SetPen(DARKGREEN); window1.SetBrush(DARKGREEN); window1.DrawCircle(680, 410, 30, FILLED); window1.SetPen(FORESTGREEN); window1.SetBrush(FORESTGREEN); window1.DrawCircle(665, 430, 35, FILLED); window1.DrawCircle(650, 445, 30, FILLED); window1.SetPen(DARKGREEN); window1.SetBrush(DARKGREEN); window1.DrawCircle(720, 425, 30, FILLED); window1.DrawCircle(685, 435, 40, FILLED); window1.SetBrush(ORANGE); window1.SetPen(ORANGE); window1.DrawTriangle(100, 75, 20, 75, 60, 145, FILLED); window1.DrawTriangle(60, 55, 20, 125, 100, 125, FILLED); window1.SetBrush(YELLOW); window1.SetPen(YELLOW); window1.DrawCircle(60, 100, 30, FILLED); window1.SetPen(WHITE); window1.SetBrush(WHITE); window1.DrawCircle(300, 90, 20, FILLED); window1.DrawEllipse(305, 60, 400, 125, FILLED); window1.DrawCircle(400, 90, 20, FILLED); window1.DrawCircle(400, 60, 20, FILLED); window1.DrawEllipse(405, 30, 500, 95, FILLED); window1.DrawCircle(500, 60, 20, FILLED); window1.DrawCircle(575, 150, 15, FILLED); window1.DrawEllipse(575, 125, 680, 175, FILLED); window1.DrawCircle(675, 150, 15, FILLED); window1.DrawCircle(610, 135, 25, FILLED); //WaitNClear(window1); } void evacuated_city(map matrix1, color &background) { background = STEELBLUE; for (int row = 0; row <600; ++ row) { for (int colmn = 0; colmn < 800; ++colmn) { matrix1[row][colmn] = 0; } } for (int r = 420; r < 600; ++r) { for (int c = 0; c < 800; ++c) { matrix1[r][c] = 1; } } //window window1(800, 600, 10, 20); /*for (int rw = 0; rw < 600; ++rw) { for (int clm = 0; clm < 800; ++clm) { if (matrix1[rw][clm] == 0) { window1.SetPen(background); window1.DrawPixel(clm, rw); } else { window1.SetPen(GRAY); window1.DrawPixel(clm, rw); } } }*/ window1.SetBrush(background); window1.SetPen(background); window1.DrawRectangle(0, 0, 800, 600, FILLED); window1.SetBrush(GRAY); window1.SetPen(GRAY); window1.DrawRectangle(0, 420, 800, 600, FILLED); for (int r1 = 320; r1 < 420; ++ r1) { for (int c1 = 100; c1 < 170; ++ c1) { matrix1[r1][c1] = 1; } } window1.SetPen(DARKBLUE); window1.SetBrush(DARKBLUE); window1.DrawRectangle(100, 320, 170, 420, FILLED); for (int r2 = 230 ; r2 < 420; ++r2) { for (int c2 = 170; c2 < 260; ++c2) { matrix1[r2][c2] = 1; } } window1.SetBrush(DARKGRAY); window1.SetPen(DARKGRAY); window1.DrawRectangle(170, 230, 260, 420, FILLED); window1.SetBrush(WHITE); window1.SetPen(BLACK); for (int i = 0; i < 6; ++i) { window1.DrawRectangle(182, 240 + (i * 30), 197, 260 + (i * 30), FILLED); window1.DrawRectangle(207, 240 + (i * 30), 222, 260 + (i * 30), FILLED); window1.DrawRectangle(232, 240 + (i * 30), 247, 260 + (i * 30), FILLED); } for (int r3 = 270; r3 < 420; ++ r3) { for (int c3 = 260; c3 < 320; ++ c3) { matrix1[r3][c3] = 1; } } window1.SetPen(DARKGREEN); window1.SetBrush(DARKGREEN); window1.DrawRectangle(260, 270, 320, 420, FILLED); for (int r4 = 175; r4 < 420; ++ r4) { for (int c4 = 320; c4 < 410; ++ c4) { matrix1[r4][c4] = 1; } } window1.SetPen(DARKRED); window1.SetBrush(DARKRED); window1.DrawRectangle(320, 175, 410, 420, FILLED); window1.SetPen(BLACK); window1.SetBrush(LIGHTYELLOW); for (int j = 0; j < 7; ++j) { window1.DrawRectangle(330, 180 + (j * 35), 345, 210 + (j * 35), FILLED); window1.DrawRectangle(358, 180 + (j * 35), 373, 210 + (j * 35), FILLED); window1.DrawRectangle(386, 180 + (j * 35), 401, 210 + (j * 35), FILLED); } for (int r5 = 305; r5 < 420; ++ r5) { for (int c5 = 425; c5 < 455; ++ c5) { matrix1[r5][c5] = 1; } } window1.SetPen(TURQUOISE); window1.SetBrush(TURQUOISE); window1.DrawRectangle(425, 305, 455, 420, FILLED); for (int r6 = 150; r6 < 420; ++ r6) { for (int c6 = 455; c6 < 530; ++ c6) { matrix1[r6][c6] = 1; } } window1.SetPen(BLUE); window1.SetBrush(BLUE); window1.DrawRectangle(455, 150, 530, 420, FILLED); window1.SetPen(BLACK); window1.SetBrush(WHITE); for (int k = 0; k < 7; ++k) { window1.DrawRectangle(460, 165 + (k * 35), 478, 185 + (k * 35), FILLED); window1.DrawRectangle(483, 165 + (k * 35), 503, 185 + (k * 35), FILLED); window1.DrawRectangle(508, 165 + (k * 35), 525, 185 + (k * 35), FILLED); } for (int r7 = 215; r7 < 420; ++ r7) { for (int c7 = 530; c7 < 600; ++ c7) { matrix1[r7][c7] = 1; } } window1.SetPen(DARKORANGE); window1.SetBrush(DARKORANGE); window1.DrawRectangle(530, 215, 600, 420, FILLED); for (int r8 = 305; r8 < 420; ++ r8) { for (int c8 = 600; c8 < 650; ++ c8) { matrix1[r8][c8] = 1; } } window1.SetPen(WHITE); window1.SetBrush(WHITE); window1.DrawRectangle(600, 305, 650, 420, FILLED); for (int r9 = 275; r9 < 420; ++ r9) { for (int c9 = 650; c9 < 710; ++ c9) { matrix1[r9][c9] = 1; } } window1.SetPen(PURPLE); window1.SetBrush(PURPLE); window1.DrawRectangle(650, 275, 710, 420, FILLED); window1.SetPen(DARKGRAY); window1.SetBrush(DARKGRAY); window1.DrawCircle(400, 60, 20, FILLED); window1.DrawEllipse(405, 30, 500, 95, FILLED); window1.DrawCircle(500, 60, 20, FILLED); window1.DrawCircle(195, 70, 15, FILLED); window1.DrawEllipse(200, 40, 295, 105, FILLED); window1.DrawCircle(295, 70, 15, FILLED); window1.DrawCircle(300, 60, 40, FILLED); window1.SetPen(GRAY); window1.SetBrush(GRAY); window1.DrawCircle(300, 90, 20, FILLED); window1.DrawEllipse(305, 60, 400, 125, FILLED); window1.DrawCircle(400, 90, 20, FILLED); window1.SetPen(GRAY); window1.SetBrush(GRAY); window1.DrawCircle(575, 100, 15, FILLED); window1.DrawEllipse(575, 75, 680, 125, FILLED); window1.DrawCircle(675, 100, 15, FILLED); window1.DrawCircle(610, 85, 25, FILLED); //WaitNClear(window1); } void arctic(map matrix1, color &background) { background = MIDNIGHTBLUE; for (int row = 0; row <600; ++ row) { for (int colmn = 0; colmn < 800; ++colmn) { matrix1[row][colmn] = 0; } } window1.SetPen(background); window1.SetBrush(background); window1.DrawRectangle(0, 0, 800, 600, FILLED); for (int r = 520; r < 600; ++r) { for (int c = 0; c < 800; ++c) { matrix1[r][c] = 1; } } window1.SetPen(WHITE); window1.SetBrush(WHITE); window1.DrawRectangle(0, 520, 800, 600, FILLED); for (int rows = 500; rows < 550; ++rows) { for (int columns = 0; columns < 150; ++columns) { matrix1[rows][columns] = 1; } } window1.DrawRectangle(0, 500, 150, 550, FILLED); for (int k = 0; k < 200; ++k) { for (int c1 = 20 + k; c1 < 300 - k; ++c1) { matrix1[519 - k][c1] = 1; } } window1.DrawTriangle(20, 519, 300, 519, 160, 379, FILLED); for (int j = 0; j < 500; ++j) { for (int c3 = 250 + j; c3 < 550 - j ; ++c3) { matrix1[520 - (3 * j)][c3] = 1; matrix1[519 - (3 * j)][c3] = 1; matrix1[518 - (3 * j)][c3] = 1; } } window1.DrawTriangle(250, 520, 550, 520, 400, 68, FILLED); for (int r4 = 350; r4 < 520; ++r4) { for (int c4 = 575; c4 < 800; ++ c4) { matrix1[r4][c4] = 1; } } window1.DrawRectangle(575, 350, 800, 520, FILLED); for (int n = 0; n < 180; ++n) { for (int c6 = 520 + n; c6 < 720- n; ++c6) { matrix1[520 - (3 * n)][c6] = 1; matrix1[519 - (3 * n)][c6] = 1; matrix1[518 - (3 * n)][c6] = 1; } } window1.DrawTriangle(520, 520, 720, 520, 620, 218, FILLED); window1.SetBrush(PALEGOLDENROD); window1.SetPen(PALEGOLDENROD); window1.DrawCircle(100, 100, 45, FILLED); window1.SetBrush(MIDNIGHTBLUE); window1.SetPen(MIDNIGHTBLUE); window1.DrawCircle(125, 75, 40, FILLED); window1.SetBrush(GOLD); window1.SetPen(GOLD); for (int q = 0; q < 10; ++q) { window1.DrawCircle(150 + (350 * q), 25, 3, FILLED); window1.DrawCircle(200 + (200 * q), 10, 2, FILLED); window1.DrawCircle(175 + (250 * q), 115, 1, FILLED); window1.DrawCircle(190 + (300* q), 100, 2, FILLED); window1.DrawCircle(205 + (150 * q), 62, 2, FILLED); } } void desert(map matrix1, color &background) { background = FIREBRICK; for (int row = 0; row <600; ++ row) { for (int colmn = 0; colmn < 800; ++colmn) { matrix1[row][colmn] = 0; } } for (int r = 420; r < 600; ++r) { for (int c = 0; c < 800; ++c) { matrix1[r][c] = 1; } } for (int r1 = 250; r1 < 450; ++r1) { for (int col = 0; col < 250; ++col) { matrix1[r1][col] = 1; } } for (int k = 0; k < 50; ++k) { for (int c5 = 0 + (k * k); c5 < 275 - (k * k); ++c5) { matrix1[250 - (4 * k)][c5] = 1; matrix1[249 - (4 * k)][c5] = 1; matrix1[248 - (4 * k)][c5] = 1; matrix1[247 - (4 * k)][c5] = 1; } for (int c1 = 450 + (k * k); c1 < 800 - (k * k); ++c1) { matrix1[419 - (7 * k)][c1] = 1; matrix1[418 - (7 * k)][c1] = 1; matrix1[417 - (7 * k)][c1] = 1; matrix1[416 - (7 * k)][c1] = 1; matrix1[415 - (7 * k)][c1] = 1; matrix1[414 - (7 * k)][c1] = 1; matrix1[413 - (7 * k)][c1] = 1; } } for (int j = 0; j <180; ++j) { for (int c4 = 35 + j; c4 < 460 - j; ++c4) { matrix1[425 - j][c4] = 1; } } //window window1(800, 600, 10, 20); window1.SetPen(background); window1.SetBrush(background); window1.DrawRectangle(0, 0, 800, 600, FILLED); window1.SetPen(LIGHTGOLDENROD); window1.SetBrush(LIGHTGOLDENROD); window1.DrawEllipse(475, 330, 780, 450, FILLED); window1.DrawTriangle(480, 375, 480, 425, 430, 425, FILLED); window1.DrawTriangle(770, 375, 770, 400, 800, 400, FILLED); window1.DrawRectangle(480, 400, 800, 600, FILLED); window1.SetPen(PALEGOLDENROD); window1.SetBrush(PALEGOLDENROD); window1.DrawEllipse(0, 200, 275, 330, FILLED); window1.DrawRectangle(0, 275, 300, 600, FILLED); window1.DrawTriangle(250, 225, 250, 600, 675, 600, FILLED); window1.DrawRectangle(0, 575, 800, 600, FILLED); window1.DrawTriangle(450, 500, 800, 600, 450, 600, FILLED); window1.SetPen(ORANGERED); window1.SetBrush(ORANGERED); window1.DrawCircle(700, 150, 50, FILLED); window1.SetPen(DARKGREEN); window1.SetBrush(DARKGREEN); window1.DrawRectangle(50, 550, 70, 460, FILLED); window1.DrawRectangle(70, 500, 80, 520, FILLED); window1.DrawRectangle(80, 520, 95, 475, FILLED); window1.DrawRectangle(50, 500, 40, 485, FILLED); window1.DrawRectangle(40, 500, 30, 470, FILLED); } void drawwind(windstruct wind) { using namespace std; ostringstream output; if (wind.direction == 'E') { output << wind.speed << " mph East"; window1.SetPen(BLACK, 5); window1.SetBrush(WHITE); window1.DrawRectangle(300, 10, 500, 70, FRAME); window1.SetPen(RED, 0); window1.SetBrush(RED); window1.DrawRectangle(325, 30, 400, 50, FILLED); window1.DrawTriangle(400, 20, 400, 60, 475, 40, FILLED); window1.SetPen(WHITE); window1.SetFont(16, BOLD | ITALICIZED, BY_NAME, "Arial"); window1.DrawString(350, 32, output.str()); } if (wind.direction == 'W') { output << wind.speed << " mph West"; window1.SetPen(BLACK, 5); window1.SetBrush(WHITE); window1.DrawRectangle(300, 10, 500, 70, FRAME); window1.SetPen(RED, 0); window1.SetBrush(RED); window1.DrawRectangle(400, 30, 475, 50, FILLED); window1.DrawTriangle(400, 20, 400, 60, 325, 40, FILLED); window1.SetPen(WHITE); window1.SetFont(16, BOLD | ITALICIZED, BY_NAME, "Arial"); window1.DrawString(375, 32, output.str()); } //WaitNClear(window1); } int numgames() { int a; cout << "Best Out of How Many Games (Min 1, Max 5): "; cin >> a; clrscr(); return a; } void playerturn(tanktype tank, int turn, color t) { int x = tank[turn].pos.x; int y = tank[turn].pos.y; window1.SetPen(t); window1.SetBrush(t); window1.DrawRectangle(x - 3, y - 50, x + 3, y - 35, FILLED); window1.DrawTriangle(x - 8, y - 38, x + 8, y - 38, x, y - 25, FILLED); } char pathoption() { char a; cout << "If You Want The Entire Path of The Projectile to Be Shown, Select 'Y'" << endl; cout << "If You Just Want To See The Projectile and Not Its Path, Select 'N'" << endl; cout << "Your Choice (Y/N): "; do { cin >> a; if (!((a == 'n') || (a == 'N') || (a == 'y') || (a == 'Y'))) cout << "Invalid Input: Try Again: "; } while (!((a == 'n') || (a == 'N') || (a == 'y') || (a == 'Y'))); if (a == 'n') a = 'N'; if (a == 'y') a = 'Y'; clrscr(); return a; } void defaultbuy(tanktype &player, list Weapon_info) { player[0].my_money = 10000; //DEFAULT VALUES player[1].my_money = 10000; //DEFAULT VALUES for(int w = 2; w < 10; ++w) //DEFAULT VALUES { player[0].weapon_array[0] = 999; //DEFAULT VALUES player[1].weapon_array[0] = 999; //DEFAULT VALUES player[0].weapon_array[1] = 7; //DEFAULT VALUES player[1].weapon_array[1] = 7; //DEFAULT VALUES player[0].weapon_array[5] = 7; //DEFAULT VALUES player[1].weapon_array[5] = 7; //DEFAULT VALUES player[0].weapon_array[w] = 0; //DEFAULT VALUES player[1].weapon_array[w] = 0; //DEFAULT VALUES } } void drawlifepoints(int lifepoints, int player) { if (player == 0) { window1.SetPen(BLACK, 3); window1.SetBrush(WHITE); window1.DrawRectangle(30, 30, 240, 50, FILLED); if (lifepoints >= 0) { window1.SetPen(RED, 0); window1.SetBrush(RED); window1.DrawRectangle(35, 35, 35 + lifepoints * 2, 45, FILLED); } } if (player == 1) { window1.SetPen(BLACK, 3); window1.SetBrush(WHITE); window1.DrawRectangle(770, 30, 560, 50, FILLED); if (lifepoints >= 0) { window1.SetPen(RED, 0); window1.SetBrush(RED); window1.DrawRectangle(765, 35, 765 - lifepoints * 2, 45, FILLED); } } //WaitNClear(window1); } void askplayer(int x, tanktype &tanknum, list Weapon_info) { int iX = 0, iY = 0; window2reset(); window2clrscr(); using namespace std; ostringstream output; ostringstream output2; window2.SetFont(25, BOLD | ITALICIZED, BY_NAME, "Arial"); window2.SetPen(BLACK); window2.SetBrush(BLACK); output << "Player " << x; output2 << "Would You Like To Buy?"; window2.DrawString(5, 20, output.str()); window2.DrawString(15, 50, output2.str()); window2.SetFont(25, BOLD | ITALICIZED, BY_NAME, "Arial"); window2.SetPen(BLACK, 3); window2.SetBrush(RED); window2.DrawRectangle(20,100,50,130, FILLED); window2setnum(20, 100, 30, 1); window2.DrawString(55,100, "Yes"); window2.DrawRectangle(170,100,200,130, FILLED); window2setnum(170,100, 30, 2); window2.DrawString(205,100, "No"); window2.DrawString(15,150, "Click A Box"); window3.SetBuffering(true); window2.FlushMouseQueue(); iY = 0; iX = 0; while((window2.GetMouseClick(iX, iY) == NO_CLICK)) { window2.GetMouseCoord(iX, iY); cout << w2[iY][iX]; window3.UpdateBuffer(); } window3.SetBuffering(false); if (w2[iY][iX] == 0) askplayer(x, tanknum, Weapon_info); else if (w2[iY][iX] == 1) weapon_menu(tanknum, Weapon_info, x); } void weapon_menu(tanktype &player, list Weapon_info, int buyer_int) { using namespace std; ostringstream output; int iX, iY; int weapon_int; window2clrscr(); window2reset(); window2.SetFont(25, BOLD | ITALICIZED, BY_NAME, "Arial"); output << "Player " << buyer_int << " Has $" << player[buyer_int - 1].my_money; window2.SetPen(BLACK, 3); window2.SetBrush(BLACK); window2.DrawString(5, 10, output.str()); window2.SetFont(20, BOLD | ITALICIZED, BY_NAME, "Arial"); window2.DrawString(30, 55 , "~WEAPON~ ~PRICE~"); window2.DrawString(30, 81, " Cannon"); window2.DrawString(160,81, "GIVEN INFINITE"); window2setnum(5, 104, 20, 2); window2.DrawRectangle(5, 104, 25, 124, FILLED); window2.DrawString(30, 104, " Buster Cannon"); window2.DrawString(200,104, "$150"); window2setnum(5, 127, 20, 3); window2.DrawRectangle(5, 127, 25, 147, FILLED); window2.DrawString(30, 127, " Super Cannon"); window2.DrawString(200,127, "$200"); window2setnum(5, 150, 20, 4); window2.DrawRectangle(5, 150, 25, 170, FILLED); window2.DrawString(30, 150, " Missile"); window2.DrawString(200,150, "$250"); window2setnum(5, 173, 20, 5); window2.DrawRectangle(5, 173, 25, 193, FILLED); window2.DrawString(30, 173, " Mega Missile"); window2.DrawString(200,173, "$300"); window2setnum(5, 196, 20, 6); window2.DrawRectangle(5, 196, 25, 216, FILLED); window2.DrawString(30, 196, " Gas Bomb"); window2.DrawString(200,196, "$350"); window2setnum(5, 219, 20, 7); window2.DrawRectangle(5, 219, 25, 239, FILLED); window2.DrawString(30, 219, " Shock Bomb"); window2.DrawString(200,219, "$500"); window2setnum(5, 242, 20, 8); window2.DrawRectangle(5, 242, 25, 262, FILLED); window2.DrawString(30, 242, " Scary Bomb"); window2.DrawString(200,242, "$700"); window2setnum(5, 265, 20, 9); window2.DrawRectangle(5, 265, 25, 285, FILLED); window2.DrawString(30, 265, " Nuke"); window2.DrawString(200,265, "$800"); window2setnum(5, 288, 20, 10); window2.DrawRectangle(5, 288, 25, 308, FILLED); window2.DrawString(30, 288, " A-bomb"); window2.DrawString(200,288, "$1000"); window2.DrawString(5, 318, "Click on The Box of the"); window2.DrawString(10, 341, "Weapon You Want To Buy"); window3.SetBuffering(true); window2.FlushMouseQueue(); iY = 0; iX = 0; while((window2.GetMouseClick(iX, iY) == NO_CLICK)) { window2.GetMouseCoord(iX, iY); //cout << w2[iY][iX]; window3.UpdateBuffer(); } window3.SetBuffering(false); if (w2[iY][iX] == 0) weapon_menu(player, Weapon_info, buyer_int); else { weapon_int = w2[iY][iX] - 1; window2clrscr(); weapon_menu2(player, Weapon_info, buyer_int, weapon_int); } } void weapon_menu2(tanktype &player, list Weapon_info, int buyer_int, int weapon_int) { int n; window2reset(); using namespace std; ostringstream output; int iX, iY; int quantity_int, total = 0, x = 0, y = 0, amount = 0; window2.SetFont(18, BOLD | ITALICIZED, BY_NAME, "Arial"); window2.SetPen(BLACK); window2.SetBrush(BLACK); window2.DrawString(5,10, "Weapon name: "); switch (weapon_int) { case 0: output << "Cannon"; break; case 1: output << "Buster Cannon"; break; case 2: output << "Super Cannon"; break; case 3: output << "Missile"; break; case 4: output << "Mega Missile"; break; case 5: output << "Gas Bomb"; break; case 6: output << "Shock Bomb"; break; case 7: output << "Scary Bomb"; break; case 8: output << "Nuke"; break; case 9: output << "A-Bomb"; } window2.DrawString(172,10, output.str()); ostringstream output1; window2.DrawString(5,30, "Ammo Per Purchase:"); output1 << Weapon_info[weapon_int].Ammo_per_purchase; window2.DrawString(172,30, output1.str()); ostringstream output2; window2.DrawString(5,50, "Weapon Price:"); output2 << "$" << Weapon_info[weapon_int].Weapon_price; window2.DrawString(172,50, output2.str()); ostringstream output3; window2.DrawString(5,70, "Weapon Power:"); output3 << Weapon_info[weapon_int].Weapon_damage; window2.DrawString(172,70, output3.str()); n = 18; window2.DrawString(5,100, "How Many Purchases?"); window2setnum(28, 130, n, 1); window2.DrawRectangle(28, 130, 28 + n, 130 + n, FILLED); window2.DrawString(50,130, "0"); window2setnum(28, 150, n, 2); window2.DrawRectangle(28, 150, 28 + n, 150 + n, FILLED); window2.DrawString(50,150, "1"); window2setnum(28, 170, n, 3); window2.DrawRectangle(28, 170, 28 + n, 170 + n, FILLED); window2.DrawString(50,170, "2"); window2setnum(28, 190, n, 4); window2.DrawRectangle(28, 190, 28 + n, 190 + n, FILLED); window2.DrawString(50,190, "3"); window2setnum(28, 210, n, 5); window2.DrawRectangle(28, 210, 28 + n, 210 + n, FILLED); window2.DrawString(50,210, "4"); window2setnum(28, 230, n, 6); window2.DrawRectangle(28, 230, 28 + n, 230 + n, FILLED); window2.DrawString(50,230, "5"); window2setnum(28, 250, n, 7); window2.DrawRectangle(28, 250, 28 + n, 250 + n, FILLED); window2.DrawString(50,250, "6"); window2setnum(28, 270, n, 8); window2.DrawRectangle(28, 270, 28 + n, 270 + n, FILLED); window2.DrawString(50,270, "7"); window2setnum(128, 130, n, 9); window2.DrawRectangle(128, 130, 128 + n, 130 + n, FILLED); window2.DrawString(150,130, "8"); window2setnum(128, 150, n, 10); window2.DrawRectangle(128, 150, 128 + n, 150 + n, FILLED); window2.DrawString(150,150, "9"); window2setnum(128, 170, n, 11); window2.DrawRectangle(128, 170, 128 + n, 170 + n, FILLED); window2.DrawString(150,170, "10"); window2setnum(128, 190, n, 12); window2.DrawRectangle(128, 190, 128 + n, 190 + n, FILLED); window2.DrawString(150,190, "11"); window2setnum(128, 210, n, 13); window2.DrawRectangle(128, 210, 128 + n, 210 + n, FILLED); window2.DrawString(150,210, "12"); window2setnum(128, 230, n, 14); window2.DrawRectangle(128, 230, 128 + n, 230 + n, FILLED); window2.DrawString(150,230, "13"); window2setnum(128, 250, n, 15); window2.DrawRectangle(128, 250, 128 + n, 250 + n, FILLED); window2.DrawString(150,250, "14"); window2setnum(128, 270, n, 16); window2.DrawRectangle(128, 270, 128 + n, 270 + n, FILLED); window2.DrawString(150,270, "15"); window2setnum(228, 130, n, 17); window2.DrawRectangle(228, 130, 228 + n, 130 + n, FILLED); window2.DrawString(250,130, "16"); window2setnum(228, 150, n, 18); window2.DrawRectangle(228, 150, 228 + n, 150 + n, FILLED); window2.DrawString(250,150, "17"); window2setnum(228, 170, n, 19); window2.DrawRectangle(228, 170, 228 + n, 170 + n, FILLED); window2.DrawString(250,170, "18"); window2setnum(228, 190, n, 20); window2.DrawRectangle(228, 190, 228 + n, 190 + n, FILLED); window2.DrawString(250,190, "19"); window2setnum(228, 210, n, 21); window2.DrawRectangle(228, 210, 228 + n, 210 + n, FILLED); window2.DrawString(250,210, "20"); window2setnum(228, 230, n, 22); window2.DrawRectangle(228, 230, 228 + n, 230 + n, FILLED); window2.DrawString(250,230, "21"); window2setnum(228, 250, n, 23); window2.DrawRectangle(228, 250, 228 + n, 250 + n, FILLED); window2.DrawString(250,250, "22"); window2setnum(228, 270, n, 24); window2.DrawRectangle(228, 270, 228 + n, 270 + n, FILLED); window2.DrawString(250,270, "23"); window2.SetFont(18, BOLD | ITALICIZED, BY_NAME, "Arial"); window2.SetPen(BLACK); window2.SetBrush(BLACK); ostringstream output10; output10 << "Player " << buyer_int << " Has $" << player[buyer_int - 1].my_money; window2.DrawString(10,320, output10.str()); window3.SetBuffering(true); window2.FlushMouseQueue(); iY = 0; iX = 0; while((window2.GetMouseClick(iX, iY) == NO_CLICK)) { window2.GetMouseCoord(iX, iY); cout << w2[iY][iX]; window3.UpdateBuffer(); } window3.SetBuffering(false); if (w2[iY][iX] == 0) weapon_menu2(player, Weapon_info, buyer_int, weapon_int); else { quantity_int = w2[iY][iX] - 1; amount = 10 * amount + quantity_int; total = amount * Weapon_info[weapon_int].Weapon_price; if (total > player[buyer_int - 1].my_money) { window2.SetFont(18, BOLD | ITALICIZED, BY_NAME, "Arial"); window2.SetPen(BLACK); window2.SetBrush(BLACK); ostringstream output8; window2.DrawString(10,350, "You do not have enough money."); output8 << "You have $" << player[buyer_int-1].my_money; window2.DrawString(20,380, output8.str()); window2.DrawString(10,410, "Please Try Again."); amount = 0; // Resets calculation total = 0; weapon_menu2(player, Weapon_info, buyer_int, weapon_int); } else { window2clrscr(); window2.SetFont(18, BOLD | ITALICIZED, BY_NAME, "Arial"); window2.SetPen(BLACK); window2.SetBrush(BLACK); ostringstream output11, output12; window2.SetFont(18, BOLD | ITALICIZED, BY_NAME, "Arial"); window2.SetPen(BLACK); window2.SetBrush(BLACK); output11 << "You Have Purchased " << Weapon_info[weapon_int].Ammo_per_purchase * amount << " Ammo"; output12 << "For $" << total; window2.DrawString(15,25, output12.str()); window2.DrawString(5,5, output11.str()); player[buyer_int - 1].my_money = player[buyer_int - 1].my_money - total; player[buyer_int - 1].weapon_array[weapon_int] = player[buyer_int - 1].weapon_array[weapon_int] + (amount * Weapon_info[weapon_int].Ammo_per_purchase); } // end of if-else statement int f = 10; int g = 175; ; ostringstream output16; ostringstream output13; ostringstream output14; ostringstream output15; ostringstream output17; ostringstream output18; ostringstream output19; ostringstream output20; ostringstream output21; ostringstream output22; ostringstream output23; output13 << "You Currently Have: $" << player[buyer_int - 1].my_money; window2.DrawString(5,45, output13.str()); window2.DrawString(f,70, "NAME"); window2.DrawString(g-21,70, "QUANTITY"); window2.DrawString(f,270, "A-bomb"); output14 << player[buyer_int - 1].weapon_array[9]; window2.DrawString(g,270, output14.str()); window2.DrawString(f,90, "Cannon"); output15 << player[buyer_int - 1].weapon_array[0]; window2.DrawString(g,90, output15.str()); window2.DrawString(f,110, "Buster Cannon"); output16 << player[buyer_int - 1].weapon_array[1]; window2.DrawString(g,110, output16.str()); window2.DrawString(f,130, "Super Cannon"); output17 << player[buyer_int - 1].weapon_array[2]; window2.DrawString(g,130, output17.str()); window2.DrawString(f,150, "Missiles"); output18 << player[buyer_int - 1].weapon_array[3]; window2.DrawString(g,150, output18.str()); window2.DrawString(f,170, "Mega Missiles"); output19 << player[buyer_int - 1].weapon_array[4]; window2.DrawString(g,170, output19.str()); window2.DrawString(f,190, "Gas Bomb"); output20 << player[buyer_int - 1].weapon_array[5]; window2.DrawString(g,190, output20.str()); window2.DrawString(f,210, "Shock Bomb"); output21 << player[buyer_int - 1].weapon_array[6]; window2.DrawString(g,210, output21.str()); window2.DrawString(f,230, "Scary Bomb"); output22 << player[buyer_int - 1].weapon_array[7]; window2.DrawString(g,230, output22.str()); window2.DrawString(f,250, "Nuke"); output23 << player[buyer_int - 1].weapon_array[8]; window2.DrawString(g,250, output23.str()); weapon_menu3(player, Weapon_info, buyer_int); } } void weapon_menu3(tanktype &player, list Weapon_info, int buyer_int) { int iX, iY; window2reset(); window2.DrawString(10, 300, "Would You Like To Purchase"); window2.DrawString(20, 320, "Another Weapon..(Y or N) "); window2.SetFont(25, BOLD | ITALICIZED, BY_NAME, "Arial"); window2.SetPen(BLACK, 3); window2.SetBrush(RED); window2.DrawRectangle(20,360,50,390, FILLED); window2setnum(20, 360, 30, 1); window2.DrawString(55,360, "Yes"); window2.DrawRectangle(170,360,200,390, FILLED); window2setnum(170,360, 30, 2); window2.DrawString(205,360, "No"); window3.SetBuffering(true); window2.FlushMouseQueue(); iY = 0; iX = 0; while((window2.GetMouseClick(iX, iY) == NO_CLICK)) { window2.GetMouseCoord(iX, iY); cout << w2[iY][iX]; window3.UpdateBuffer(); } window3.SetBuffering(false); if (w2[iY][iX] == 0) weapon_menu3(player, Weapon_info, buyer_int); else if (w2[iY][iX] == 1) weapon_menu(player, Weapon_info, buyer_int); } void createwind(windstruct &wind) { int temp; time_t seconds; time(&seconds); srand((unsigned int) seconds); temp = rand() % 2; if (temp == 1) wind.direction = 'W'; if (temp == 0) wind.direction = 'E'; wind.speed = rand() % 25 + 1; } void terrainselect(map matrix1, color &outside) { char a; int temp; cout << "Terrain Selection" << endl << endl; cout << " 1: Desert" << endl; cout << " 2: Forest" << endl; cout << " 3: Mountains" << endl; cout << " 4: Evacuated City" << endl; cout << " 5: Arctic" << endl; cout << "Your Choice: "; do { cin >> a; temp = a - 48; if ((temp > 5) || (temp < 1)) cout << "Invalid Input: Try Again: "; } while((temp > 5) || (temp < 1)); switch (temp) { case 1: desert(matrix1, outside); break; case 2: forest(matrix1, outside); break; case 3: mountains(matrix1, outside); break; case 4: evacuated_city(matrix1, outside); break; case 5: arctic(matrix1, outside); } } void tankdefinition(int &win, int p, int &player, int &money, int &lifepoints, color &c, color t) { win = 0; player = p; money = 200; lifepoints = 100; c = t; } void weapondefinition(list Weapon_info) { Weapon_info[0].Weapon_name = "Cannon"; Weapon_info[0].Ammo_per_purchase = 999; // add one each time when a player uses it Weapon_info[0].Weapon_price = 0; Weapon_info[0].Weapon_damage = 5; Weapon_info[0].Weapon_radius = 10; Weapon_info[1].Weapon_name = "Buster Cannon"; Weapon_info[1].Ammo_per_purchase = 50; Weapon_info[1].Weapon_price = 150; Weapon_info[1].Weapon_damage = 7; Weapon_info[1].Weapon_radius = 15; Weapon_info[2].Weapon_name = "Mega Cannon"; Weapon_info[2].Ammo_per_purchase = 10; Weapon_info[2].Weapon_price = 200; Weapon_info[2].Weapon_damage = 9; Weapon_info[2].Weapon_radius = 20; Weapon_info[3].Weapon_name = "Missiles"; Weapon_info[3].Ammo_per_purchase = 10; Weapon_info[3].Weapon_price = 250; Weapon_info[3].Weapon_damage = 11; Weapon_info[3].Weapon_radius = 25; Weapon_info[4].Weapon_name = "Mega Missiles"; Weapon_info[4].Ammo_per_purchase = 5; Weapon_info[4].Weapon_price = 300; Weapon_info[4].Weapon_damage = 15; Weapon_info[4].Weapon_radius = 30; Weapon_info[5].Weapon_name = "Gas Bomb"; Weapon_info[5].Ammo_per_purchase = 3; Weapon_info[5].Weapon_price = 400; Weapon_info[5].Weapon_damage = 10; Weapon_info[5].Weapon_radius = 50; Weapon_info[6].Weapon_name = "Shock Bomb"; Weapon_info[6].Ammo_per_purchase = 2; Weapon_info[6].Weapon_price = 500; Weapon_info[6].Weapon_damage = 15; Weapon_info[6].Weapon_radius = 30; Weapon_info[7].Weapon_name = "Scary Bomb"; Weapon_info[7].Ammo_per_purchase = 1; Weapon_info[7].Weapon_price = 700; Weapon_info[7].Weapon_damage = 25; Weapon_info[7].Weapon_radius = 40; Weapon_info[8].Weapon_name = "Nuke"; Weapon_info[8].Ammo_per_purchase = 1; Weapon_info[8].Weapon_price = 800; Weapon_info[8].Weapon_damage = 35; Weapon_info[8].Weapon_radius = 50; Weapon_info[9].Weapon_name = "A-bomb"; Weapon_info[9].Ammo_per_purchase = 1; Weapon_info[9].Weapon_price = 1000; Weapon_info[9].Weapon_damage = 50; Weapon_info[9].Weapon_radius = 100; } void tankplacement(map matrix1, tankposition &tank1, tankposition &tank2) { time_t seconds; time(&seconds); srand((unsigned int) seconds); tank1.x = rand() % 150 + 1 + 10; tank2.x = rand() % 150 + 1 + 640; for (int x = 599; x > 0; x--) if (matrix1[x][tank1.x] == 0) { tank1.y = x; break; }; for (int i = 599; i > 0; i--) if (matrix1[i][tank2.x] == 0) { tank2.y = i; break; } matrix1[tank1.y][tank1.x] = 1; for (int o = 0; o < 13; o++) matrix1[tank1.y - o][tank1.x] = TRUE; matrix1[tank2.y][tank2.x] = 1; for (o = 0; o < 13; o++) matrix1[tank2.y - o][tank2.x] = TRUE; } void drawtank(tankposition pos, color t, int turn) { window1.SetPen(t, 0); window1.SetBrush(t); window1.DrawTriangle(pos.x-15, pos.y, pos.x+15, pos.y, pos.x, pos.y-20, FILLED); window1.SetPen(t, 5); if (turn == 0) window1.DrawLine(pos.x+1, pos.y-6, pos.x+10, pos.y-18); else window1.DrawLine(pos.x-1, pos.y-6, pos.x-10, pos.y-18); //WaitNClear(window1); } void projectile(map matrix1, weapon choice, char want, int turn, tanktype &tank, anglestruct angle, double velocity, color sky, windstruct wind) { double x = 0.25; bool out; bool hit; int position = tank[turn].pos.x; double newvelocity; double newangle; double graphicsy; double vel; double win; double ang; int temp = angle.degrees; tankposition hitpos; tankposition previouspos; tankposition currentpos; apvector firepositions; int i = 0; if (temp > 180) angle.degrees = 360 - angle.degrees; vel = double(velocity); win = double(wind.speed); ang = double(angle.degrees); if (wind.direction == 'E') { newvelocity = vel * vel + win * win - 2 * win * vel * cos(((180 - ang) / 180) * PI); newvelocity = sqrt(newvelocity); newangle = (sin(((180 - ang) / 180) * PI) * win) / newvelocity; newangle = asin(newangle); newangle = ang - ((newangle * 180) / PI); } if (wind.direction == 'W') { newvelocity = vel * vel + win * win - 2 * win * vel * cos(((ang) / 180) * PI); newvelocity = sqrt(newvelocity); newangle = (sin(((ang) / 180) * PI) * win) / newvelocity; newangle = asin(newangle); newangle = ang + ((newangle * 180) / PI); } if (temp > 180) newangle = 360 - newangle; //cout << "angle " << newangle << endl; //cout << "velocity " << newvelocity << endl; out = FALSE; hit = FALSE; while ((hit == FALSE) && (out == FALSE)) { if (want == 'N') { window1.SetPen(sky, 0); window1.SetBrush(sky); window1.DrawCircle(previouspos.x, previouspos.y, 4, FILLED); } if (want == 'Y') { i++; firepositions.resize(i); firepositions[i - 1] = previouspos; } graphicsy = -16 * x * x + newvelocity * sin((newangle / 180) * PI) * x + double(tank[turn].pos.y); currentpos.y = int(tank[turn].pos.y - (graphicsy - tank[turn].pos.y)); currentpos.x = int(x * newvelocity * cos((newangle / 180) * PI) + tank[turn].pos.x); window1.SetPen(tank[turn].c, 0); window1.SetBrush(tank[turn].c); window1.DrawCircle(currentpos.x, currentpos.y, 4, FILLED); if ((currentpos.x > 800) || (currentpos.x < 0)) out = TRUE; if ((currentpos.y <600) && (currentpos.y > 0) && (currentpos.x < 800) && (currentpos.x > 0)) { if (matrix1[currentpos.y][currentpos.x] == TRUE) { hit = TRUE; hitpos.x = currentpos.x; hitpos.y = currentpos.y; } Sleep(8); } previouspos.x = currentpos.x; previouspos.y = currentpos.y; //cout << "Matrix " << "(" << currentpos.x << "," << currentpos.y << ")" << endl; x = x + 0.025; } if (((hit == TRUE) || (out == TRUE)) && (want == 'Y')) if (want == 'Y') { for (int t = 0; t < firepositions.length(); t++) { window1.SetPen(sky, 0); window1.SetBrush(sky); window1.DrawCircle(firepositions[t].x, firepositions[t].y, 4, FILLED); } } if (hit == TRUE) blast(matrix1, choice.Weapon_damage, currentpos, tank, choice.Weapon_radius, sky); } void fire(map matrix1, char want, int turn, tanktype &tank, color sky, windstruct wind, list weaponsall) { double opposite, adjacent; selectiontype link; int iX, iY; apstring a; weapon use; int choice; anglestruct angle; double velocity; using namespace std; ostringstream output; clrscr(); window2.SetFont(24, BOLD | ITALICIZED, BY_NAME, "Arial"); window2.SetPen(BLACK); window2.SetBrush(BLACK); playerturn(tank, turn, WHITE); tank[turn].weapon_array[0] = 999; output << "Player " << tank[turn].player; window2.DrawString(5, 5, output.str()); window2.SetFont(20, BOLD | ITALICIZED, BY_NAME, "Arial"); ostringstream output1; output1 << " Please Select Your Weapon"; window2.DrawString(5, 31, output1.str()); ostringstream output2; output2 << " Click On A Box Below"; window2.DrawString(5, 53, output2.str()); choice = weaponlistdis(link, tank[turn]); window2clrscr(); /*do { cin >> a; choice = a[0] - 48; if ((choice < 1) || (choice > max)) cout << " Invalid Input: Try Again: "; } while ((choice < 1) || (choice > max)); sum = 0;*/ use = weaponsall[link[choice]]; tank[turn].weapon_array[link[choice]]--; window2.SetBuffering(true); window1.FlushMouseQueue(); while(window1.GetMouseClick(iX, iY) == NO_CLICK) { window2clrscr(); window1.GetMouseCoord(iX, iY); //window1.GetMouseClick(iX, iY); //window1.WaitMouseClick(iX, iY); adjacent = double(abs(double(iX) - double(tank[turn].pos.x))); opposite = double(abs(double(iY) - double(tank[turn].pos.y))); if (iX > tank[turn].pos.x) if (iY < tank[turn].pos.y) angle.degrees = atan(opposite/adjacent); else if (iY > tank[turn].pos.y) angle.degrees = 2 * PI - atan(opposite/adjacent); else if (iY == tank[turn].pos.y) angle.degrees = 0; if (iX < tank[turn].pos.x) if (iY < tank[turn].pos.y) angle.degrees = PI - atan(opposite/adjacent); else if (iY > tank[turn].pos.y) angle.degrees = PI + atan(opposite/adjacent); else if (iY == tank[turn].pos.y) angle.degrees = PI; if (iX == tank[turn].pos.x) if (iY < tank[turn].pos.y) angle.degrees = PI / 2; else if (iY > tank[turn].pos.y) angle.degrees = 1.5 * PI; else if (iY == tank[turn].pos.y) angle.degrees = 0; angle.degrees = ((angle.degrees * 180) / PI); velocity = sqrt(opposite * opposite + adjacent * adjacent); drawanglevelocity(angle.degrees, velocity, BLACK); window2.UpdateBuffer(); } window2.SetBuffering(false); /*cout << angle.degrees << " " << velocity << endl; cout << "tankpos " << tank[turn].pos.x << " : " << tank[turn].pos.y << endl; cout << "clicpos " << iX << " : " << iY << endl; cout << "opposite " << opposite << endl; cout << "ajdacent " << adjacent; //cin >> m; cout << " Player " << tank[turn].player << " Angle Must Be Greater Than or Equal to 0 and Less Than 360"; cout << " Please Enter Your Angle of Trajectory: "; do { sum = 0; cin >> a; pass = TRUE; for (int x = 0; x < a.length(); x++) if ((a[x] > '9') || (a[x] < '0')) pass = FALSE; if (pass) for (x = 0; x < a.length(); x++) sum = sum * 10 + (a[x] - 48); if ((sum < 0) || (sum > 359)) pass = FALSE; if (pass == FALSE) cout << " Invalid Input. Try Again: "; } while (pass == FALSE); angle.degrees = sum; sum = 0; cout << " Player " << tank[turn].player << " Velocity Must Be Greater Than or Equal to 0"; cout << " Please Enter Your Velocity: "; do { sum = 0; cin >> a; pass = TRUE; for (int x = 0; x < a.length(); x++) if ((a[x] > '9') || (a[x] < '0')) pass = FALSE; if (pass) for (x = 0; x < a.length(); x++) sum = sum * 10 + (a[x] - 48); if (sum < 0) pass = FALSE; if (pass == FALSE) cout << " Invalid Input: Try Again: "; } while (pass == FALSE); velocity = sum; sum = 0;*/ //clrscr(); window2clrscr(); playerturn(tank, turn, sky); projectile(matrix1, use, want, turn, tank, angle, velocity, sky, wind); } int weaponlistdis(selectiontype &link, tank tank1) { int loc = 53; int i = 0; using namespace std; int iX, iY; int choice; window2reset(); window2.SetPen(BLACK, 3); window2.SetBrush(RED); window2.SetFont(20, BOLD | ITALICIZED, BY_NAME, "Arial"); for (int x = 0; x < 10; x++) if (tank1.weapon_array[x] > 0) { loc = loc + 22; ostringstream output; ostringstream output2; i++; switch (x) { case 0: output << "Cannon"; break; case 1: output << "Buster Cannon"; break; case 2: output << "Super Cannon"; break; case 3: output << "Missile"; break; case 4: output << "Mega Missile"; break; case 5: output << "Gas Bomb"; break; case 6: output << "Shock Bomb"; break; case 7: output << "Scary Bomb"; break; case 8: output << "Nuke"; break; case 9: output << "A-Bomb"; } window2.DrawRectangle(25, loc + 3, 50, loc + 28, FILLED); window2setnum(25, loc + 3, 25, i); window2.DrawString(60, loc, output.str()); output2 << " You Have: " << tank1.weapon_array[x] << " Ammos"; loc = loc + 22; window2.DrawString(60, loc, output2.str()); link[i] = x; } window3.SetBuffering(true); window2.FlushMouseQueue(); iY = 0; iX = 0; while((window2.GetMouseClick(iX, iY) == NO_CLICK)) { window2.GetMouseCoord(iX, iY); //cout << w2[iY][iX]; window3.UpdateBuffer(); } window3.SetBuffering(false); if (w2[iY][iX] == 0) choice = weaponlistdis(link, tank1); else choice = w2[iY][iX]; return choice; } void drawanglevelocity(double angledegrees, double velocity, color t) { using namespace std; ostringstream output; ostringstream output1; output << "Angle: " << (angledegrees); window2.SetPen(t); window2.SetFont(25, BOLD | ITALICIZED , BY_NAME, "Arial"); window2.DrawString(5,40, "Click Mouse On Desired"); window2.DrawString(10,80, "Angle & Velocity"); window2.SetFont(30, BOLD | ITALICIZED , BY_NAME, "Arial"); window2.DrawString(35, 200, output.str()); output1 << "Velocity: " << (velocity); window2.SetPen(t); window2.SetFont(30, BOLD | ITALICIZED , BY_NAME, "Arial"); window2.DrawString(35, 240, output1.str()); } void blast(map matrix1, int damage, tankposition pos, tanktype &tank, int radius, color sky) { int hittank = -1; for (int o = 1; o <= radius; o++) { if (o % 3 == 0) { window1.SetPen(YELLOW, 0); window1.SetBrush(YELLOW); } else if (o % 3 == 1) { window1.SetPen(ORANGE, 0); window1.SetBrush(ORANGE); } else { window1.SetPen(RED, 0); window1.SetBrush(RED); } window1.DrawCircle(pos.x, pos.y, o, FILLED); Sleep(20); } window1.SetPen(sky, 0); window1.SetBrush(sky); window1.DrawCircle(pos.x, pos.y, radius, FILLED); for (int x = 0; x < radius; x++) for (int y = 0; y < radius; y++) if (x * x + y * y <= radius * radius) { if (pos.y + x <= 600) { matrix1[pos.y + x][pos.x + y] = FALSE; matrix1[pos.y + x][pos.x - y] = FALSE; } if (pos.y - x <= 600) { matrix1[pos.y - x][pos.x + y] = FALSE; matrix1[pos.y - x][pos.x - y] = FALSE; } for (int i = 0; i < 2; i++) { if (((tank[i].pos.x == pos.x + y) && (tank[i].pos.y == pos.y + x)) || ((tank[i].pos.x == pos.x - y) && (tank[i].pos.y == pos.y + x)) || ((tank[i].pos.x == pos.x + y) && (tank[i].pos.y == pos.y - x)) || ((tank[i].pos.x == pos.x - y) && (tank[i].pos.y == pos.y - x))) { hittank = i; tank[i].lifepoints = tank[i].lifepoints - damage; } } } if (hittank != -1) { drawtank(tank[hittank].pos, sky, hittank); tankreplace(matrix1, tank[hittank].pos, radius); drawtank(tank[hittank].pos, tank[hittank].c, hittank); } } void tankreplace(map matrix1, tankposition &tank, int radius) { int p = 0; for (int x = 599; x > tank.y - 1; x--) { if (matrix1[x][tank.x] == 0) { tank.y = x; p = 1; break; } } if (p == 0) tank.y = 599; matrix1[x][tank.x] = TRUE; for (int o = 0; o < 13; o++) matrix1[x - o][tank.x] = TRUE; //cout << "x at " << tank.x << " and y at " << tank.y << endl; } void WaitNClear(window &inputWindow) { int iX, iY; inputWindow.SetPen(BLACK); inputWindow.SetFont(16, BOLD, SWISS); inputWindow.DrawString(inputWindow.GetWidth()/2 - 100, inputWindow.GetHeight() - 25, "Click mouse to continue..."); // Flush the mouse queue inputWindow.FlushMouseQueue(); // Ignore return value since we don't care what type of click it was inputWindow.WaitMouseClick(iX, iY); // Set the brush and pen white so we can clear the background inputWindow.SetPen(WHITE, 0); inputWindow.SetBrush(WHITE); // Draw a rectangle that covers the entire window inputWindow.DrawRectangle(0, 0, inputWindow.GetWidth(), inputWindow.GetHeight()); }