im working a pretty advance program which is a huge jump from what we were doing.
1) im having problems displaying the grid and the robots. its suposed to refresh each time the rounds end.
2)Not really sure on how to assemble my functions =/ the most functions we ever use prior to this was 3. So any advice or help would be much loved=D
3) if you notice any error in my code or and easier way, please point it out.

Any advice or help at all will be absorbed and put to good use

#include <cstdlib>
#include <iostream>
#include "color.h"
#include <conio.h>

using namespace std;
using namespace Petter;

void title();
void credits();
void intro();
void instructions();
int menu(char arrayGrid[][21]);
void displayGrid(char arrayGrid[][21]);
void begin();
void yourTank();
void yourTankRotate();
void compTank();
void compTankRotate();
void stats();
void compStats();
void yourShootL();
void compShootL();
void shootG();
void shieldLeft();
void move();
void hitLaser();
void hitGrenade();
void direction();
void tankFace();



int main(int argc, char *argv[])
{
    //yourTank;
    //compTank;
    
    //yourTankY =2;
    //yourTankX = 2;
    //compTankY = 19;
    //compTankX = 19; 
    //int compShield; // HP
    //int compMove; // actions per a turn
    //int compWeapon; // +damage
    //int compRange; // how far weapon can shoot
    //int compTotal = compRange + compShield + compWeapon + compMove; 
    //int yourShield;// HP
    //int yourMove; // actions per a round
    //int yourWeapon; // +damage
    //int yourRange; // how far your weapon shoots
    //int yourTotal = yourRange + yourShield + yourWeapon + yourMove; // total stats cannot acceed 10
    //int yourRemaining = 10 - yourRange + yourShield + yourWeapon + yourMove;
    //int yourFace;
    //char action;
    char arrayGrid[][21]={
                        {201,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,187},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {200,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,188},
                        };
    
    
    title();
    credits();
    cout << endl;
    cout << endl;
    menu(arrayGrid);
    
    
    system("PAUSE");
    return EXIT_SUCCESS;
}
void title()
{
    cout << endl;
    cout << endl;
    cout << endl;
    cout << endl;
    cout <<  "\t\t\t" <<RED << " WELCOME TO M.I.M.E WARS!!!!!!!" << NORMAL << endl;   
}
void credits()
{
    cout << endl;
    cout << endl;
    cout << endl;
    cout << endl;
    cout << "\t\t\tCreated by: Michael Meyer" << endl;
    cout << "\t\t\tWith Help from: Mountain Dew" << endl;
}
int menu(char arrayGrid[][21])
{
    char choice;
    
    do
    {
    
    
    cout << "                                 :[B]ATTLE!:   " <<endl;
    cout << "                                               " <<endl;
    cout << "                                :[S]STORY LINE:" <<endl;
    cout << "                                               " <<endl;
    cout << "                               :[I]NSTRUCTIONS:" <<endl;
    cout << "                                               " <<endl;
    cout << "                              :[E]XIT(chicken!?):    " <<endl;
    
    choice =getch(); // calls for input
    switch(choice)
    {
                   case 'b':
                        {
                            begin();
                        }
                   break;
                   case 's':
                        {
                            intro();
                        }
                   break;
                   case 'i':
                        {
                            instructions();
                        }
                   break;
                   case 'e':
                   break;
    } 
    }
    while(choice != 'e');  

    return 0;
}
     
void instructions()
{
    cout << "\t\t\t\t Instructions" << endl << endl << endl;

            cout << "Player controls:" << endl;
            cout << "W key: Progress the M.I.M.E forward, towards the way they are facing." << endl;
            cout << "A key: Rotates the M.I.M.E left." << endl;
            cout << "D key: Rotatest the M.I.M.E Counter right." << endl;
            cout << "E key: Chooses to fire the M.I.M.E's Lazer." << endl;
            cout << "Q key: Chooses to lob a M.I.M.E's Grenade." << endl;     
    }
void into()
{
    cout << "\t\t\t\t Introduction" << endl << endl << endl;
            cout << "\tDuring the third World War a new breed of warefare was brought to life. M.I.M.E's were born to be a slave of men.";
           Sleep(4000);
            cout << " M.I.M.E, Mechines In Main Engagement, were a far more advance design of A.I.(Artificial Intelegence).";
            Sleep(4000);
            cout << "There mechines   were designed to lower human casualties, but instead turned and increase the   death toll.";
            cout << endl;
            Sleep(4000);
            cout << "\tWhen the M.I.M.Es turned, it was nothing more then a silent killing of  those around them.";
            Sleep(4000);
            cout << "Man was once again forced back into traditional warfare of    opertaing there own mechines and demise.";
            cout << endl;
            cout << endl;
            cout << endl;
            Sleep(4000);
            cout << "Who will win!?!?.........";
            cout << endl;
            cout << endl;    
}

void begin(char arrayGrid[][21])
{
    stats();
    //displayGrid(arrayGrid[][21]);
    cout << endl;
    shieldLeft();
    cout << endl;
    direction();
    cout << endl;
    cout << endl;
    move();
}
void displayGrid(char arrayGrid[][21]) // display the grid + robots
{
    cout << (char)      {201,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,187},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {199,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,197,196,182},
                        {186,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',186},
                        {200,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,188},
                        }; 
}
void yourTank() // your tank Green
{
     
}

/*void yourTankRotate() // Shows you tank rotating N, S, W, E
{
    if(action == a)
        {
            yourFace - 1;
            
        }
    else if(action == d)
        {
            yourFace - 1;
        }
    //yourTankFace(); 
}
*/
void compTank() // computer tank Red
{
    
}

void compTankRotate() // Shows computer tank rotating N, S, W, E
{
    
}

void stats()
{
   int yourShield; // HP
   int yourMove; // actions per a round
   int yourWeapon; // +damage
   int yourRange; // how far your weapon shoots
   int yourTotal = yourRange + yourShield + yourWeapon + yourMove; // total stats cannot acceed 10
   int yourRemaining = 10 - yourRange + yourShield + yourWeapon + yourMove;
    
     cout << "Choose the stats you would like for your M.I.M.E., with a max total of 10." << endl;
     
     while(yourTotal != 10)
     {
         cout << "Choose 1-6 for your range of your weapon(" << yourRemaining << " points left: ";
         cin >> yourRange;
         while((cin == 0) || (yourRange < 0))
                    {
                        cin.clear();
                        cin.ignore(10000, '\n');
                        cout << "Please enter the amount of range: ";
                        cin >> yourRange;
                    }
         
         cout << "Choose 1-6 for your shields(" << yourRemaining << " points left: ";
         cin >> yourShield;
         while((cin == 0) || (yourShield < 0))
                    {
                        cin.clear();
                        cin.ignore(10000, '\n');
                        cout << "Please enter amount for the shield: ";
                        cin >> yourShield;
                    }
         
         cout << "Choose 1-6 for your weapon damage(" << yourRemaining << " points left: ";
         cin >> yourWeapon;
         while((cin == 0) || (yourWeapon < 0))
                    {
                        cin.clear();
                        cin.ignore(10000, '\n');
                        cout << "Please enter the amount for the weapon: ";
                        cin >> yourWeapon;
                    }
         
         cout << "Choose 1-6 for your movement speed(" << yourRemaining << " points left: ";
         cin >> yourMove;
         while((cin == 0) || (yourMove < 0))
                    {
                        cin.clear();
                        cin.ignore(10000, '\n');
                        cout << "Please enter the amount for movement: ";
                        cin >> yourMove;
                    }
    }
}

void compStats() // stats MUST be random 1-6 cannot accede 10 total
{
    srand(time(0)); // int random number
    int total = 0;
    int compRange;
    int compShield;
    int compWeapon;
    int compMove;
    
    cout << "The computers stats are as shown: " << endl;
    
    while(total != 10 )
    {
        compRange = (rand() % 6) + 1;
        total = compRange - 10;
        compShield = (rand() % 6) + 1;
        total = (compShield + compRange) - 10;
        compWeapon = (rand() % 6) + 1;
        total =(compShield + compRange + compWeapon) - 10;
        compMove = (rand() % 6) + 1;
        total =(compShield + compRange + compRange + compMove) - 10;
    }
    
    cout << "Range is = " << compRange << endl;
    cout << "Shield is = " << compShield << endl;
    cout << "Weapon is = " << compWeapon << endl;
    cout << "Movement is = " << compMove << endl;
}


void yourShootL() // direct shot 2 damage
{
    int face;
    int yourTankX;
    int yourRange;
    int weaponX;
    int yourTankY;
    int weaponY;
    
    if( 2 == face || 4 == face)
        {
            weaponX = yourTankX + yourRange;
        }
    else if( 1 == face || 3 == face)
        {
             weaponY = yourTankY + yourRange;
        }



     hitLaser();
}

void compShootL() // direct shot 2 damage
{
    int face;
    int compTankY;
    int compTankX;
    int weaponX;
    int weaponY;
    int compRange;

    if( 2 == face || 4 == face)
        {
             weaponX = compTankX + compRange;
        }
    else if ( 1 == face || 3 == face)
        {
             weaponY = compTankY + compRange;
        }



     hitLaser();
}

void shootG() // Area of affect dmg 3x3 1 dmg
{
    int face;
    int yourTankX;
    int yourRange;
    int weaponX;
    int yourTankY;
    int weaponY;
    
    if( 2 == face || 4 == face)
        {
             weaponX = yourTankX + yourRange;
        }
    else if( 1 == face || 3 == face)
        {
             weaponY = yourTankY + yourRange;
        }
        
    hitGrenade();
}

void shieldLeft() // remaining life points
{
     int yourShield;
     int compShield;
     
     cout << "Your shield left is: " << yourShield << endl;
     
     cout << "The computers shield left is: " << compShield << endl;
}

void direction() // which direction you are facing to determine which way you can move
{                 // face must remain 1-4
    int yourFace;
    
    if( yourFace == 1)
        {
             cout << "You are facing North" ;
        }
    else if(yourFace == 2)
        {
             cout << "You are facing West";
        }
    else if(yourFace == 3)
        {
            cout << "You are facing South";    
        }
    else if(yourFace == 4)
        {
            cout << "You are facing East";    
        }
    else if( yourFace > 4 || yourFace < 1)
    {
        yourFace = 1;
        cout << "You are facing North"; 
    }
}

void yourTankFace()
{
   int yourFace;
    
    if( yourFace == 1)//North
        {
              cout << GREEN << (char)193;
        }
    else if(yourFace == 2)//South
        {
            cout << GREEN << (char)194;
        }
    else if(yourFace == 3)//West
        {
            cout << GREEN << (char)180;    
        }
    else if(yourFace == 4)//East
        {
            cout << GREEN << (char)195;
        }
}

void compTankFace()
{
    int face;
    
    if( face = 1)//North
        {
            cout << RED << (char)193;
        }
    else if(face == 2)//South
        {
            cout << RED << (char)194;
        }
    else if(face == 3)//East
        {
            cout << RED << (char)180;
        }
    else if(face == 4)//West
        {
            cout << RED << (char)195;    
        }    
}

void move() // Move you forward
{
     int x;
     int y;
     int action;
     int moveX;
     int moveY;
     int yourTankX;
     int yourTankY;
     int face;
     
     
     cout << "Choose an action: 1 - Move Forward, 2 - Rotate Left, 3 - Rotate right, 4 - Fire Laser, 5 - Lob Grenade." << endl;
     cin >> action;
     
     switch(action)
     {
        case 1: // move forward adding 1 to X or Y axis based on direction facing 
            while( x != 0 && x != 21 && y != 0 && y != 21)
            {
                if( 2== face || 4 == face)
                    {
                         moveX =yourTankX + 2;    
                    }   
                else if ( 1 == face || 3 == face)
                    {
                         moveY = yourTankY + 2;
                    } 
            }
            break;
            
        case 2: // rotates you to the left subtracting 1 from face
             // yourTankRotate();
              break;
                      
        case 3: // rotates you to the right adding 1 to face
              //yourTankRotate();
              break;
                          
        case 4: // fires THE LAZER! 
              //shootL();
              break;
            
        case 5:  // Lobs the grenade
             //shootG();
             break;
        
     }
}

void hitLaser() // determines if the laser hit
{
    int weaponY;
    int yourTankY;
    int compTankY;
    int weaponX;
    int yourTankX;
    int compTankX;
    
    if (weaponY == yourTankY || weaponY == compTankY)
        {

            shieldLeft();
        }
    else if (weaponX == yourTankX || weaponX == compTankX)
            {
    
                shieldLeft();
            }
         
}

void hitGrenade() // determines if the Grenade hits
{
    int weaponY;
    int yourTankY;
    int compTankY;
    int weaponX;
    int yourTankX;
    int compTankX;
    
    if (weaponY + 3 == compTankY)
        {

            shieldLeft();
        }
    else if (weaponX + 3 == compTankX)
            {
    
                shieldLeft();
            }
}

It will make your life easier if you explicitly specify the number of rows in addition to the number of columns in your array.

In your display function this won't work:
cout << (char){201,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,209,205,187},.......

You need to output elements of an array one at a time, with the one exception to my knowledge being a string. Therefore you should use syntax that does that. One commonly used protocol looks something like this:

for(int i = 0; i < numRows; ++i)
  for(int j = 0; j < numCols; ++j)
    cout << arrayGrid[i][j];

So you are talking about something like this?

void printgrid(char grid[][10],int h,int w)    //create grid
{
     for(int i = 0;i < h;i++)
     {
             for(int j = 0;j < w;j++)
             {
                     cout << grid[i][j] << '.';
             }
     cout <<endl;
     }
}

Yes.

Since you are using integers in a char array you may (or may not, I don't have a lot of experience trying it) need to cast the int to a char like you did in your original post, but the important point is you need to ouput each element of an array separately unless it is being used as a string (there may be other exceptions, too, but if so I am not aware of them).

This article has been dead for over six months. Start a new discussion instead.