void main () { HANDLE hOut; COORD NewSBSize; SMALL_RECT DisplayArea = {0, 0, 0, 0}; hOut = GetStdHandle(STD_OUTPUT_HANDLE); NewSBSize = GetLargestConsoleWindowSize(hOut); SetConsoleScreenBufferSize(hOut, NewSBSize); DisplayArea.Right = NewSBSize.X - 1; DisplayArea.Bottom = NewSBSize.Y - 1; SetConsoleWindowInfo(hOut, TRUE, &DisplayArea); HANDLE hConsole; int k; hConsole = GetStdHandle(STD_OUTPUT_HANDLE); for(k = 1; k < 2; k++) { SetConsoleTextAttribute(hConsole, 26); char keyPressed; bool quit = false; int dX; int dY; int dZ; do { system("cls"); cout <<endl; cout <<endl; for (int a = 0; a < 90; a++) cout << box; cout << endl; cout <<box <<" " << box << endl; cout <<box <<" " << box << endl; cout <<box <<" xxx__xxx_xx_xx____xx_xxxxx__xxxx__xx_______xx_xxxxx_xxxxx_xxxxx___xxxxx_xxxxxx_ " << box <<endl; cout <<box <<" xxx__xxx_xx_xxx___xx_xxxxx_xxxxxx_xx_______xx_xxxxx_xxxxx_xxxxxx__xxxxx_xxxxxxx "<< box <<endl; cout <<box <<" xxx__xxx_xx_xxx___xx_xx____xxx_xx_xx_______xx_xx____xx____xx___xx_xx____xx___xx "<< box <<endl; cout <<box <<" xx_xx_xx_xx_xxxx__xx_xx____xx______xx_____xx__xx____xx____xx___xx_xx____xx___xx "<< box <<endl; cout <<box <<" xx_xx_xx_xx_xx_xx_xx_xxxxx__xx_____xx__x__xx__xxxxx_xxxxx_xxxxxx__xxxxx_xxxxxx_ "<< box <<endl; cout <<box <<" xx____xx_xx_xx__xxxx_xxxxx___xx____xx__x__xx__xxxxx_xxxxx_xxx_____xxxxx_xxxx___ "<< box <<endl; cout <<box <<" xx____xx_xx_xx__xxxx_xx_______xx___xx_xxx_xx__xx____xx____xx______xx____xx_xx__ "<< box <<endl; cout <<box <<" xx____xx_xx_xx___xxx_xx____xx_xxx___xxx_xxx___xx____xx____xx______xx____xx__xx_ "<< box <<endl; cout <<box <<" xx____xx_xx_xx____xx_xxxxx_xxxxxx___xx___xx___xxxxx_xxxxx_xx______xxxxx_xx__xx_ "<< box <<endl; cout <<box <<" xx____xx_xx_xx____xx_xxxxx__xxxx____xx___xx___xxxxx_xxxxx_xx______xxxxx_xx__xx_ "<< box <<endl; cout <<box <<" " << box << endl; cout <<box <<" " << box << endl; for (int b = 0; b < 90; b++) cout << box; cout << endl; cout << endl; cout << endl; system("pause"); for (int d = 0; d < 90; d++) cout << box; cout << endl; cout <<box <<" " << box << endl; cout <<box <<" " << box << endl; cout <<box <<"Use ESC button to quit MINESWEEPER anytime" << box << endl; cout <<box <<"The arrow buttons on keyboard will move your player" << box << endl; cout <<box <<"Buttons < and > will be used to go up & down levels" << box << endl; cout <<box <<"Buttons = or - will increse/decrease the size" << box << endl; cout <<box <<" " << box << endl; cout <<box <<" " << box << endl; for (int e = 0; e < 90; e++) cout << box; cout << endl; system("pause"); for (int f = 0; f < 90; f++) cout << box; cout << endl; cout <<box <<" " << box << endl; cout <<box <<"Enter the number of rows you would like to have" << box <<endl; cout <<box <<" " << box << endl; for (int g = 0; g < 90; g++) cout << box; cout << endl; cout << endl; cout << endl; cin >> dX; while (dX > maxROW) { cout << "Please re-enter the number of rows that is less than that" << endl; cin >> dX; } while (dX < minROW) { cout << " Please re-enter the number of rows that is greater than that" << endl; cin >> dX; } for (int h = 0; h < 90; h++) cout << box; cout << endl; cout <<box <<" " << box << endl; cout <<box <<"Enter the number of columns you would like to have" << box << endl; cout <<box <<" " << box << endl; for (int i = 0; i < 90; i++) cout << box; cout << endl; cout << endl; cout << endl; cin >> dY; while (dY > maxCOL) { cout << "Please re-enter the number of columns that is less than that" << endl; cin >> dY; } while (dY < minCOL) { cout << "Please re-enter the number of columns that is greater than that" << endl; cin >> dY; } for (int j = 0; j < 90; j++) cout << box; cout << endl; cout<<endl; cout <<box <<"Enter the depth you would like to have" << box << endl; cout <<box <<" " << box << endl; for (int k = 0; k < 90; k++) cout << box; cout << endl; cout << endl; cout << endl; cin >> dZ; while (dZ > maxDEPTH) { cout << "Please re-enter the depth you would like that is less than that" << endl; cin >> dZ; } while (dZ < minDEPTH) { cout << "Please re-enter the depth you would like that is greater than that" << endl; cin >> dZ; } GridActive myGridActive (dX, dY, dZ); do{ myGridActive.setActive(myGridActive.getX(), myGridActive.getY(), myGridActive.getZ()); myGridActive.print ( myGridActive.getZ() ); myGridActive.printDimensions(myGridActive.getRow(), myGridActive.getCol(), myGridActive.getDepth()); char key; bool flag = false; key = getch(); switch (toascii(key)) { case 'Q': case 'q': quit = true; break; case 80: if (flag) { myGridActive.goSouth(); flag = false; } else cout << "try again. " << endl; break; case 72: if (flag) { myGridActive.goNorth(); flag = false; } else cout << "try again. " << endl; break; case 77: if (flag) { myGridActive.goWest(); flag = false; } else cout << "try again. " << endl; break; case 75: if (flag) { myGridActive.goEast(); flag = false; } else cout << "try again. " << endl; break; case 73: if (flag) { myGridActive.upsize(); flag = false; } else cout << "try again. " << endl; break; case 81: if (flag) { myGridActive.downsize(); flag = false; } else cout << "try again. " << endl; break; } while (!quit); cout << "\n Would u like to start over? Press key \n Would u like to quit? Press N "; keyPressed = getch (); quit = false; if (( keyPressed == 'N' ) || (keyPressed == 'n' )) quit = true; cin.get(); printEnd(); } }
void main () { HANDLE hOut; COORD NewSBSize; SMALL_RECT DisplayArea = {0, 0, 0, 0}; hOut = GetStdHandle(STD_OUTPUT_HANDLE); NewSBSize = GetLargestConsoleWindowSize(hOut); SetConsoleScreenBufferSize(hOut, NewSBSize); DisplayArea.Right = NewSBSize.X - 1; DisplayArea.Bottom = NewSBSize.Y - 1; SetConsoleWindowInfo(hOut, TRUE, &DisplayArea); HANDLE hConsole; int k; hConsole = GetStdHandle(STD_OUTPUT_HANDLE); for(k = 1; k < 2; k++) { SetConsoleTextAttribute(hConsole, 26); char keyPressed; bool quit = false; int dX; int dY; int dZ; do { system("cls"); cout <<endl; cout <<endl; for (int a = 0; a < 90; a++) cout << box; cout << endl; cout <<box <<" " << box << endl; cout <<box <<" " << box << endl; cout <<box <<" xxx__xxx_xx_xx____xx_xxxxx__xxxx__xx_______xx_xxxxx_xxxxx_xxxxx___xxxxx_xxxxxx_ " << box <<endl; cout <<box <<" xxx__xxx_xx_xxx___xx_xxxxx_xxxxxx_xx_______xx_xxxxx_xxxxx_xxxxxx__xxxxx_xxxxxxx "<< box <<endl; cout <<box <<" xxx__xxx_xx_xxx___xx_xx____xxx_xx_xx_______xx_xx____xx____xx___xx_xx____xx___xx "<< box <<endl; cout <<box <<" xx_xx_xx_xx_xxxx__xx_xx____xx______xx_____xx__xx____xx____xx___xx_xx____xx___xx "<< box <<endl; cout <<box <<" xx_xx_xx_xx_xx_xx_xx_xxxxx__xx_____xx__x__xx__xxxxx_xxxxx_xxxxxx__xxxxx_xxxxxx_ "<< box <<endl; cout <<box <<" xx____xx_xx_xx__xxxx_xxxxx___xx____xx__x__xx__xxxxx_xxxxx_xxx_____xxxxx_xxxx___ "<< box <<endl; cout <<box <<" xx____xx_xx_xx__xxxx_xx_______xx___xx_xxx_xx__xx____xx____xx______xx____xx_xx__ "<< box <<endl; cout <<box <<" xx____xx_xx_xx___xxx_xx____xx_xxx___xxx_xxx___xx____xx____xx______xx____xx__xx_ "<< box <<endl; cout <<box <<" xx____xx_xx_xx____xx_xxxxx_xxxxxx___xx___xx___xxxxx_xxxxx_xx______xxxxx_xx__xx_ "<< box <<endl; cout <<box <<" xx____xx_xx_xx____xx_xxxxx__xxxx____xx___xx___xxxxx_xxxxx_xx______xxxxx_xx__xx_ "<< box <<endl; cout <<box <<" " << box << endl; cout <<box <<" " << box << endl; for (int b = 0; b < 90; b++) cout << box; cout << endl; cout << endl; cout << endl; system("pause"); for (int d = 0; d < 90; d++) cout << box; cout << endl; cout <<box <<" " << box << endl; cout <<box <<" " << box << endl; cout <<box <<"Use ESC button to quit MINESWEEPER anytime" << box << endl; cout <<box <<"The arrow buttons on keyboard will move your player" << box << endl; cout <<box <<"Buttons < and > will be used to go up & down levels" << box << endl; cout <<box <<"Buttons = or - will increse/decrease the size" << box << endl; cout <<box <<" " << box << endl; cout <<box <<" " << box << endl; for (int e = 0; e < 90; e++) cout << box; cout << endl; system("pause"); for (int f = 0; f < 90; f++) cout << box; cout << endl; cout <<box <<" " << box << endl; cout <<box <<"Enter the number of rows you would like to have" << box <<endl; cout <<box <<" " << box << endl; for (int g = 0; g < 90; g++) cout << box; cout << endl; cout << endl; cout << endl; cin >> dX; while (dX > maxROW) { cout << "Please re-enter the number of rows that is less than that" << endl; cin >> dX; } while (dX < minROW) { cout << " Please re-enter the number of rows that is greater than that" << endl; cin >> dX; } for (int h = 0; h < 90; h++) cout << box; cout << endl; cout <<box <<" " << box << endl; cout <<box <<"Enter the number of columns you would like to have" << box << endl; cout <<box <<" " << box << endl; for (int i = 0; i < 90; i++) cout << box; cout << endl; cout << endl; cout << endl; cin >> dY; while (dY > maxCOL) { cout << "Please re-enter the number of columns that is less than that" << endl; cin >> dY; } while (dY < minCOL) { cout << "Please re-enter the number of columns that is greater than that" << endl; cin >> dY; } for (int j = 0; j < 90; j++) cout << box; cout << endl; cout<<endl; cout <<box <<"Enter the depth you would like to have" << box << endl; cout <<box <<" " << box << endl; for (int k = 0; k < 90; k++) cout << box; cout << endl; cout << endl; cout << endl; cin >> dZ; while (dZ > maxDEPTH) { cout << "Please re-enter the depth you would like that is less than that" << endl; cin >> dZ; } while (dZ < minDEPTH) { cout << "Please re-enter the depth you would like that is greater than that" << endl; cin >> dZ; } GridActive myGridActive (dX, dY, dZ); do{ myGridActive.setActive(myGridActive.getX(), myGridActive.getY(), myGridActive.getZ()); myGridActive.print ( myGridActive.getZ() ); myGridActive.printDimensions(myGridActive.getRow(), myGridActive.getCol(), myGridActive.getDepth()); char key; bool flag = false; key = getch(); switch (toascii(key)) { case 'q': quit = true; break; case 80: if (flag) { myGridActive.goSouth(); flag = false; } else cout << "try again. " << endl; break; case 72: if (flag) { myGridActive.goNorth(); flag = false; } else cout << "try again. " << endl; break; case 77: if (flag) { myGridActive.goWest(); flag = false; } else cout << "try again. " << endl; break; case 75: if (flag) { myGridActive.goEast(); flag = false; } else cout << "try again. " << endl; break; case 73: if (flag) { myGridActive.upsize(); flag = false; } else cout << "try again. " << endl; break; case 81: if (flag) { myGridActive.downsize(); flag = false; } else cout << "try again. " << endl; break; } while (!quit); cout << "\n Would u like to start over? Press key \n Would u like to quit? Press N "; keyPressed = getch (); quit = false; if (( keyPressed == 'N' ) || (keyPressed == 'n' )) quit = true; cin.get(); printEnd(); } }
I fixed that now but I still have the un-expected file ending. Do you know why its doing this?
for ( i = 0 ; i < 10 ; i++ ) { }
for ( i = 0 ; i < 10 ; i++ ) { cout << "hello" << var << endl; }
| DaniWeb Message | |
| Cancel Changes | |