Thread: Hello I'm New Here

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    75

    Talking Hello I'm New Here




    Hello Everybody I'm stealth:

    I just started learning C++ but I do have experience in programming (not C++ better not say what though) anyway
    I started a text combat engine and I have problems already
    so I thought I'd post the code and let u guys see and hopefully help me out,dunno what the problem is actually ( like I said I'm new) anyway so far I have it printing the stats of the players health but then I want it to print who starts the match according to who is the fastest of the players , sorry if this is confusing but
    I'll post the code so that it's more clear what I have done

    #include <iostream.h>
    #include <stdlib.h>


    int main()
    {

    // place a information screen at the very top
    cout << "+================================================ ==================+" << endl;
    cout << "+ +" << endl;
    cout << "+ Text Combat Editor Written By Stealth +" << endl;
    cout << "+ +" << endl;
    cout << "+================================================ ==================+" << endl;

    // provide spaces before continuing to print anything else
    cout << "\n";
    cout << "\n";






    //=========================== declare all variables here =======================

    // make a short int to store the value of the character stats
    short int enemy_health = 100 , player_health = 100;
    short int enemy_size = 1 , player_size = 1;
    short int enemy_speed = (enemy_health - enemy_size);
    short int player_speed = (player_health - 50);//player_size);


    // symbolic variables for use of evaluation outcome for all equations
    short int use = 1;
    short int not = 0;


    // names for the characters variables as char
    char player[7] = "Player";
    char enemy[6] = "Enemy";

    // values which will be checked to determine who starts the match
    int player_start;
    int enemy_start = use;

    //==================== variable declaration ends here ==========================



    //========================= print character stats ==============================

    cout << "STATS :\n";
    cout << "\n";
    cout << "Player Health = " << player_health << endl;
    cout << "Enemy Health = " << enemy_health << endl;
    cout << "\n";
    cout << "\n";

    //======================= print character stats ends here ======================




    //============ speed check ( determining who starts the match ) ===============


    // check if player is faster then the enemy
    if (player_speed > enemy_speed)
    // set player start to use
    player_start = use;


    // check if enemy is faster then player
    if (enemy_speed > player_speed)
    enemy_start = use;


    // check if enemy and player speeds are equal,if they are player has the right to start
    if (player_speed = enemy_speed)
    player_start = use;


    if (player_start = use)
    enemy_start = not;
    else
    if (enemy_start = use)
    player_start = not;


    //=========================== speed check ends here ============================



    //=================== print who starts the match ===============================

    if (player_start = use)
    cout << "Player is faster\n" << "You will start the match\n";
    else
    if (enemy_start = use)
    cout << "Enemy is faster \n" << "He will start the match \n";

    //=================== print who starts match ends here =========================


    system("PAUSE");
    return 0;
    }



    what I actually done here was test it to see if it would print

    "Enemy Is Faster "
    "He Will Start The Match"

    But it always seems to print


    "Player Is Faster"
    "You Will Start The Match"


    plz can somebody plz help me out here



    cheers


    stealth

  2. #2
    Anti-Terrorist
    Join Date
    Aug 2001
    Location
    mming, Game DevelopmentCSR >€&<>&2Minimization of boolean functions, PROM,PLA design >‚&0>ƒ&WA, USA guitar, dogsCommercial Aviation >„&>>…&USAProgramming
    Posts
    742
    Code:
    if (player_speed = enemy_speed)
    In places where you tested conditions you used an assignment instead of a logical operator.

    Also you could use 'else if' statements more clearly by putting them in blocks.
    Code:
    // check if player is faster then the enemy 
    if (player_speed > enemy_speed) 
    // set player start to use 
    player_start = use; 
    
    
    // check if enemy is faster then player 
    if (enemy_speed > player_speed) 
    enemy_start = use; 
    
    
    // check if enemy and player speeds are equal,if they are player has the right to start 
    if (player_speed = enemy_speed) 
    player_start = use;
    Could become
    Code:
    // check if player is faster then the enemy 
    if (player_speed >= enemy_speed ) 
    {
    // set player start to use 
    player_start = use; 
    }
    else
    {
    // enemy is faster then player 
    enemy_start = use; 
    }
    I compile code with:
    Visual Studio.NET beta2

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    75

    thanx

    Oh ok man thanks alot I'll try that now , I though tsomething like that just couldnt put it into code
    thanks again man

    cheers

    stealth

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    75

    YES!!!!!!!!!!!!




    YES!!!!!!!!!!! I got it but I had to take away this

    if (player_start = use)
    cout << "Player is faster\n" << "You will start the match\n";
    else
    if (enemy_start = use)
    cout << "Enemy is faster \n" << "He will start the match \n";




    and add the cout to the speed check part like this


    // check if player is faster then the enemy
    if (player_speed >= enemy_speed )
    {
    // set player start to use
    player_start = use;
    cout << "Player is faster\n" << "You will start the match\n";
    }
    else
    {
    // enemy is faster then player
    enemy_start = use;
    cout << "Enemy is faster \n" << "He will start the match \n";
    }




    cool


    thanks again man really this is really cool


    cheers


    stealth

  5. #5
    aurë entuluva! mithrandir's Avatar
    Join Date
    Aug 2001
    Posts
    1,209
    You ripped off my bloody name!

  6. #6
    Registered User Generator's Avatar
    Join Date
    Aug 2001
    Posts
    238
    If anybody makes a [Generator] alias they will feel the full wrath of my member status.
    What's a matter you no like peppi?

Popular pages Recent additions subscribe to a feed