C++ Full Screen

This is a discussion on C++ Full Screen within the C++ Programming forums, part of the General Programming Boards category; Hey all, I'm just wondering, how do you make a Visual C++ program display in full screen, i have a ...

  1. #1
    Unregistered
    Guest

    C++ Full Screen

    Hey all, I'm just wondering, how do you make a Visual C++ program display in full screen, i have a Battleship game that would look kind of cool on full screen. I've searched all over and I can't find anything. You guys are my last hope!!!!!Help!!!!
    (Thanx in advance)

  2. #2
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    What compiler/os are you using? What type of program is it?
    zen

  3. #3
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    and showing us the code might help...i think

  4. #4
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    in the createwindow function you use the WS_POPUP flag and make the width and height the same as the screen settings.

  5. #5
    Unregistered
    Guest
    ok, folks, the thing is this is a Battleship game, and the compiler is Visual C++ 6.0, OS is Windows XP, and here's the code:

    //Raj Srikrishnan
    //2nd Hr
    //Battleship

    //Header Files
    #include <fstream.h>
    #include <time.h>
    #include <iomanip.h>
    #include <string.h>
    #include <stdlib.h>
    #include <windows.h>
    //Function prototypes
    void Clearer();
    int CheckerUser(int z, int w); //Checks to see if a ship has been hit by the computer
    void SetMCGA();
    void CheckerComp(int z, int w); //Checks to see if a ship has been hit by the user
    void TableDraw(); //Draws a table with the multidimensional array in it, Shows the user's grids
    void AIPlace(); //Placement of ships by the computer in the beginning
    void AIGuess(); //Computer guess of where the user's ships are
    void UserPlace(); //User's placement of ships
    void ShipChecker(char ship); //Checks to see if a ship has been sunk by the computer
    void ShipCheckerComp(char ship); //Checks to see if a ship has been sunk by the user
    //Global variable Declarations
    char AIShip[10][10]; //The ai's ship placement
    char UserGuess[10][10], UserShip[10][10]; //The User's guessing grid,and the user's ship placement
    int comp1, comp2, specialguess, w, w1; //AI's x and y guess of the user, and then the ai's special guess, winning variable for user, winning variable for comp
    int a, b, c, d, s; //Counters for:Aircraft Carrier, Battleship, Cruiser, Destroyer, Submarine(AI's Ships)
    int a1, b1, c1, d1, s1; //Counters for:Aircraft Carrier, Battleship, Cruiser, Destroyer, Submarine(User's ships)
    struct HighScore //Structure for if the user wins
    {
    char Name[40]; //Name of the user
    int Score; //Score of the user
    };

    main()
    {
    //Variable Declarations
    int x,y, x1; //Placement variables, counter variable
    x1=0;
    char name[40]; //Name of the user if the user wins the game(For high score purposes)
    HighScore udtArray[10], temp; //Array for if the user wins the game, used to store a struct while sorting
    ifstream infile; //File pointer for input file
    ofstream outfile; //File pointer for output file

    Clearer();
    AIPlace();
    UserPlace();
    //After the user enters all the ships
    do
    {
    x1++;
    TableDraw();
    cout << "Enter the coordinates of your guess:";
    cin >> x >> y;
    while(x>9 || y>9)
    {
    cout << "That is an illegal guess. Please type a valid coordinate\n";
    cin >> x >> y;
    }
    system("CLS");
    CheckerComp(y, x);
    AIGuess();
    }while(x1<=100 && w<5 && w1<5);
    if(w1==5)//If computer wins
    cout << "The computer wins the game!!!!\n";
    if(w==5)//If user wins
    {
    cout << "You win the game!!!!\n";
    cout << "Enter your name:";
    cin.ignore(80, '\n');
    cin.get(name, 40);
    cin.ignore(80, '\n');
    x=0;
    //Opens the file for input and sorting
    infile.open("HighScore.txt", ios::in);
    {
    if(!infile.eof())
    {
    do
    {
    infile.ignore(80, char(-52));
    infile.get(udtArray[x].Name, 40);
    infile.ignore(80, '\n');
    infile >> udtArray[x].Score;
    infile.ignore(80, '\n');
    x++;
    }while(!infile.eof() && x<=9);
    }
    else
    cout << "ERROR!!!, Program ending!!!!";
    }
    //This is where the bubble sort sorts the high score list properly
    for(int i=0;i<9;i++)
    {
    for(int pos=0;pos<i;pos++)
    {
    if(udtArray[pos].Score<udtArray[pos+1].Score)
    {
    temp=udtArray[pos];
    udtArray[pos]=udtArray[pos+1];
    udtArray[pos+1]=temp;
    }
    }
    }
    cout<<"Saving.\n";
    Sleep(500);
    system("CLS");
    cout<<"Saving..\n";
    Sleep(1000);
    system("CLS");
    cout<<"Saving...\n";
    Sleep(2000);
    //After the bubble sort, it writes to the file after erasing it
    outfile.open("HighScore.txt", ios:ut);
    {
    if(!outfile.eof())
    for(x=0; x<=9; x++)
    {
    outfile << udtArray[x].Name << '\n'<< udtArray[x].Score << '\n';
    }
    else
    cout << "ERROR!!!, Program ending!!!!";
    }
    outfile.close();
    cout<<"Saving complete. Game over!!!\n";
    }
    return 0;
    }
    void AIPlace()
    {
    //This is where the ai places his ships
    int comp1, comp2, random;
    srand((unsigned)time(NULL));
    //Destroyer Placement
    do
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }while(int(AIShip[comp1][comp2])!=32);
    random=(rand() % 3) + 0;
    switch(random)
    {
    case 0: //Left from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1][comp2-1])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1][comp2-1])==0 || comp2-1<0)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='D';
    AIShip[comp1][comp2-1]='D';
    break;
    case 1: //Up from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1-1][comp2])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1-1][comp2])==0)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='D';
    AIShip[comp1-1][comp2]='D';
    break;
    case 2: //Right from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1][comp2+1])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1][comp2+1])==0 || comp2+1>9)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='D';
    AIShip[comp1][comp2+1]='D';
    break;
    case 3: //Down from first coordinatec
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1+1][comp2])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1+1][comp2])==0)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='D';
    AIShip[comp1+1][comp2]='D';
    break;
    }
    //Submarine Placement
    do
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }while(int(AIShip[comp1][comp2])!=32);
    random=(rand() % 3) + 0;
    switch(random)
    {
    case 0: //Left from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1][comp2-1])!=32 || int(AIShip[comp1][comp2-2])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1][comp2-1])==0 || int(AIShip[comp1][comp2-2])==0 || comp2-2<0)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='S';
    AIShip[comp1][comp2-1]='S';
    AIShip[comp1][comp2-2]='S';
    break;
    case 1: //Up from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1-1][comp2])!=32 || int(AIShip[comp1-2][comp2])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1-1][comp2])==0 || int(AIShip[comp1-2][comp2])==0)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='S';
    AIShip[comp1-1][comp2]='S';
    AIShip[comp1-2][comp2]='S';
    break;
    case 2: //Right from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1][comp2+1])!=32 || int(AIShip[comp1][comp2+2])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1][comp2+1])==0 || int(AIShip[comp1][comp2+2])==0 || comp2+2>9)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='S';
    AIShip[comp1][comp2+1]='S';
    AIShip[comp1][comp2+2]='S';
    break;
    case 3: //Down from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1+1][comp2])!=32 || int(AIShip[comp1+2][comp2])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1+1][comp2])==0 || int(AIShip[comp1+2][comp2])==0)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='S';
    AIShip[comp1+1][comp2]='S';
    AIShip[comp1+2][comp2]='S';
    break;
    }
    //Cruiser Placement
    do
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }while(int(AIShip[comp1][comp2])!=32);
    random=(rand() % 3) + 0;
    switch(random)
    {
    case 0: //Left from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1][comp2-1])!=32 || int(AIShip[comp1][comp2-2])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1][comp2-1])==0 || int(AIShip[comp1][comp2-2])==0 || comp2-2<0)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='C';
    AIShip[comp1][comp2-1]='C';
    AIShip[comp1][comp2-2]='C';
    break;
    case 1: //Up from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1-1][comp2])!=32 || int(AIShip[comp1-2][comp2])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1-1][comp2])==0 || int(AIShip[comp1-2][comp2])==0)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='C';
    AIShip[comp1-1][comp2]='C';
    AIShip[comp1-2][comp2]='C';
    break;
    case 2: //Right from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1][comp2+1])!=32 || int(AIShip[comp1][comp2+2])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1][comp2+1])==0 || int(AIShip[comp1][comp2+2])==0 || comp2+2>9)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='C';
    AIShip[comp1][comp2+1]='C';
    AIShip[comp1][comp2+2]='C';
    break;
    case 3: //Down from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1+1][comp2])!=32 || int(AIShip[comp1+2][comp2])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1+1][comp2])==0 || int(AIShip[comp1+2][comp2])==0)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='C';
    AIShip[comp1+1][comp2]='C';
    AIShip[comp1+2][comp2]='C';
    break;
    }
    //Battleship Placement
    do
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }while(int(AIShip[comp1][comp2])!=32);
    random=(rand() % 3) + 0;
    switch(random)
    {
    case 0: //Left from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1][comp2-1])!=32 || int(AIShip[comp1][comp2-2])!=32 || int(AIShip[comp1][comp2-3])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1][comp2-1])==0 || int(AIShip[comp1][comp2-2])==0 || int(AIShip[comp1][comp2-3])==0 || comp2-3<0)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='B';
    AIShip[comp1][comp2-1]='B';
    AIShip[comp1][comp2-2]='B';
    AIShip[comp1][comp2-3]='B';
    break;
    case 1: //Up from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1-1][comp2])!=32 || int(AIShip[comp1-2][comp2])!=32 || int(AIShip[comp1-3][comp2])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1-1][comp2])==0 || int(AIShip[comp1-2][comp2])==0 || int(AIShip[comp1-3][comp2])==0)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='B';
    AIShip[comp1-1][comp2]='B';
    AIShip[comp1-2][comp2]='B';
    AIShip[comp1-3][comp2]='B';
    break;
    case 2: //Right from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1][comp2+1])!=32 || int(AIShip[comp1][comp2+2])!=32 || int(AIShip[comp1][comp2+3])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1][comp2+1])==0 || int(AIShip[comp1][comp2+2])==0 || int(AIShip[comp1][comp2+3])==0 || comp2+3>9)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='B';
    AIShip[comp1][comp2+1]='B';
    AIShip[comp1][comp2+2]='B';
    AIShip[comp1][comp2+3]='B';
    break;
    case 3: //Down from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1+1][comp2])!=32 || int(AIShip[comp1+2][comp2])!=32 || int(AIShip[comp1+3][comp2])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1+1][comp2])==0 || int(AIShip[comp1+2][comp2])==0 || int(AIShip[comp1+3][comp2])==0)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='B';
    AIShip[comp1+1][comp2]='B';
    AIShip[comp1+2][comp2]='B';
    AIShip[comp1+3][comp2]='B';
    break;
    }
    //Aircraft Carrier Placement
    do
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }while(int(AIShip[comp1][comp2])!=32);
    random=(rand() % 3) + 0;
    switch(random)
    {
    case 0: //Left from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1][comp2-1])!=32 || int(AIShip[comp1][comp2-2])!=32 || int(AIShip[comp1][comp2-3])!=32 || int(AIShip[comp1][comp2-4])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1][comp2-1])==0 || int(AIShip[comp1][comp2-2])==0 || int(AIShip[comp1][comp2-3])==0 || int(AIShip[comp1][comp2-4])==0 || comp2-4<0)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='A';
    AIShip[comp1][comp2-1]='A';
    AIShip[comp1][comp2-2]='A';
    AIShip[comp1][comp2-3]='A';
    AIShip[comp1][comp2-4]='A';
    break;
    case 1: //Up from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1-1][comp2])!=32 || int(AIShip[comp1-2][comp2])!=32 || int(AIShip[comp1-3][comp2])!=32 || int(AIShip[comp1-4][comp2])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1-1][comp2])==0 || int(AIShip[comp1-2][comp2])==0 || int(AIShip[comp1-3][comp2])==0 || int(AIShip[comp1-4][comp2])==0)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='A';
    AIShip[comp1-1][comp2]='A';
    AIShip[comp1-2][comp2]='A';
    AIShip[comp1-3][comp2]='A';
    AIShip[comp1-4][comp2]='A';
    break;
    case 2: //Right from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1][comp2+1])!=32 || int(AIShip[comp1][comp2+2])!=32 || int(AIShip[comp1][comp2+3])!=32 || int(AIShip[comp1][comp2+4])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1][comp2+1])==0 || int(AIShip[comp1][comp2+2])==0 || int(AIShip[comp1][comp2+3])==0 || int(AIShip[comp1][comp2+4])==0 || comp2+4>9)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='A';
    AIShip[comp1][comp2+1]='A';
    AIShip[comp1][comp2+2]='A';
    AIShip[comp1][comp2+3]='A';
    AIShip[comp1][comp2+4]='A';
    break;
    case 3: //Down from first coordinate
    while(int(AIShip[comp1][comp2])!=32 || int(AIShip[comp1+1][comp2])!=32 || int(AIShip[comp1+2][comp2])!=32 || int(AIShip[comp1+3][comp2])!=32 || int(AIShip[comp1+4][comp2])!=32 || int(AIShip[comp1][comp2])==0 || int(AIShip[comp1+1][comp2])==0 || int(AIShip[comp1+2][comp2])==0 || int(AIShip[comp1+3][comp2])==0 || int(AIShip[comp1+4][comp2])==0)
    {
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    }
    AIShip[comp1][comp2]='A';
    AIShip[comp1+1][comp2]='A';
    AIShip[comp1+2][comp2]='A';
    AIShip[comp1+3][comp2]='A';
    AIShip[comp1+4][comp2]='A';
    }
    }

    void UserPlace()
    {
    //This is where the user places his ship
    int x, y, continues;
    char direction; //Variable that stores which way the user wants to place their ship
    //Right here is where the user will enter his ships in
    //Destroyer Placement
    do
    {
    cout << "Enter the coordinate of the first endpoint of your destroyer(Top left is 0 0)";
    cin >> x >> y;
    cout << "Which way do you want to go from your fist coordinate?(directions are u/l/r/d)";
    cin.ignore(80, '\n');
    cin >> direction;
    cin.ignore(80, '\n');
    continues=1;
    switch(direction)
    {
    case 'u': //Up from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y-1][x])!=32 || int(UserShip[y][x])==0 || int(UserShip[y-1][x])==0)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='D';
    UserShip[y-1][x]='D';
    }
    break;
    case 'l': //Left from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y][x-1])!=32 || int(UserShip[y][x])==0 || int(UserShip[y][x-1])==0 && x-1<0)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='D';
    UserShip[y][x-1]='D';
    }
    break;
    case 'r': //Right from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y][x+1])!=32 || int(UserShip[y][x])==0 || int(UserShip[y][x+1])==0 && x+1>9)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='D';
    UserShip[y][x+1]='D';
    }
    break;
    case 'd': //Down from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y+1][x])!=32 || int(UserShip[y][x])==0 || int(UserShip[y+1][x])==0)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='D';
    UserShip[y+1][x]='D';
    }
    break;
    }
    }while(continues==0);
    system("CLS");
    TableDraw();
    //Submarine Placement
    do
    {
    cout << "Enter the coordinate of the first endpoint of your submarine:";
    cin >> x >> y;
    cout << "Which way do you want to go from your first endpoint?(directions are u/l/r/d)";
    cin>>direction;
    cin.ignore(80, '\n');
    system("CLS");
    continues=1;
    switch(int(direction))
    {
    case 'u': //Up from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y-1][x])!=32 || int(UserShip[y-2][x])!=32 || int(UserShip[y][x])==0 || int(UserShip[y-1][x])==0 || int(UserShip[y-2][x])==0)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='S';
    UserShip[y-1][x]='S';
    UserShip[y-2][x]='S';
    }
    break;
    case 'l': //Left from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y][x-1])!=32 || int(UserShip[y][x-2])!=32 || int(UserShip[y][x])==0 || int(UserShip[y][x-1])==0 || int(UserShip[y][x-2])==0 || x-2<0)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='S';
    UserShip[y][x-1]='S';
    UserShip[y][x-2]='S';
    }
    break;
    case 'r': //Right from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y][x+1])!=32 || int(UserShip[y][x+2])!=32 || int(UserShip[y][x])==0 || int(UserShip[y][x+1])==0 || int(UserShip[y][x+2])==0 || x+2>9)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='S';
    UserShip[y][x+1]='S';
    UserShip[y][x+2]='S';
    }
    break;
    case 'd': //Down from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y+1][x])!=32 || int(UserShip[y+2][x])!=32 || int(UserShip[y][x])==0 || int(UserShip[y+1][x])==0 || int(UserShip[y+2][x])==0)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='S';
    UserShip[y+1][x]='S';
    UserShip[y+2][x]='S';
    }
    break;
    }
    }while(continues==0);
    TableDraw();
    //Cruiser Placement
    do
    {
    cout << "Enter the coordinate of the first endpoint of your cruiser:";
    cin >> x >> y;
    cout << "Which way do you want to go from your first endpoint?(directions are u/l/r/d)";
    cin>>direction;
    cin.ignore(80, '\n');
    continues=1;
    system("CLS");
    switch(direction)
    {
    case 'u': //Up from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y-1][x])!=32 || int(UserShip[y-2][x])!=32 || int(UserShip[y][x])==0 || int(UserShip[y-1][x])==0 || int(UserShip[y-2][x])==0)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='C';
    UserShip[y-1][x]='C';
    UserShip[y-2][x]='C';
    }
    break;
    case 'l': //Left from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y][x-1])!=32 || int(UserShip[y][x-2])!=32 || int(UserShip[y][x])==0 || int(UserShip[y][x-1])==0 || int(UserShip[y][x-2])==0 || x-2<0)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='C';
    UserShip[y][x-1]='C';
    UserShip[y][x-2]='C';
    }
    break;
    case 'r': //Right from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y][x+1])!=32 || int(UserShip[y][x+2])!=32 || int(UserShip[y][x])==0 || int(UserShip[y][x+1])==0 || int(UserShip[y][x+2])==0 || x+2>9)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='C';
    UserShip[y][x+1]='C';
    UserShip[y][x+2]='C';
    }
    break;
    case 'd': //Down from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y+1][x])!=32 || int(UserShip[y+2][x])!=32 || int(UserShip[y][x])==0 || int(UserShip[y+1][x])==0 || int(UserShip[y+2][x])==0)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='C';
    UserShip[y+1][x]='C';
    UserShip[y+2][x]='C';
    }
    break;
    }
    }while(continues==0);
    TableDraw();
    //Battleship Placement
    do
    {
    cout << "Enter the coordinate of the first endpoint of your battleship:";
    cin >> x >> y;
    cout << "Which way do you want to go from your first endpoint?(directions are u/l/r/d)";
    cin>>direction;
    cin.ignore(80, '\n');
    continues=1;
    system("CLS");
    switch(direction)
    {
    case 'u': //Up from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y-1][x])!=32 || int(UserShip[y-2][x])!=32 || int(UserShip[y-3][x])!=32|| int(UserShip[y][x])==0 || int(UserShip[y-1][x])==0 || int(UserShip[y-2][x])==0 || int(UserShip[y-3][x])==0)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='B';
    UserShip[y-1][x]='B';
    UserShip[y-2][x]='B';
    UserShip[y-3][x]='B';
    }
    break;
    case 'l': //Left from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y][x-1])!=32 || int(UserShip[y][x-2])!=32 || int(UserShip[y][x-3])!=32 || int(UserShip[y][x])==0 || int(UserShip[y][x-1])==0 || int(UserShip[y][x-2])==0 || int(UserShip[y][x-3])==0 || x-3<0)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='B';
    UserShip[y][x-1]='B';
    UserShip[y][x-2]='B';
    UserShip[y][x-3]='B';
    }
    break;
    case 'r': //Right from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y][x+1])!=32 || int(UserShip[y][x+2])!=32 || int(UserShip[y][x+3])!=32 || int(UserShip[y][x])==0 || int(UserShip[y][x+1])==0 || int(UserShip[y][x+2])==0 || int(UserShip[y][x+3])==0 || x+3>9)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='B';
    UserShip[y][x+1]='B';
    UserShip[y][x+2]='B';
    UserShip[y][x+3]='B';
    }
    break;
    case 'd': //Down from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y+1][x])!=32 || int(UserShip[y+2][x])!=32 || int(UserShip[y+3][x])!=32 || int(UserShip[y][x])==0 || int(UserShip[y+1][x])==0 || int(UserShip[y+2][x])==0 || int(UserShip[y+3][x])==0)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='B';
    UserShip[y+1][x]='B';
    UserShip[y+2][x]='B';
    UserShip[y+3][x]='B';
    }
    break;
    }
    }while(continues==0);
    TableDraw();
    //Aircraft carrier
    do
    {
    cout << "Enter the coordinate of the first endpoint of your aircraft carrier:";
    cin >> x >> y;
    cout << "Which way do you want to go from your first endpoint?(directions are u/l/r/d)";
    cin>>direction;
    cin.ignore(80, '\n');
    continues=1;
    system("CLS");
    switch(direction)
    {
    case 'u': //Up from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y-1][x])!=32 || int(UserShip[y-2][x])!=32 || int(UserShip[y-3][x])!=32 || int(UserShip[y-4][x])!=32 || int(UserShip[y][x])==0 || int(UserShip[y-1][x])==0 || int(UserShip[y-2][x])==0 || int(UserShip[y-3][x])==0 || int(UserShip[y-4][x])==0)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='A';
    UserShip[y-1][x]='A';
    UserShip[y-2][x]='A';
    UserShip[y-3][x]='A';
    UserShip[y-4][x]='A';
    }
    break;
    case 'l': //Left from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y][x-1])!=32 || int(UserShip[y][x-2])!=32 || int(UserShip[y][x-3])!=32 || int(UserShip[y][x-4])!=32 || int(UserShip[y][x])==0 || int(UserShip[y][x-1])==0 || int(UserShip[y][x-2])==0 || int(UserShip[y][x-3])==0 || int(UserShip[y][x-4])==0 || x-4<0)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='A';
    UserShip[y][x-1]='A';
    UserShip[y][x-2]='A';
    UserShip[y][x-3]='A';
    }
    break;
    case 'r': //Right from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y][x+1])!=32 || int(UserShip[y][x+2])!=32 || int(UserShip[y][x+3])!=32 || int(UserShip[y][x+4])!=32 || int(UserShip[y][x])==0 || int(UserShip[y][x+1])==0 || int(UserShip[y][x+2])==0 || int(UserShip[y][x+3])==0 || int(UserShip[y][x+4])==0 || x+4>9)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='A';
    UserShip[y][x+1]='A';
    UserShip[y][x+2]='A';
    UserShip[y][x+3]='A';
    }
    break;
    case 'd': //Down from first coordinate
    if(int(UserShip[y][x])!=32 || int(UserShip[y+1][x])!=32 || int(UserShip[y+2][x])!=32 || int(UserShip[y+3][x])!=32 || int(UserShip[y+4][x])!=32 || int(UserShip[y][x])==0 || int(UserShip[y+1][x])==0 || int(UserShip[y+2][x])==0 || int(UserShip[y+3][x])==0 || int(UserShip[y+4][x])==0)
    {
    cout<< "That is an illegal coordinate.\n";
    continues=0;
    }
    else
    {
    UserShip[y][x]='A';
    UserShip[y+1][x]='A';
    UserShip[y+2][x]='A';
    UserShip[y+3][x]='A';
    UserShip[y+4][x]='A';
    }
    break;
    }
    }while(continues==0);
    }

    void CheckerComp(int z, int w)
    {
    //This checks to see if the user hit a part of an ai ship
    if(int(AIShip[z][w])!=32)
    {
    switch(AIShip[z][w])
    {
    case 'D': //If hit of the Destroyer
    cout << "You hit a ship of the AI!!!\n";
    ShipCheckerComp(AIShip[z][w]);
    UserGuess[z][w]='H';
    AIShip[z][w]='H';
    break;
    case 'S': //If hit of the Submarine
    cout << "You hit a ship of the AI!!!\n";
    ShipCheckerComp(AIShip[z][w]);
    UserGuess[z][w]='H';
    AIShip[z][w]='H';
    break;
    case 'C': //If hit of the Cruiser
    cout << "You hit a ship of the AI!!!\n";
    ShipCheckerComp(AIShip[z][w]);
    UserGuess[z][w]='H';
    AIShip[z][w]='H';
    break;
    case 'B': //If hit of the Battleship
    cout << "You hit a ship of the AI!!!\n";
    ShipCheckerComp(AIShip[z][w]);
    UserGuess[z][w]='H';
    AIShip[z][w]='H';
    break;
    case 'A': //If hit of the Aircraft carrier
    cout << "You hit a ship of the AI!!!\n";
    ShipCheckerComp(AIShip[z][w]);
    UserGuess[z][w]='H';
    AIShip[z][w]='H';
    break;
    }
    }
    else //If user misses all the ships
    {
    UserGuess[z][w]='M';
    cout << "You missed the ai's ships.\n";
    }
    }

    void ShipCheckerComp(char ship)
    {
    //This function checks to see if the user has sunk a ship, and will end the program properly
    switch(ship)
    {
    case 'D':
    d++;
    break;
    case 'S':
    s++;
    break;
    case 'C':
    c++;
    break;
    case 'B':
    b++;
    break;
    case 'A':
    a++;
    break;
    }
    if(d==2)
    {
    cout << "You sunk the AI's Destroyer!!!!\n";
    w++;
    d=0;
    }
    if(s==3)
    {
    cout << "You sunk the AI's Submarine!!!!\n";
    w++;
    s=0;
    }
    if(c==3)
    {
    cout << "You sunk the AI's cruiser!!!!\n";
    w++;
    c=0;
    }
    if(b==4)
    {
    cout << "You sunk the AI's Battleship!!!!\n";
    w++;
    b=0;
    }
    if(a==5)
    {
    cout << "You sunk the AI's Aircraft Carrier!!!!\n";
    w++;
    a=0;
    }
    }

    void ShipChecker(char ship)
    {
    //This function checks to see if the ai has sunk a ship, and will end the program properly
    switch(ship)
    {
    case 'D':
    d1++;
    break;
    case 'S':
    s1++;
    break;
    case 'C':
    c1++;
    break;
    case 'B':
    b1++;
    break;
    case 'A':
    a1++;
    break;
    }
    if(d1==2)
    {
    cout << "The AI sunk your Destroyer!!!!\n";
    w1++;
    d1=0;
    }
    if(s1==3)
    {
    cout << "The AI sunk your Submarine!!!!\n";
    w1++;
    s1=0;
    }
    if(c1==3)
    {
    cout << "The AI sunk your cruiser!!!!\n";
    w1++;
    c1=0;
    }
    if(b1==4)
    {
    cout << "The AI sunk your Battleship!!!!\n";
    w1++;
    b1=0;
    }
    if(a1==5)
    {
    cout << "The AI sunk your Aircraft Carrier!!!!\n";
    w1++;
    a1=0;
    }
    }
    void Clearer()
    {
    //This clears the matrices to make it easier to work with in the beginning
    int x,y;
    a=0;
    b=0;
    c=0;
    d=0;
    s=0;
    a1=0;
    b1=0;
    c1=0;
    d1=0;
    s1=0;
    for(x=0;x<=9;x++)
    {
    for(y=0;y<=9;y++)
    {
    UserShip[y][x]=char(32);
    AIShip[y][x]=char(32);
    UserGuess[y][x]='?';
    }
    }
    }

    void AIGuess()
    {
    //This is where the ai guesses where the user's ships are
    int random; //This is a variable that determines where to guess after the computer has hit the user initially
    if(specialguess!=1)
    {
    srand((unsigned)time(NULL));
    comp1=(rand() % 9) + 0;
    comp2=(rand() % 9) + 0;
    specialguess=CheckerUser(comp1, comp2);
    }
    else
    {
    random=(rand() % 3) + 0;
    switch(random)
    {
    case 0:
    specialguess=CheckerUser(comp1-1, comp2);
    break;
    case 1:
    specialguess=CheckerUser(comp1, comp2-1);
    break;
    case 2:
    specialguess=CheckerUser(comp1+1, comp2);
    break;
    case 3:
    specialguess=CheckerUser(comp1, comp2+1);
    break;
    }
    }
    }

    int CheckerUser(int z, int w)
    {
    //This checks to see if the ai hit a portion of the user's ships
    if(UserShip[z][w]!=32)
    {
    switch(UserShip[z][w])
    {
    case 'D': //If hit of the Destroyer
    cout << "The AI hit a portion of your destroyer!!!\n";
    ShipChecker(UserShip[z][w]);
    UserShip[z][w]='H';
    return 1;
    break;
    case 'S': //If hit of the Submarine
    cout << "The AI hit a portion of your submarine!!!\n";
    ShipChecker(UserShip[z][w]);
    UserShip[z][w]='H';
    return 1;
    break;
    case 'C': //If hit of the Cruiser
    cout << "The AI hit a portion of your cruiser!!!\n";
    ShipChecker(UserShip[z][w]);
    UserShip[z][w]='H';
    return 1;
    break;
    case 'B': //If hit of the Battleship
    cout << "The AI hit a portion of your battleship!!!\n";
    ShipChecker(UserShip[z][w]);
    UserShip[z][w]='H';
    return 1;
    break;
    case 'A': //If hit of the Aircraft Carrier
    cout << "The AI hit a portion of your aircraft carrier!!!\n";
    ShipChecker(UserShip[z][w]);
    UserShip[z][w]='H';
    return 1;
    break;
    default:
    return 0;
    }
    }
    else //If none of the ships are hit
    return 0;
    }

    void TableDraw()
    {
    //This draws the table of the user's ships, and the user's guesses
    int y;
    cout<<" _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n";
    for(y=0;y<=9;y++)
    {
    cout<<"|" << UserShip[y][0] << "|" << UserShip[y][1] << "|" << UserShip[y][2] << "|" << UserShip[y][3] << "|" << UserShip[y][4] << "|" << UserShip[y][5] << "|";
    cout<<UserShip[y][6] << "|" << UserShip[y][7] << "|" << UserShip[y][8] << "|" << UserShip[y][9] << "| |";
    cout<<AIShip[y][0] << "|" << AIShip[y][1] << "|" << AIShip[y][2] << "|" << AIShip[y][3] << "|" << AIShip[y][4] << "|" << AIShip[y][5] << "|";
    cout<<AIShip[y][6] << "|" << AIShip[y][7] << "|" << AIShip[y][8] << "|" << AIShip[y][9] <<"|\n";
    cout<< " - - - - - - - - - - - - - - - - - - - -\n";
    }
    }

  6. #6
    Registered User
    Join Date
    Dec 2001
    Posts
    194
    Next time use the CODE tags when posting code.
    Is this a simple console app that runs in a DOS command prompt?
    If so the only way to make it full screen is for the user to press ALT+ENTER or make a shortcut to the exe file, and check the settings to make it open full screen.

  7. #7
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    im sure there is way to do it using assembly code, if you're running msvc you can embed asm code into your app. I dont know the code but if you search the old boards you may find it...
    Monday - what a way to spend a seventh of your life

  8. #8
    Registered User marCplusplus's Avatar
    Join Date
    Nov 2001
    Posts
    68
    mmm i tried to run the code but it gave me 3 errors

    Compiling...
    prog.cpp
    C:\Program Files\Microsoft Visual Studio\MyProjects\battlwe\prog.cpp(114) : error C2275: 'ios' : illegal use of this type as an expression
    c:\program files\microsoft visual studio\vc98\include\ios.h(106) : see declaration of 'ios'
    C:\Program Files\Microsoft Visual Studio\MyProjects\battlwe\prog.cpp(114) : error C2143: syntax error : missing ')' before ':'
    C:\Program Files\Microsoft Visual Studio\MyProjects\battlwe\prog.cpp(114) : error C2059: syntax error : ')'

    Anybody know how that may be fixed?
    Marc
    No matter how much you know, you NEVER know enough.

  9. #9
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    Well I'm sure the IS a way to trick out the OS into making it fullscreen...but it practically requires you to take total control over the OS, iain . Remember, we're not talking about just simply DOS here, we're talking about a shell runing in windows....

    So anyhow, I can only come up with one solution: use FindWindow to get the handle of the console, and use SendMessage() to trick it out into thinking you've hit alt+enter.


    You might want to put a little warning before the game starts, though: "To put this game into windowed mode, hit alt+enter"

  10. #10
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    could you post some code for that please, Ken

    Also, would it be possible to generate the Alt+Enter interrupt code
    if the console has focus, would it expand???
    Monday - what a way to spend a seventh of your life

  11. #11
    Registered User
    Join Date
    Dec 2001
    Posts
    15
    No, in Windows, interrupts are dead. I learned that the hard way.
    Just make it a normal Windows application, create a bare-bones message-processing routine, and specify WS_POPUP during window creation like taylorguitarman said.

  12. #12
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You can maximise the Win32 console with something like -

    Code:
    #include <windows.h>
    
    int main()
    {
      
    	HANDLE hConsole;
    	COORD size;
    	HWND hWnd;
    		
    	hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    	size = GetLargestConsoleWindowSize(hConsole);
    	SetConsoleScreenBufferSize(hConsole,size);
    	SetConsoleTitle("test");
    	hWnd = FindWindow(NULL,"test");
    	
    	ShowWindow(hWnd,SW_MAXIMIZE);
    
            //Your code
    
    	return 0;
    	
    }
    It's not the same as alt-enter, though.
    zen

  13. #13
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    Ah...stupid me. I forgot about using ShowWindow to maximize it...

  14. #14
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    If you're still interested you can make the console enter fullscreen mode properly using (doesn't work on 9x) -

    Code:
    #include <windows.h>
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
      	HWND hWnd;
    	SetConsoleTitle("test");
    	hWnd = FindWindow(NULL,"test");
    	SendMessage(hWnd,WM_SYSKEYDOWN,
    			VK_RETURN,0xFF000000);
    
    	cout << "Hello World\n";
    	
    
    	
    	return 0;
    	
    }
    zen

  15. #15
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    >>doesnt work for 9x

    what does it work for? is it NT only?
    Monday - what a way to spend a seventh of your life

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Opening in full screen
    By MaGaIn in forum C++ Programming
    Replies: 14
    Last Post: 08-21-2007, 11:12 AM
  2. Full Screen
    By Rainer in forum C++ Programming
    Replies: 4
    Last Post: 08-08-2003, 05:56 AM
  3. !!!!!!Full screen!!!!!
    By Lukas in forum C++ Programming
    Replies: 2
    Last Post: 03-19-2003, 03:43 AM
  4. full screen
    By DominicTrix in forum Windows Programming
    Replies: 2
    Last Post: 04-21-2002, 06:13 AM
  5. Full Screen
    By JamMan in forum C++ Programming
    Replies: 3
    Last Post: 11-21-2001, 02:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21