What is wrong with this?

This is a discussion on What is wrong with this? within the C++ Programming forums, part of the General Programming Boards category; I am compiling this with Dev C++ (Mandatory of instructor.) I am using whatever compiler was default. When I compile ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    1

    What is wrong with this?

    I am compiling this with Dev C++ (Mandatory of instructor.)
    I am using whatever compiler was default.

    When I compile my program I get the error
    too many arguments to function 'bool checkFire()'

    What is wrong with this?

    Thanks

    Code:
    //Cursor Position
    
    #include <conio.h> //required for getch()
    #include <cstdlib>
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    string map1[24] =
           {
               "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
               "XXXXX   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX             XXXXXXXXX\n",
               "XXXXX   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX             XXXXXXXXX\n",
               "XXXXX               XXXXXXXXX                                         XXXX   XX\n",
               "XXXXXXXXXXXXXXXX    XXXXXXXXX   XXXXXXXXXXXXXXXXXXXXXXXXX             XXXX   XX\n",
               "XXXXXXXXXXXXXXXX    XXXXXXXXX   XXXXXXXXXXXXXXXXXXXXXXXXX             XXXX   XX\n",
               "XXXXXXXXXXXXXX       XXXXXXXX   XXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXX   XX\n",
               "XXXXXXXXXXXXXX   X   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXX   XX\n",
               "XXXXXXXXXXXXXX   X   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXX   XX\n",
               "XXXXXXXXXXXX    XXX    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXX   XX\n",
               "XXXXXXXXXX     XXXXX    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXX   XX\n",
               "XXXXXXXXXX   XXXXXXXX   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXX   XX\n",
               "XXXXX        XXXXXXXX                                           XXXXXXXXXX   XX\n",
               "XXXXX   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XX\n",
               "XXXXX   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XX\n",
               "XXXXX                                                                        XX\n",
               "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
               "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
               "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
               "XXXXXXXXXXXXXXXXXXXXXXXXXXXX       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
               "XXXXXXXXXXXXXXXXXXXXXXXXX      X      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
               "XXXXXXXXXXXXXXXXXXXXXXXXXXXX       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
               "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
               "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
           };
    
    string map2[24] =
           {
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
              "XXXXXXXXXXXXXXXXXX                             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX               XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX                                           XXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX               XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
              "XXXXXXXXXXXXXXXXXX                             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
              "XXXXXXX                                                              XXXXXXXXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXX      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXX      XXXXXXXXXXXX   XXXXXXXXXXXXXXXXXXXX   XXXXXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXX      XXXXXXXXXXXX   XXXXXXXXXXXXXXXXXXXX   XXXXXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXX      XXXXXXXXXXXX   XXXXXXXXXXXXXXXXXXXX   XXXXXXX\n",
              "X             XXXXXXXXXXXXXX      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
              "X          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXXXXXXX\n",
              "X          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXXXXXXX\n",
              "X          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   XXXXXXXXXXXXXXX\n",
              "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
           };
    
    string map3[24] =
        {
        "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "X                                                                             X\n",
        "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"
        };
    
    //function that generates a goto feature on the ouptut screen
    int monsters = 2; //tells how many monsters are alive. 
    void gotoxy(int x, int y)
    {
    HANDLE hConsoleOutput;
    COORD dwCursorPosition;
    cout.flush();
    dwCursorPosition.X = x;
    dwCursorPosition.Y = y;
    hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(hConsoleOutput,dwCursorPosition);
    }
    
    int defence = 2;    //defence
    int strength = 2;   //strength
    int demonhp = 25;   //demons hp
    int billhp = 15;
    int stevehp = 16;
    int hp = 30;       //your hp
    int demonoption;  //fight run heal - etc etc for demon
    int m1c = 69; //monster one's coordinates
    int m1r = 1;
    int m2c = 76;
    int m2r = 3;
        int c = 6;
        int r = 2;
        int monster = 2;
        int stevelife = 1;
        int billlife = 1;
    int tempm1c, tempm1r, tempm2r, tempm2c;
    
    bool checkMonster();
    bool monstersAlive();
    bool checkWall();
    bool checkFire();
    bool checkDoor();
    
    
    void chooseAttack1();
    void attackDemon();
    void ceoDead();
    void ceoWall();
    void healCharacter();
    void demonAttack();
    void runMonster();
    void demonDead();
    void youDead();
    void moveDemon();
    void checkDemon();
    void fightMonster1();
    void fightMonster2();
    void checkCEO();
    void ceoOptions();
    void attackBill();
    void attackSteve();
    void steveAttack();
    void billAttack();
    void healCharacter2();
    void billDead();
    void steveDead();
    void resetMap();
    void drawMap(string map[])
    
    
    
    {
         for (int j=0; j<24; j++)
         {
             cout<<map[j];
         }
    }
    
    void resetMap()
    {
         system ("cls");
           drawMap(map1);
        gotoxy (c,r);
        cout<<(char) 232; 
        gotoxy (m1c,m1r);
        cout<<"m";
            gotoxy (m2c,m2r);
        cout<<"m";
        gotoxy (30,6);
        cout<<"D";
        gotoxy (57,5);
        cout<<"(W)";
        int wallcounter = 1;
        while ( monstersAlive != false && wallcounter == 1 )
        {
        gotoxy (30,16);
        cout<<"XXX";
        wallcounter=2;
    }  
    }     
    
    bool checkWall(string map[], int x, int y)
    {
        bool hitWall = false;
    
        // the x and y are reversed because the string array picks which line first then the position within the line
        if (map[y][x] == 'X')
        {
           hitWall = true;
        }
    
        return hitWall;
    }
    bool collideDemon(string map[], int x, int y)
    {
        bool hitDemon = false;
    
        // the x and y are reversed because the string array picks which line first then the position within the line
        if (map[y][x] == m1c,m1r )
        {
           hitDemon = true;
        }
    
        return hitDemon;
    }
    
    
    
    void charMove(int x, int y)
    {
         gotoxy(x, y);
         cout<<(char) 232;
    }
    
    void charClear(int x, int y)
    {
        gotoxy(x, y);
        cout<<" ";
    
    }
    
    void fightMonster1()     //intro to fighting monster one
    {
        int fightlady;      // int to ask if you want to fight the old lady
        system ("cls");
        cout<<"You encounter an Old Lady."<<endl;
        //Enter Old Lady ASCII
    	cout<<endl<<"Press Enter..."<<endl;    
    	cin.get();   //same as system pause but not as resource heavy 
    	Sleep (1500);
       cout<<"Want to fight it?"<<endl;
       cout<<"[1] - Yes   [2] - No"<<endl;
       cin>>fightlady;         //asks if you want to fight the old lady
       system ("cls");
    	if ( fightlady == 1 )   //if you want to fight it
    {
     cout<<"Why would you want to do that?"<<endl;
     Sleep (1500);
     cout<<"She's a helpless old lady!"<<endl;
     system ("PAUSE");
    }
          else if ( fightlady == 2 )     //if you don't want to fight it
    {
      cout<<"Good choice!"<<endl;
      cout<<"Just kidding, you're going to die. :)"<<endl;
      system ("PAUSE");
    }
      system ("cls");
      cout<<"The 'old lady' morphs into a giant demon!"<<endl;
      //Enter Demon ASCII
      system ("PAUSE");
      system ("cls");
      chooseAttack1();      
    }
      void chooseAttack1()   //call chooseAttack1 - fight options for the demon
      {
      system ("cls");
      cout<<"The Demon has "<<demonhp<<" health."<<endl<<"You have "<<hp<<" health."<<endl;
      cout<<"Your options are"<<endl<<"[1] - Attack"<<endl<<"[2] - Heal"<<endl<<"[3] - Skip Turn"<<endl<<"[4] - Run"<<endl;
      cin>>demonoption;  //asks what you want to do when fighting the demon
      system ("cls");
      if ( demonoption == 1 )
      {
       attackDemon();
      }
      else if ( demonoption == 2 )
      {
       healCharacter();
      }
      else if ( demonoption == 3 )
      {
       demonAttack();
      }
      else if ( demonoption == 4 )
      {
       runMonster();
      }
      }
         bool killedYou()
    {
        bool killedYou = false;
    
        if ( hp <= 0 )
        {
           killedYou = true;
        }
    
        return killedYou;
    }
        bool monstersAlive()
    {
        bool monstersAlive = true;
    
        if ( monsters == 0 )
        {
           monstersAlive = false;
        }
    
        return monstersAlive;
    }
        bool killedDemon()
        {
        bool killedDemon = false;
    
        if ( demonhp <= 0 )
        {
           killedDemon = true;
        }
    
        return killedDemon;
    }
    void demonWall(string map[])
    {
        srand (time(NULL)); // initialize the randomizer
        do
        {
            tempm1c=m1c;
            tempm1r=m1r;
            int random = (rand()%10);
            int random2 = (rand()%10);
            int random3 = (rand()%2);
    //        if ( random == 1 || random == 3 || random == 5 || random == 7 || random == 9 )
            if ( random == 5 || random == 7 || random == 9 )
            {
               tempm1c=tempm1c-1;    
            }
    //        else if ( random == 2 || random == 4 || random == 6 || random == 8 || random == 10 )     
            else if (random == 6 || random == 8 || random == 10 )     
            {
               tempm1c=tempm1c+1;     
            }
    //        if ( random2 == 1 || random2 == 3 || random2 == 5 || random2 == 7 || random2 == 9 )
            if ( random2 == 5 || random2 == 7 || random2 == 9 )
            {
               tempm1r=tempm1r-1;     
            }
    //        else if ( random2 == 2 || random2 == 4 || random2 == 6 || random2 == 8 || random2 == 10 )
            else if ( random2 == 6 || random2 == 8 || random2 == 10 )
            {
               tempm1r=tempm1r+1;     
            }
        }
        while(checkWall(map, tempm1c, tempm1r) && ((tempm1c>23) || (tempm1c<0) || (tempm1r<0) || (tempm1r>78)));
    
        //if ( random3 == 1 || random3 == 2 && (!checkWall(map, tempm1c, tempm1r))
        //{
        charClear(m1c, m1r);
        m1c=tempm1c;
        m1r=tempm1r;
        gotoxy (m1c, m1r);
        cout<<"m";
        //}
        
    }
    void ceoWall(string map[])
    {
        srand (time(NULL)); // initialize the randomizer
        do
        {
            tempm2c=m2c;
            tempm2r=m2r;
            int random = (rand()%10);
            int random2 = (rand()%10);
            int random3 = (rand()%2);
    //        if ( random == 1 || random == 3 || random == 5 || random == 7 || random == 9 )
            if ( random == 5 || random == 7 || random == 9 )
            {
               tempm2c=tempm2c-1;    
            }
    //        else if ( random == 2 || random == 4 || random == 6 || random == 8 || random == 10 )     
            else if (random == 6 || random == 8 || random == 10 )     
            {
               tempm2c=tempm2c+1;     
            }
    //        if ( random2 == 1 || random2 == 3 || random2 == 5 || random2 == 7 || random2 == 9 )
            if ( random2 == 5 || random2 == 7 || random2 == 9 )
            {
               tempm2r=tempm2r-1;     
            }
    //        else if ( random2 == 2 || random2 == 4 || random2 == 6 || random2 == 8 || random2 == 10 )
            else if ( random2 == 6 || random2 == 8 || random2 == 10 )
            {
               tempm2r=tempm2r+1;     
            }
        }
        while(checkWall(map, tempm2c, tempm2r) && (checkFire(map, tempm2c, tempm2r) && (checkDoor(map, tempm2c, tempm2r) && ((tempm2c>23) || (tempm2c<0) || (tempm2r<0) || (tempm2r>78)));
        
        //if ( random3 == 1 || random3 == 2 && (!checkWall(map, tempm1c, tempm1r))
        //{
    
        charClear(m2c, m2r);
        m2c=tempm2c;
        m2r=tempm2r;
        gotoxy (m2c, m2r);
        cout<<"m";
        
         
    }
    
    bool checkFire(string map[], int x, int y)
    {
        bool hitFire = false;
    
        // the x and y are reversed because the string array picks which line first then the position within the line
        if (map[y][x] == '(')
        {
           hitFire = true;
        }
        else if (map[y][x] == 'W')
        {
             hitFire = true;
             }
             else if (map[y][x] == ')')
             {
                  hitFire = true;
                  }
    
        return hitFire;
    }
    bool checkDoor(string map[], int x, int y)
    {
        bool hitDoor = false;
    
        // the x and y are reversed because the string array picks which line first then the position within the line
        if (map[y][x] == 'D')
        {
           hitDoor = true;
        }
    
        return hitDoor;
    }
    void checkDemon()
    {
     if ( m1c == c && m1r == r )
     //if ( m1c != c )
     {
          fightMonster1();
    }         
    }
    void checkCEO()
    {
     if ( m2c == c && m2r == r )
     //if ( m1c != c )
     {
          fightMonster2();
    }         
    }          
    
    
    
      void attackDemon()
      {
       system ("cls");
       cout<<"You charge the demon!"<<endl;
       Sleep (1000);
       int damage = strength+(rand()%15);
       cout<<"You do "<<damage<<" damage."<<endl;
       demonhp=demonhp-damage;
       system ("PAUSE");
      if ( demonhp <= 0 )
      {
       system ("cls");
       demonDead();
      }
      else
      {
       system ("cls");
       demonAttack();
      }
    }
    void demonAttack()
    {
       system ("cls");
       cout<<"The demon attacks you!"<<endl;
       Sleep (1200);
       int damage = (rand()%15)+3-defence;
       cout<<"It does "<<damage<<" damage."<<endl;
       hp=hp-damage;
       system ("PAUSE");
    
      if ( hp <= 0 )
      {
       system ("cls");
       youDead();
      }
      else
      {
       system ("cls");
       chooseAttack1();
      }
    }   
    
    void healCharacter()
    {
    system ("cls");
    int heal = (rand()%11)+6;
    hp=hp+heal;
    cout<<"You heal by "<<heal<<" health, to "<<hp<<" health."<<endl;
    system ("PAUSE");
    demonAttack();
    }
    void runMonster()
    {
    system ("cls");
    cout<<"You run from the monster like the little girl you are."<<endl;
    system ("PAUSE");
         system ("cls");
    resetMap();
    }
    void demonDead()
    {
         system ("cls");
         cout<<"You killed the Demon!"<<endl<<"You are on your way to becoming a true killer!"<<endl;
         monster=monster-1;
         system ("PAUSE");
         system ("cls");
    resetMap();
         }
    void youDead()
    {
         system ("cls");
         cout<<"You died!"<<endl;
         gotoxy (5,2);
         cout<<"What";
         Sleep (1000);
         gotoxy (19,5);
         Sleep (1000);
         cout<<"The";
         Sleep (1000);
         gotoxy (31,8);
         cout<<"Heck!";
         cout<<endl<<endl<<endl;
         system ("PAUSE");
         system ("cls");
    resetMap();
         }
    
         
    
    void fightMonster2() 
    {
       system ("cls");
       cout<<"You encounter a grousome foe!"<<endl;
       system ("PAUSE");
       system ("cls");
       cout<<"It's.. it's.. it's...\n";
       system ("PAUSE");
       system ("cls");
       gotoxy (13,3);
       cout<<"Bill Gates";
       Sleep (400);
       gotoxy (24,4);
       cout<<"and";
       Sleep (400);
       gotoxy (28,5);
       cout<<"Steve Jobz!";
       gotoxy (1,10);
       system ("PAUSE");
       ceoOptions();
    }
       void ceoOptions()
       {
            while ( stevelife == 1 && billlife == 1 )
            {
            system ("cls");
       cout<<"Bill, the ex president of Micro$oft, has "<<billhp<<" health."<<endl<<"Steve Jobz, CEO of Apple, has "<<stevehp<<" health."<<endl<<"You have "<<hp<<" health."<<endl;
       system ("PAUSE");
    
    
       cout<<"[1] To Attack Bill\n[2] To Attack Steve\n[3] To Heal\n[4] To Run\n[5] To Skip Your Turn\n";
       int ceoFightOptions;
       cin>>ceoFightOptions;
       if ( ceoFightOptions == 1 )
       {
     attackBill();  
    }
    else if ( ceoFightOptions == 2 )
    {
         attackSteve();
         }
         else if ( ceoFightOptions == 3 )
         {
              healCharacter2();
              }
              else if ( ceoFightOptions == 4 )
              {
                   runMonster();
                   }
                   else if ( ceoFightOptions == 5 )
                   {
                        billAttack();
                        }
       }    
       while ( stevelife == 1 && billlife == 0 )
            {
            system ("cls");
       cout<<"Steve Jobz, CEO of Apple, has "<<stevehp<<" health."<<endl<<"You have "<<hp<<" health."<<endl;
       system ("PAUSE");
    
    
       cout<<"[1] To Attack Steve\n[2] To Heal\n[3] To Run\n[4] To Skip Your Turn\n";
       int ceoFightOptions;
       cin>>ceoFightOptions;
    
    if ( ceoFightOptions == 1 )
    {
         attackSteve();
         }
         else if ( ceoFightOptions == 2 )
         {
              healCharacter2();
              }
              else if ( ceoFightOptions == 3 )
              {
                   runMonster();
                   }
                   else if ( ceoFightOptions == 4 )
                   {
                        billAttack();
                        }
       }    
       while ( stevelife == 0 && billlife == 1 )
            {
            system ("cls");
       cout<<"Bill, the ex president of Micro$oft, has "<<billhp<<" health."<<endl<<"You have "<<hp<<" health."<<endl;
       system ("PAUSE");
    
    
       cout<<"[1] To Attack Bill\n[2] To Heal\n[3] To Run\n[4] To Skip Your Turn\n";
       int ceoFightOptions;
       cin>>ceoFightOptions;
       if ( ceoFightOptions == 1 )
       {
     attackBill();  
    }
    
         else if ( ceoFightOptions == 2 )
         {
              healCharacter2();
              }
              else if ( ceoFightOptions == 3 )
              {
                   runMonster();
                   }
                   else if ( ceoFightOptions == 4 )
                   {
                        billAttack();
                        }
       }    }
    
                   void healCharacter2()
                   {
                        system ("cls");
    int heal = (rand()%11)+6;
    hp=hp+heal;
    cout<<"You heal by "<<heal<<" health, to "<<hp<<" health."<<endl;
    system ("PAUSE");
    billAttack();
                        }
                        
    void attackBill ()
    {
       system ("cls");
       cout<<"You punch Bill in the mouth!"<<endl;
       Sleep (800);
       int damage = strength+(rand()%21);
       cout<<"You do "<<damage<<" damage."<<endl;
       billhp=billhp-damage;
       system ("PAUSE");
      if ( billhp <= 0 )
      {
       system ("cls");
       billDead();
      }
      else
      {
       system ("cls");
       billAttack();
      }
    }
    void attackSteve ()
    {
       system ("cls");
       cout<<"You punch Steve in the jaw!"<<endl;
       Sleep (900);
       int damage = strength+(rand()%12);
       cout<<"You do "<<damage<<" damage."<<endl;
       stevehp=stevehp-damage;
       system ("PAUSE");
      if ( stevehp <= 0 )
      {
       system ("cls");
       steveDead();
      }
      else
      {
       system ("cls");
       billAttack();
      }
    }
    void billDead()
    {
         billlife=0;
         while ( stevelife == 1 )
         {
         system ("cls");
         cout<<"You killed Bill Gates!"<<endl;
         system ("PAUSE");
         ceoOptions();
         }
         while ( stevelife == 0 )
         {
              system ("cls");
               cout<<"You Killed Bill Gates!"<<endl;
               system ("PAUSE");
               ceoDead();
               }      
         }
         void ceoDead()
         {
              monster=monster-1;
              system ("cls");
              cout<<"Both of the CEO's are dead!"<<endl<<"Good Job! :)"<<endl;
              system ("PAUSE");
              system ("cls");
              drawMap(map1);
        gotoxy (c,r);
        cout<<(char) 232; 
        gotoxy (m1c,m1r);
        cout<<"m";
            gotoxy (m2c,m2r);
        cout<<"m";
        gotoxy (30,6);
        cout<<"D";
        gotoxy (58,6);
        cout<<"(W)";
        int wallcounter = 1;
        while ( monstersAlive != false && wallcounter == 1 )
        {
        gotoxy (30,16);
        cout<<"XXX";
        wallcounter=2;
    }
              }     
         void steveDead()
         {
                  stevelife=0;
         while ( billlife == 1 )
         {
         system ("cls");
         cout<<"You killed Steve Jobz!"<<endl;
         system ("PAUSE");
         ceoOptions();
         }
         while ( billlife == 0 )
         {
              system ("cls");
               cout<<"You Killed Bill Gates!"<<endl;
               system ("PAUSE");
               ceoDead();
               }    
              
              }
    void billAttack()
    {
         while ( billlife == 1 )
         {
       system ("cls");
       cout<<"Bill attacks you!"<<endl;
       Sleep (1000);
       int damage = (rand()%2)+3-defence;
       cout<<"He does "<<damage<<" damage."<<endl;
       hp=hp-damage;
       system ("PAUSE");
      if ( hp <= 0 )
      {
       system ("cls");
       youDead();
      }
      else
      {
       system ("cls");
       steveAttack();
      }}
      while ( billlife == 0 )
      {
            steveAttack();
            }
    }  
    void steveAttack()
    {
         while ( stevelife == 1 )
         {
       system ("cls");
       cout<<"Steve attacks you!"<<endl;
       Sleep (700);
       int damage = (rand()%17)+3-defence;
       cout<<"He does "<<damage<<" damage."<<endl;
       hp=hp-damage;
       system ("PAUSE");
      if ( hp <= 0 )
      {
       system ("cls");
       youDead();
      }
      else
      {
       system ("cls");
       ceoOptions();
      }}
      while ( stevelife == 0 )
      {
            ceoOptions();
            }
    } 
    
    
    int main(int argc, char *argv[])
    {
        system("title Savior's of Death");
        system("color 09");
        char gameMove = 'k';
        string map[24] = map1;
    
    
    //    system("cls");
    resetMap();
    
        while (gameMove != 'q')
        {
           //system("cls");
    
    
           gameMove = getch();
    
           // moves left with the "a" key or 4 on the numberpad
           if ((((gameMove == 'a') || (gameMove == '4') || (gameMove == 'j'))) && (!checkWall(map, c-1, r))) {
              if (c > 0) {
                  charClear(c, r);
                  c--;
                  charMove(c, r);
                  demonWall(map);
                  ceoWall(map);
                  checkDemon();
                  checkCEO();
                  
              }
           }
           // moves down with the "s" key or 2 on the numberpad
           if ((((gameMove == 's') || (gameMove == '2') || (gameMove == 'k'))) && (!checkWall(map, c, r+1))) {
              if (r < 23   ) {
                  charClear(c, r);
                  r++;
                  charMove(c, r);
                  demonWall(map);
                  ceoWall(map);
                     checkDemon();         
                  checkCEO();
              }
                  
           }
    
           // moves right with the "d" key or 6 on the numberpad
           if ((((gameMove == 'd') || (gameMove == '6') || (gameMove == 'l'))) && (!checkWall(map, c+1, r)))
           {
              if (c < 78)
              {
                  charClear(c, r);
                  c++;
                  charMove(c, r);
                  demonWall(map);
                  ceoWall(map);
                  checkDemon(); 
                  checkCEO();             
                  }
            
    
      	     }
    
           
    
           // moves up with the "w" key or 8 on the numberpad
           if ((((gameMove == 'w') || (gameMove == '8') || (gameMove == 'i'))) && (!checkWall(map, c, r-1)))
           {
              if (r > 0)
              {
                  charClear(c, r);
                  r--;
                  charMove(c, r);
                  demonWall(map);
                  ceoWall(map);
                  checkDemon(); 
                  checkCEO();             
              }
           }
    
           // moves lower left with 1 on the numberpad
           if ((gameMove == '1') && (!checkWall(map, c-1, r+1)))
           {
              if ((r < 23) && (c > 0))
              {
                  charClear(c, r);
                  c--;
                  r++;
                  charMove(c, r);
                  demonWall(map);
                  ceoWall(map);
                     checkDemon();     
                     checkCEO();      
              }
           }
    
           // moves lower right with 3 on the numberpad
           if ((gameMove == '3') && (!checkWall(map, c+1, r+1)))
           {
              if ((r < 23) && (c < 78)) {
                  charClear(c, r);
                  c++;
                  r++;
                  charMove(c, r);
                  demonWall(map);
                  ceoWall(map);
                     checkDemon(); 
                     checkCEO();          
                 }
           }
    
           // moves upper left with 7 on the numberpad
           if ((gameMove == '7') && (!checkWall(map, c-1, r-1)))
           {
              if ((r > 0) && (c > 0)) {
                  charClear(c, r);
                  c--;
                  r--;
                  charMove(c, r);
                  demonWall(map);
                  ceoWall(map);
        checkDemon();
        checkCEO();
                 }
           }
    
           // moves upper right with 9 on the numberpad
           if ((gameMove == '9') && (!checkWall(map, c+1, r-1)))
           {
              if ((r > 0) && (c < 78)) {
                  charClear(c, r);
                  c++;
                  r--;
                  charMove(c, r);
                  demonWall(map);
                  ceoWall(map);
                  checkDemon();
                 checkCEO();
                 }
           }
    
        }
        //system("PAUSE");
        return EXIT_SUCCESS;
    }

  2. #2
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    It's written in plain English.

    Here's how you prototypes your function, which is what the compiler is expecting:
    Code:
    bool checkFire();
    When the compiler finds you calling checkFire in your code, it's expecting a function call with no arguments.

    How many arguments does your function implementation take?
    Code:
    bool checkFire(string map[], int x, int y)
    And here's how you call it
    Code:
    checkFire(map, tempm2c, tempm2r)
    Everything's gotta match up there...from prototype, to implementation, to usage.

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    23
    rags_to_riches is right, also I didn't read the code but I noticed an abundance of 'random2 == ??'. Use arrays with loops. When it comes time to update this code adding even a single case to random2 will require multiple updates throughout the code.

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,801
    Code:
    #include <conio.h> //required for getch()
    #include <cstdlib>
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    string map1[24] =
           {
    If you're gonna be using std::string objects you should include the <string> header as well.



    Code:
    string map1[24] =
           {
               "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n",
    
    ...
    
    int main(int argc, char *argv[])
    {
        system("title Savior's of Death");
        system("color 09");
        char gameMove = 'k';
        string map[24] = map1;
    You can't assign arrays like that.



    Code:
    void demonWall(string map[])
    {
        srand (time(NULL)); // initialize the randomizer
    
    ...
    
    void ceoWall(string map[])
    {
        srand (time(NULL)); // initialize the randomizer
    In general you should avoid repeatedly calling srand in a program. Your ceoWall/demonWall functions are called within a loop and therefore set/reset the PRNG each time. Call srand once somewhere towards the start of the main function instead.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-15-2004, 03:30 PM
  2. Debugging-Looking in the wrong places
    By JaWiB in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2003, 09:50 PM
  3. Confused: What is wrong with void??
    By Machewy in forum C++ Programming
    Replies: 19
    Last Post: 04-15-2003, 12:40 PM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 11:01 AM
  5. Whats wrong?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 07-14-2002, 01:04 PM

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