Page 2 of 4 FirstFirst 1234 LastLast
Results 16 to 30 of 47
  1. #16
    flashlight95's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    12-34 Poopie Street Posts: Over 9000!
    Posts
    127
    Reputation
    10
    Thanks
    15
    Also, if you don't want it to go over 100%

    Code:
    	if(pages > total)
    	{
                 cout << "Blah blah";
         } else {

  2. #17
    DBag4Life69's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    290
    Reputation
    13
    Thanks
    59
    My Mood
    Twisted
    Quote Originally Posted by flashlight95 View Post
    Also, if you don't want it to go over 100%

    Code:
    	if(pages > total)
    	{
                 cout << "Blah blah";
         } else {
    I just learned about the if and else if and while if else if and all them loops. lolz.
    I could do that, which I will end up making the code more complex, just as a way to test my skills I am learning, but as of the pause, I haven't learned that yet. How would I do that?

  3. #18
    flashlight95's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    12-34 Poopie Street Posts: Over 9000!
    Posts
    127
    Reputation
    10
    Thanks
    15
    system("PAUSE"); works

    but

    cin.get(); is probably better

  4. #19
    tahha's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    my keyboard or my bed
    Posts
    122
    Reputation
    9
    Thanks
    3
    Quote Originally Posted by mmbob View Post
    Definitely not, you NEVER use void main();
    really cus im taking a Comp sci class and im in the 3rd level of it and if we use int main we get kicked out of class for good.
    we must use void main
    our teacher is also the same guy who helps IBM Dell and microsoft
    but i guess you kno more then him so ok....you win...dont use void main use int main and let your program end for no reason and then wonder y its doing so
    (BTW: My Name Is PowerHouse On Other Forums)

    Click this to get PowerHouse Private!

  5. #20
    scimmyboy's Avatar
    Join Date
    Jan 2008
    Gender
    male
    Location
    https://mpgh.net MPGHCash: $442,596,199
    Posts
    5,645
    Reputation
    26
    Thanks
    896
    My Mood
    Happy
    Class:
    Code:
    #include <iostream>
    #include <ctime>
    
    class Player1
    {
    public:
    	int Health;
    	Player1();
    
    	int Attack();
    	int Attack1();
    	int Attack2();
    	int Burn(int damage);
    	int Heal();
    
    	void Damage(int damage);
    	void DisplayHP();
    
    };
    
    class Monster1
    {
    public:
    	int Health;
    	Monster1();
    
    	int RandomAttack();
    	void Damage(int damage);
    	void DisplayHP();
    
    };
    
    class Monster2
    {
    public:
    	int Health;
    	Monster2();
    
    	int RandomAttack();
    	void Damage(int damage);
    	void DisplayHP();
    
    };
    
    class Monster3
    {
    public:
    	int Health;
    	Monster3();
    
    	int RandomAttack();
    	void Damage(int damage);
    	void DisplayHP();
    
    };
    Main:
    Code:
    int main()
    {
    	srand( (unsigned) time(0) );
        Instructions();
        return 0;
    }
    
    void Instructions()
    {
        string exit;
    
        cout << "Do you want to start?: ";
        cin >> exit;
        if (exit == "no")
        {
        }
        else if (exit == "yes")
        {
            system ("cls");
    
            cout << "Attack the monster!" << endl 
    			 << "Press 1 to use assault rifle (weak/accurate)" << endl
    			 << "Press 2 to big boom (stronger/less accurate)" << endl 
    			 << "Press 3 to heal (You can't attack)" << endl;
    
            system("pause");
           
            pick();
    
            system("pause");
            system ("cls");
        }
    
    	else if (exit == "mudkipz")
    	{
    		EnableMenuItem(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE , MF_GRAYED);
    		DrawMenuBar(GetConsoleWindow());
    
    		intro();
    	}
    }
    
    void pick()
    {
        string pick;
    
        cout << "Which monster do you want to fight? (Truck, Tank, Plane): ";
        cin >> pick;
    
        if (pick == "Truck")
        {
            system("cls");
            Combat1();
        }
        else if (pick == "Tank")
        {
            system("cls");
            Combat2();
        }
    	else if (pick == "Plane")
    	{
    		system ("cls");
    		Combat3();
    	}
    
    }
    
    
    Player1::Player1()
    {
        Health = 100;
    }
    
    Monster1::Monster1()
    {
        Health = 500;
    }
    
    
    Monster2::Monster2()
    {
        Health = 1000;
    }
    
    Monster3::Monster3()
    {
        Health = 200;
    }
    
    void Player1::DisplayHP()
    {
        cout << "Your HP: " << Health << endl;
    }
    
    void Monster1::DisplayHP()
    {
        cout << "Truck's HP: " << Health << endl;
    }
    
    
    void Monster2::DisplayHP()
    {
        cout << "Tank's HP: " << Health << endl;
    }
    
    void Monster3::DisplayHP()
    {
        cout << "Plane's HP: " << Health << endl;
    }
    
    void Player1::Damage(int damage)
    {
        Health -= damage;
    }
    
    void Monster1::Damage(int damage)
    {
        Health -= damage;
    }
    
    
    void Monster2::Damage(int damage)
    {
        Health -= damage;
    }
    
    void Monster3::Damage(int damage)
    {
        Health -= damage;
    }
    
    int Player1::Heal()
    {
        int randdamage;
        randdamage = -(rand() % 20 + 1);
    
        cout << "You healed: " << -(randdamage) << endl;
        return randdamage;
    }
    
    int Player1::Attack()
    {
        int randdamage;
        randdamage = rand() % 4 + 20;
    
        cout << "You dealt: " << randdamage << " damage" << endl;
        return randdamage;
    }
    
    int Player1::Attack1()
    {
        int randdamage;
        randdamage = rand() % 100 + 5;
    
        cout << "You dealt: " << randdamage << " damage" << endl;
        return randdamage;
    }
    
    int Player1::Attack2()
    {
        int randdamage;
        randdamage = rand() % 4 + 10;
    
        cout << "You dealt: " << randdamage << " damage" << endl;
        return randdamage;
    }
    
    
    int Monster1::RandomAttack()
    {
        int randdamage;
        int randattack;
    
        randattack = rand() % 2 + 1;
    
        if (randattack == 1)
        {
            randdamage = rand() % 10 + 5;
        }
        else if (randattack == 2)
        {
            randdamage = rand() % 20 + 5;
        }
       
        cout << "You received: " << randdamage << " damage" << endl;
        return randdamage;
    }
    
    
    int Monster2::RandomAttack()
    {
        int randdamage;
        int randattack;
    
        randattack = rand() % 2 + 1;
    
        if (randattack == 1)
        {
            randdamage = rand() % 5 + 5;
        }
        else if (randattack == 2)
        {
            randdamage = rand() % 8 + 5;
        }
       
        cout << "You received: " << randdamage << " damage" << endl;
        return randdamage;
    }
    
    int Monster3::RandomAttack()
    {
        int randdamage;
        int randattack;
    
        randattack = rand() % 2 + 1;
    
        if (randattack == 1)
        {
            randdamage = rand() % 5 + 5;
        }
        else if (randattack == 2)
        {
            randdamage = rand() % 50 + 5;
        }
       
        cout << "You received: " << randdamage << " damage" << endl;
        return randdamage;
    }
    
    void Combat1()
    {
        int choice;
    
        Player1 User;
        Monster1 Monster;
    
        User.DisplayHP();
        Monster.DisplayHP();
    
        while (User.Health > 0)
        {
            cout << "Press 1 to use assault rifle (weak/accurate)" << endl
    			 << "Press 2 to big boom (stronger/less accurate)" << endl 
    			 << "Press 3 to heal (You can't attack)" << endl;
    		cin >> choice;
            switch (choice)
            {               
            case 1:
                Monster.Damage(User.Attack());
                Monster.DisplayHP();
                User.Damage(Monster.RandomAttack());
                User.DisplayHP();
                break;
    
            case 2:
                Monster.Damage(User.Attack1());
                Monster.DisplayHP();
                User.Damage(Monster.RandomAttack());
                User.DisplayHP();
                break;
    
            case 3:
                User.Damage(User.Heal());
                Monster.DisplayHP();
                User.Damage(Monster.RandomAttack());
                User.DisplayHP();
    			break;
    
    		case 1337:
    			Monster.Damage(1000000);
    			Monster.DisplayHP();
    			User.DisplayHP();
    			cout << "you cheater" << endl;
    			break;
    
            }
    
            if (User.Health <= 0)
            {
                MessageBox(NULL, TEXT("Game Over GG"), TEXT("Game Over GG"), MB_OK);
    		
    			system("pause");
                system("cls");
                Instructions();
                break;
            }
    
            if (Monster.Health <= 0)
            {
    			MessageBox(NULL, TEXT("You ween"), TEXT("You ween"), MB_OK);
                cout << "You ween" << endl;
                system("pause");
                system("cls");
                Instructions();
                break;
            }
        }
    }
    
    void Combat2()
    {
        int choice;
    
        Player1 User;
        Monster2 Tank;
    
        User.DisplayHP();
        Tank.DisplayHP();
    
        while (User.Health > 0)
        {
            cout << "Press 1 to use assault rifle (weak/accurate)" << endl
    			 << "Press 2 to big boom (stronger/less accurate)" << endl 
    			 << "Press 3 to heal (You can't attack)" << endl;
    
    		cin >> choice;
            switch (choice)
            {               
            case 1:
                Tank.Damage(User.Attack());
                Tank.DisplayHP();
                User.Damage(Tank.RandomAttack());
                User.DisplayHP();
                break;
    
            case 2:
                Tank.Damage(User.Attack1());
                Tank.DisplayHP();
                User.Damage(Tank.RandomAttack());
                User.DisplayHP();
                break;
    
            case 3:
                User.Damage(User.Heal());
                Tank.DisplayHP();
                User.Damage(Tank.RandomAttack());
                User.DisplayHP();
    			break;
    
    		case 4:
    			Tank.Damage(User.Attack2());
    			Tank.DisplayHP();
    			User.Damage(Tank.RandomAttack());
    			User.DisplayHP();
    			break;
    
    		case 1337:
    			Tank.Damage(1000000);
    			Tank.DisplayHP();
    			User.DisplayHP();
    			cout << "you cheater" << endl;
    			break;
            }
    
            if (User.Health <= 0)
            {
                MessageBox(NULL, TEXT("Game Over GG"), TEXT("Game Over GG"), MB_OK);
                system("pause");
                system("cls");
                Instructions();
                break;
            }
            if (Tank.Health <= 0)
            {
                MessageBox(NULL, TEXT("You ween"), TEXT("You ween"), MB_OK);
                system("pause");
                system("cls");
                Instructions();
                break;
            }
        }
    }
    
    void Combat3()
    {
        int choice;
    
        Player1 User;
        Monster3 Plane;
    
        User.DisplayHP();
        Plane.DisplayHP();
    
        while (User.Health > 0)
        {
            cout << "Press 1 to use assault rifle (weak/accurate)" << endl
    			 << "Press 2 to big boom (stronger/less accurate)" << endl 
    			 << "Press 3 to heal (You can't attack)" << endl;
    
    		cin >> choice;
            switch (choice)
            {               
            case 1:
                Plane.Damage(User.Attack());
                Plane.DisplayHP();
                User.Damage(Plane.RandomAttack());
                User.DisplayHP();
                break;
    
            case 2:
                Plane.Damage(User.Attack1());
                Plane.DisplayHP();
                User.Damage(Plane.RandomAttack());
                User.DisplayHP();
                break;
    
            case 3:
                User.Damage(User.Heal());
                Plane.DisplayHP();
                User.Damage(Plane.RandomAttack());
                User.DisplayHP();
    			break;
    
    		case 4:
    			Plane.Damage(User.Attack2());
    			Plane.DisplayHP();
    			User.Damage(Plane.RandomAttack());
    			User.DisplayHP();
    			break;
    
    		case 1337:
    			Plane.Damage(1000000);
    			Plane.DisplayHP();
    			User.DisplayHP();
    			cout << "you cheater" << endl;
    			break;
            }
    
            if (User.Health <= 0)
            {
                MessageBox(NULL, TEXT("Game Over GG"), TEXT("Game Over GG"), MB_OK);
                system("pause");
                system("cls");
                Instructions();
                break;
            }
    
            if (Plane.Health <= 0)
            {
                MessageBox(NULL, TEXT("You ween"), TEXT("You ween"), MB_OK);
                system("pause");
                system("cls");
                Instructions();
                break;
            }
        }
    }
    hehe. probably should have put the combats into classes, but i did this a long time ago. missing some stuff cuz it would be way too long.

    EDIT: @the noob on top of me. why the hell would the program close randomly because of int main()? ya sure u aint sleepin in class?

  6. #21
    tahha's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    my keyboard or my bed
    Posts
    122
    Reputation
    9
    Thanks
    3
    if you include conio.h then you can use getch();
    to pause it for one char input with out stopping the program for the time
    (BTW: My Name Is PowerHouse On Other Forums)

    Click this to get PowerHouse Private!

  7. #22
    CASHMONEY3's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Location
    Greenville, South Carolina
    Posts
    207
    Reputation
    10
    Thanks
    9
    My Mood
    Asleep
    Quote Originally Posted by DBag4Life69 View Post


    Lolz. I know what you mean.
    Most people aren't very determined.

    I am.

    I am determined to learn C++ as a language, so I can make stuff that I can use for ANYTHING.
    Not just for hacks.

    Now, I know that's what my inspiration WAS to start this determination, but my inspiration changed now.

    But ANYWAYS, I figured I would release that code, since it's proof that I AM in fact learning SOMETHING, cuz I wrote that all on my own.
    nice i believe in you bro im learning it also so we can help each other i have actually made on hack but im trying to get it so it can not dc

  8. #23
    tahha's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    my keyboard or my bed
    Posts
    122
    Reputation
    9
    Thanks
    3
    Quote Originally Posted by DBag4Life69 View Post


    There's a big problem there with how you re-wrote that. :-|
    p hasn't been defined, and pages is also not defined. I know HOW to do that, but no matter what, your code there WILL not work, unless you change a couple of things. ;-)
    yea i noticed i messed up there a bit so im trying to do it now by doing it in my compiler, at first i just wrote it out in the reply box then as i posted i noticed the errors so im rewriting it now i will post back in a minute
    and p was defined in the int calcu as an input (u need to use different names as u pass values thru functions so in main it is pages in the function it is p
    (BTW: My Name Is PowerHouse On Other Forums)

    Click this to get PowerHouse Private!

  9. #24
    DBag4Life69's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    290
    Reputation
    13
    Thanks
    59
    My Mood
    Twisted
    [php]
    // Credits:
    // D-Vid aka Illusionz
    // flashlight95 -- For the idea of usin the if
    #include <iostream>

    int main()
    {
    using namespace std;
    float CppPrimer;
    float total;
    int pages;

    cout << "Enter the total amount of pages that you've read so far: \n\n";
    cin >> pages;
    cout << endl;
    CppPrimer = 1225;
    total = 2501;
    if (pages>total)
    {
    cout << "You input the incorrect value, it has to be less than 2501 pages." << endl;
    system("PAUSE");
    cout << endl;
    }
    else if (pages<total)
    {
    cout << "Percentage outta the C++ Primer Plus: 5th Edition: " << pages / CppPrimer * 100 << "%" << endl;
    cout << "Percentage TOTAL outta all the books: " << pages / total * 100 << "%" << endl;
    system("PAUSE");
    cout << endl;
    }
    else
    {
    cout << "You're DONE learning from those books!" << endl;
    system("PAUSE");
    cout << endl;
    }

    }
    [/php]

    I just added something in there.
    What'ya think so far?
    Last edited by DBag4Life69; 09-25-2010 at 02:59 PM.

  10. #25
    tahha's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    my keyboard or my bed
    Posts
    122
    Reputation
    9
    Thanks
    3
    Quote Originally Posted by DBag4Life69 View Post
    [php]
    // Credits: D-Vid aka Illusionz
    #include <iostream>

    int main()
    {
    using namespace std;
    float CppPrimer;
    float total;
    int pages;

    cout << "Enter the total amount of pages that you've read so far: \n\n";
    cin >> pages;
    cout << endl;
    CppPrimer = 1225;
    total = 2501;
    if (pages>total)
    {
    cout << "You input the incorrect value, it has to be less than 2501 pages." << endl;
    system("PAUSE");
    cout << endl;
    }
    else if (pages<total)
    {
    cout << "Percentage outta the C++ Primer Plus: 5th Edition: " << pages / CppPrimer * 100 << "%" << endl;
    cout << "Percentage TOTAL outta all the books: " << pages / total * 100 << "%" << endl;
    system("PAUSE");
    cout << endl;
    }
    else
    {
    cout << "You're DONE learning from those books!" << endl;
    system("PAUSE");
    cout << endl;
    }

    }
    [/php]I just added something in there.
    What'ya think so far?
    what compiler are you usen.
    the one im usen wont let me use system("PAUSE");
    ever but im usen turbo c++ 3.0 IDE

    also i did this but the funtion still returns nothing

    all tho its the same structure as i use in all my programs
    but im tired its Saturday and i dont want to think to much so i give up on trying it but thats the way i was taught to code by my teacher at school

    Code:
    #include <iostream.h>
    #include <conio.h>
    
    int calcucpp(int p,int CPP){
        int temp;
        temp = p/CPP;
        temp = temp * 100;
        return temp;
    }
    
    void main(){
        clrscr();
        double CppPrimer = 1225;
        double total = 2501;
        int pages;
    
        double temp;
    
        cout<<"Enter the total amount of pages read so far : \n\n";
        cin>>pages;
    
        cout <<"% of CppPrimer "<<calcucpp(pages,CppPrimer)<<endl;
    
        cout <<"% of total pages "<<pages/total * 100<<endl;
        getch();
    }#include <iostream.h>
    #include <conio.h>
    #include <math.h>
    const int CppPrimer = 1225;
    const int total = 2501;
    
    int calcuCPPP(int p){
        int temp;
        temp=(p/CppPrimer)*100;
        return(temp);
    }
    int calcutotal(int p){
        int temp;
        temp = (p/total)*100;
        return(temp);
    }
    
    void main(){
        int pages;
    
        cout<<"Enter the total amount of pages that you've read so far:\n";
        cin>>pages;
        cout<<endl;
    
        cout<<"Percentage outta the C++ Primer Plus: 5th Edition: "<<calcuCPPP(pages)<<"%"<<endl;
        cout<<"Percentage outta all the books: "<<calcutotal(pages)<<"%"<<endl;
        getch();
    }
    (BTW: My Name Is PowerHouse On Other Forums)

    Click this to get PowerHouse Private!

  11. #26
    Stephen's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    Engine.exe
    Posts
    4,689
    Reputation
    184
    Thanks
    1,149
    My Mood
    Aggressive
    Quote Originally Posted by scimmyboy View Post
    Class:
    Code:
    #include <iostream>
    #include <ctime>
    
    class Player1
    {
    public:
    	int Health;
    	Player1();
    
    	int Attack();
    	int Attack1();
    	int Attack2();
    	int Burn(int damage);
    	int Heal();
    
    	void Damage(int damage);
    	void DisplayHP();
    
    };
    
    class Monster1
    {
    public:
    	int Health;
    	Monster1();
    
    	int RandomAttack();
    	void Damage(int damage);
    	void DisplayHP();
    
    };
    
    class Monster2
    {
    public:
    	int Health;
    	Monster2();
    
    	int RandomAttack();
    	void Damage(int damage);
    	void DisplayHP();
    
    };
    
    class Monster3
    {
    public:
    	int Health;
    	Monster3();
    
    	int RandomAttack();
    	void Damage(int damage);
    	void DisplayHP();
    
    };
    Main:
    Code:
    int main()
    {
    	srand( (unsigned) time(0) );
        Instructions();
        return 0;
    }
    
    void Instructions()
    {
        string exit;
    
        cout << "Do you want to start?: ";
        cin >> exit;
        if (exit == "no")
        {
        }
        else if (exit == "yes")
        {
            system ("cls");
    
            cout << "Attack the monster!" << endl 
    			 << "Press 1 to use assault rifle (weak/accurate)" << endl
    			 << "Press 2 to big boom (stronger/less accurate)" << endl 
    			 << "Press 3 to heal (You can't attack)" << endl;
    
            system("pause");
           
            pick();
    
            system("pause");
            system ("cls");
        }
    
    	else if (exit == "mudkipz")
    	{
    		EnableMenuItem(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE , MF_GRAYED);
    		DrawMenuBar(GetConsoleWindow());
    
    		intro();
    	}
    }
    
    void pick()
    {
        string pick;
    
        cout << "Which monster do you want to fight? (Truck, Tank, Plane): ";
        cin >> pick;
    
        if (pick == "Truck")
        {
            system("cls");
            Combat1();
        }
        else if (pick == "Tank")
        {
            system("cls");
            Combat2();
        }
    	else if (pick == "Plane")
    	{
    		system ("cls");
    		Combat3();
    	}
    
    }
    
    
    Player1::Player1()
    {
        Health = 100;
    }
    
    Monster1::Monster1()
    {
        Health = 500;
    }
    
    
    Monster2::Monster2()
    {
        Health = 1000;
    }
    
    Monster3::Monster3()
    {
        Health = 200;
    }
    
    void Player1::DisplayHP()
    {
        cout << "Your HP: " << Health << endl;
    }
    
    void Monster1::DisplayHP()
    {
        cout << "Truck's HP: " << Health << endl;
    }
    
    
    void Monster2::DisplayHP()
    {
        cout << "Tank's HP: " << Health << endl;
    }
    
    void Monster3::DisplayHP()
    {
        cout << "Plane's HP: " << Health << endl;
    }
    
    void Player1::Damage(int damage)
    {
        Health -= damage;
    }
    
    void Monster1::Damage(int damage)
    {
        Health -= damage;
    }
    
    
    void Monster2::Damage(int damage)
    {
        Health -= damage;
    }
    
    void Monster3::Damage(int damage)
    {
        Health -= damage;
    }
    
    int Player1::Heal()
    {
        int randdamage;
        randdamage = -(rand() % 20 + 1);
    
        cout << "You healed: " << -(randdamage) << endl;
        return randdamage;
    }
    
    int Player1::Attack()
    {
        int randdamage;
        randdamage = rand() % 4 + 20;
    
        cout << "You dealt: " << randdamage << " damage" << endl;
        return randdamage;
    }
    
    int Player1::Attack1()
    {
        int randdamage;
        randdamage = rand() % 100 + 5;
    
        cout << "You dealt: " << randdamage << " damage" << endl;
        return randdamage;
    }
    
    int Player1::Attack2()
    {
        int randdamage;
        randdamage = rand() % 4 + 10;
    
        cout << "You dealt: " << randdamage << " damage" << endl;
        return randdamage;
    }
    
    
    int Monster1::RandomAttack()
    {
        int randdamage;
        int randattack;
    
        randattack = rand() % 2 + 1;
    
        if (randattack == 1)
        {
            randdamage = rand() % 10 + 5;
        }
        else if (randattack == 2)
        {
            randdamage = rand() % 20 + 5;
        }
       
        cout << "You received: " << randdamage << " damage" << endl;
        return randdamage;
    }
    
    
    int Monster2::RandomAttack()
    {
        int randdamage;
        int randattack;
    
        randattack = rand() % 2 + 1;
    
        if (randattack == 1)
        {
            randdamage = rand() % 5 + 5;
        }
        else if (randattack == 2)
        {
            randdamage = rand() % 8 + 5;
        }
       
        cout << "You received: " << randdamage << " damage" << endl;
        return randdamage;
    }
    
    int Monster3::RandomAttack()
    {
        int randdamage;
        int randattack;
    
        randattack = rand() % 2 + 1;
    
        if (randattack == 1)
        {
            randdamage = rand() % 5 + 5;
        }
        else if (randattack == 2)
        {
            randdamage = rand() % 50 + 5;
        }
       
        cout << "You received: " << randdamage << " damage" << endl;
        return randdamage;
    }
    
    void Combat1()
    {
        int choice;
    
        Player1 User;
        Monster1 Monster;
    
        User.DisplayHP();
        Monster.DisplayHP();
    
        while (User.Health > 0)
        {
            cout << "Press 1 to use assault rifle (weak/accurate)" << endl
    			 << "Press 2 to big boom (stronger/less accurate)" << endl 
    			 << "Press 3 to heal (You can't attack)" << endl;
    		cin >> choice;
            switch (choice)
            {               
            case 1:
                Monster.Damage(User.Attack());
                Monster.DisplayHP();
                User.Damage(Monster.RandomAttack());
                User.DisplayHP();
                break;
    
            case 2:
                Monster.Damage(User.Attack1());
                Monster.DisplayHP();
                User.Damage(Monster.RandomAttack());
                User.DisplayHP();
                break;
    
            case 3:
                User.Damage(User.Heal());
                Monster.DisplayHP();
                User.Damage(Monster.RandomAttack());
                User.DisplayHP();
    			break;
    
    		case 1337:
    			Monster.Damage(1000000);
    			Monster.DisplayHP();
    			User.DisplayHP();
    			cout << "you cheater" << endl;
    			break;
    
            }
    
            if (User.Health <= 0)
            {
                MessageBox(NULL, TEXT("Game Over GG"), TEXT("Game Over GG"), MB_OK);
    		
    			system("pause");
                system("cls");
                Instructions();
                break;
            }
    
            if (Monster.Health <= 0)
            {
    			MessageBox(NULL, TEXT("You ween"), TEXT("You ween"), MB_OK);
                cout << "You ween" << endl;
                system("pause");
                system("cls");
                Instructions();
                break;
            }
        }
    }
    
    void Combat2()
    {
        int choice;
    
        Player1 User;
        Monster2 Tank;
    
        User.DisplayHP();
        Tank.DisplayHP();
    
        while (User.Health > 0)
        {
            cout << "Press 1 to use assault rifle (weak/accurate)" << endl
    			 << "Press 2 to big boom (stronger/less accurate)" << endl 
    			 << "Press 3 to heal (You can't attack)" << endl;
    
    		cin >> choice;
            switch (choice)
            {               
            case 1:
                Tank.Damage(User.Attack());
                Tank.DisplayHP();
                User.Damage(Tank.RandomAttack());
                User.DisplayHP();
                break;
    
            case 2:
                Tank.Damage(User.Attack1());
                Tank.DisplayHP();
                User.Damage(Tank.RandomAttack());
                User.DisplayHP();
                break;
    
            case 3:
                User.Damage(User.Heal());
                Tank.DisplayHP();
                User.Damage(Tank.RandomAttack());
                User.DisplayHP();
    			break;
    
    		case 4:
    			Tank.Damage(User.Attack2());
    			Tank.DisplayHP();
    			User.Damage(Tank.RandomAttack());
    			User.DisplayHP();
    			break;
    
    		case 1337:
    			Tank.Damage(1000000);
    			Tank.DisplayHP();
    			User.DisplayHP();
    			cout << "you cheater" << endl;
    			break;
            }
    
            if (User.Health <= 0)
            {
                MessageBox(NULL, TEXT("Game Over GG"), TEXT("Game Over GG"), MB_OK);
                system("pause");
                system("cls");
                Instructions();
                break;
            }
            if (Tank.Health <= 0)
            {
                MessageBox(NULL, TEXT("You ween"), TEXT("You ween"), MB_OK);
                system("pause");
                system("cls");
                Instructions();
                break;
            }
        }
    }
    
    void Combat3()
    {
        int choice;
    
        Player1 User;
        Monster3 Plane;
    
        User.DisplayHP();
        Plane.DisplayHP();
    
        while (User.Health > 0)
        {
            cout << "Press 1 to use assault rifle (weak/accurate)" << endl
    			 << "Press 2 to big boom (stronger/less accurate)" << endl 
    			 << "Press 3 to heal (You can't attack)" << endl;
    
    		cin >> choice;
            switch (choice)
            {               
            case 1:
                Plane.Damage(User.Attack());
                Plane.DisplayHP();
                User.Damage(Plane.RandomAttack());
                User.DisplayHP();
                break;
    
            case 2:
                Plane.Damage(User.Attack1());
                Plane.DisplayHP();
                User.Damage(Plane.RandomAttack());
                User.DisplayHP();
                break;
    
            case 3:
                User.Damage(User.Heal());
                Plane.DisplayHP();
                User.Damage(Plane.RandomAttack());
                User.DisplayHP();
    			break;
    
    		case 4:
    			Plane.Damage(User.Attack2());
    			Plane.DisplayHP();
    			User.Damage(Plane.RandomAttack());
    			User.DisplayHP();
    			break;
    
    		case 1337:
    			Plane.Damage(1000000);
    			Plane.DisplayHP();
    			User.DisplayHP();
    			cout << "you cheater" << endl;
    			break;
            }
    
            if (User.Health <= 0)
            {
                MessageBox(NULL, TEXT("Game Over GG"), TEXT("Game Over GG"), MB_OK);
                system("pause");
                system("cls");
                Instructions();
                break;
            }
    
            if (Plane.Health <= 0)
            {
                MessageBox(NULL, TEXT("You ween"), TEXT("You ween"), MB_OK);
                system("pause");
                system("cls");
                Instructions();
                break;
            }
        }
    }


    hehe. probably should have put the combats into classes, but i did this a long time ago. missing some stuff cuz it would be way too long.

    EDIT: @the noob on top of me. why the hell would the program close randomly because of int main()? ya sure u aint sleepin in class?
    Thats from thatr Guy in youtube. Or its from C++ for Dummies

  12. #27
    scimmyboy's Avatar
    Join Date
    Jan 2008
    Gender
    male
    Location
    https://mpgh.net MPGHCash: $442,596,199
    Posts
    5,645
    Reputation
    26
    Thanks
    896
    My Mood
    Happy
    Quote Originally Posted by Stephen View Post


    Thats from thatr Guy in youtube. Or its from C++ for Dummies
    uhm no its not. those vids and C++ for dummies is bullshit

  13. #28
    DBag4Life69's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    290
    Reputation
    13
    Thanks
    59
    My Mood
    Twisted
    Quote Originally Posted by tahha View Post
    what compiler are you usen.
    the one im usen wont let me use system("PAUSE");
    ever but im usen turbo c++ 3.0 IDE

    also i did this but the funtion still returns nothing

    all tho its the same structure as i use in all my programs
    but im tired its Saturday and i dont want to think to much so i give up on trying it but thats the way i was taught to code by my teacher at school

    Code:
    #include <iostream.h>
    #include <conio.h>
    
    int calcucpp(int p,int CPP){
        int temp;
        temp = p/CPP;
        temp = temp * 100;
        return temp;
    }
    
    void main(){
        clrscr();
        double CppPrimer = 1225;
        double total = 2501;
        int pages;
    
        double temp;
    
        cout<<"Enter the total amount of pages read so far : \n\n";
        cin>>pages;
    
        cout <<"% of CppPrimer "<<calcucpp(pages,CppPrimer)<<endl;
    
        cout <<"% of total pages "<<pages/total * 100<<endl;
        getch();
    }#include <iostream.h>
    #include <conio.h>
    #include <math.h>
    const int CppPrimer = 1225;
    const int total = 2501;
    
    int calcuCPPP(int p){
        int temp;
        temp=(p/CppPrimer)*100;
        return(temp);
    }
    int calcutotal(int p){
        int temp;
        temp = (p/total)*100;
        return(temp);
    }
    
    void main(){
        int pages;
    
        cout<<"Enter the total amount of pages that you've read so far:\n";
        cin>>pages;
        cout<<endl;
    
        cout<<"Percentage outta the C++ Primer Plus: 5th Edition: "<<calcuCPPP(pages)<<"%"<<endl;
        cout<<"Percentage outta all the books: "<<calcutotal(pages)<<"%"<<endl;
        getch();
    }
    [IMG]https://i33.photobucke*****m/albums/d55/y_owns_you/VisualStudio2010.png[/IMG]

  14. #29
    Crash's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    JAville
    Posts
    2,881
    Reputation
    163
    Thanks
    3,291
    My Mood
    Sleepy
    No need for that total variable just wasting memory. Change it to pages < 2501

  15. #30
    tahha's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    my keyboard or my bed
    Posts
    122
    Reputation
    9
    Thanks
    3
    Quote Originally Posted by scimmyboy View Post
    Class:
    EDIT: @the noob on top of me. why the hell would the program close randomly because of int main()? ya sure u aint sleepin in class?
    hey dick can it

    the return 0; he was missing would crash if he had a longer program ive done it before and ended up losing the work.

    if you have

    Code:
    int main(){
    //lots of code here
    }
    then it can crash

    but
    Code:
    int main(){
    cout<<"Hey";
    }
    theres no need for it cus the program ends before theres a chance for it to lose the track of main

    as for
    Code:
    void main(){
    //code here
    }
    its not trying to return or look for the return of the value of main
    so it wouldnt have an issue at all
    if you would get your head out of the books telling you the wrong information and learn the RIGHT way you would see this.

    Quote Originally Posted by DBag4Life69 View Post


    [IMG]https://i33.photobucke*****m/albums/d55/y_owns_you/VisualStudio2010.png[/IMG]
    OH your usen the vc well no wonder your able to use int main and system("PAUSE");

    that version of c++ is dulled down for the easy of use

    if you use an older compiler it will make it alot harder to get errors fixed and make you really learn the syntax of c++ so you dont make errors as much

    vc++ pretty much tells you exactly where the error is

    my compiler will tell you the line and the error not that your missing a ";" at line 12 col 33
    but "unexpected end of line at line 12"
    Last edited by tahha; 09-25-2010 at 03:09 PM.
    (BTW: My Name Is PowerHouse On Other Forums)

    Click this to get PowerHouse Private!

Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Hey i want to learn to make with c++ code a pb proof wh please help
    By xaris in forum Call of Duty Modern Warfare Help
    Replies: 8
    Last Post: 05-05-2010, 10:57 AM
  2. CS 1.6 VAC2 proof hacks AND cheat death hacks
    By Brunogol in forum General Game Hacking
    Replies: 28
    Last Post: 12-18-2006, 08:26 PM
  3. Where could I learn C++? (Beginner, and Advanced stuff)
    By TsumikiriX in forum C++/C Programming
    Replies: 8
    Last Post: 07-19-2006, 08:11 PM
  4. Learn Hacking
    By Loler in forum Hack Requests
    Replies: 2
    Last Post: 01-22-2006, 03:20 PM
  5. Looking to learn.
    By SadisticGrin in forum Hack Requests
    Replies: 1
    Last Post: 01-15-2006, 06:57 PM