Thread: Whats my problem here?

  1. #16
    Registered User
    Join Date
    May 2006
    Posts
    35
    oh nevermind sorry

  2. #17
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Not a problem, this seems like a nifty project.

    If I may, can I suggest you making the Player and Enemy a couple of classes? It will work out to be easier for you in the long run, because you can make attack functions, and just call those, minimizing the risk of buggy code and making the project easier to maintain.

    Plus it'll be easy to incorporate magic or whatever.

    When you get around to it.

  3. #18
    Registered User
    Join Date
    May 2006
    Posts
    35
    Quote Originally Posted by citizen
    Not a problem, this seems like a nifty project.

    If I may, can I suggest you making the Player and Enemy a couple of classes? It will work out to be easier for you in the long run, because you can make attack functions, and just call those, minimizing the risk of buggy code and making the project easier to maintain.

    Plus it'll be easy to incorporate magic or whatever.

    When you get around to it.
    yeah no problem it would probally be easier if we didnt through some other means than on here but yeah that would be great. What im working on now is just like the prototype, im still learning c++ but i would like to turn this in to and actuall word based game and eventually even more but yeah hit me up.

    [email protected]
    and if you just want to discuss it for now sebastionv3 is my aim im on now

  4. #19
    Registered User
    Join Date
    May 2006
    Posts
    35
    i dont understand this one, its working the program runs but not all of the code runs. it states the first two lines then quits out on me.

    Code:
    #include <iostream>
    #include <cstdlib>
    #include <cstring>
    #include <time.h>
    
    
    using namespace std;
    
    string Command;
    
    struct User
    {
           int UHP; // Users Current Hit Points
           int max_UHP; // Users Maximum Hit Points
    };
    struct Challenger
    {
           int CHP; // Challengers Hit Points
           int max_CHP; // Challengers Maximum Hit Points
    };
    int main()
    {
        srand( time(NULL) );
        User Player;
        Challenger Enemy;
        
        Player.max_UHP = 100;
        Player.UHP = 100;
        Enemy.max_CHP = 100;
        Enemy.CHP = 100;
        int UATK = rand()%20; // Users Attack points
        int CATK = rand()%15; // Challengers Attack points
    
        cout<<"As your walking down a path a cloaked swordsman ambushes you.\n";
        cout<<"He then challenges you to a fight and you humbly accept.\n";
        cout<<"You can Attack.\n";
        cin>> Command;
        cin.ignore();
        if ( Command == "Attack" || Command == "attack" ) { Enemy.CHP-=UATK;
        cout<<"You took out "<< UATK <<" hp.\n"; }
        cout<<"The challenger has "<< Enemy.CHP <<" hp left.\n";
        cin.get();
        cout<<"The Challenger attacks.\n";
        Player.UHP-=CATK;
        cout<<"He does "<< CATK <<" damage, leaving you with "<< Player.UHP <<" hp.\n";
        cin.get();
        
        while ( Player.UHP > 0 || Enemy.CHP > 0 ) {
                  cout<<"You can Attack.\n";
                  cin>> Command;
                  cin.ignore();
                  if ( Command == "Attack" || Command == "attack" ) { Enemy.CHP-=UATK;
                  cout<<"You took out "<< UATK <<" hp.\n"; }
                  cout<<"The challenger has "<< Enemy.CHP <<" hp left.\n";
                  cin.get();
                  cout<<"The Challenger attacks.\n";
                  Player.UHP-=CATK;
                  cout<<"He does "<< CATK <<" damage, leaving you with "<< Player.UHP <<" hp.\n";
                  cin.get();
                  }
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM