Thread: help

  1. #1
    |<o>| <--cyclopse LouDu's Avatar
    Join Date
    Mar 2003
    Posts
    137

    help

    ok i am trying to have it so i can have a typeing effect as the intro before the game, and i cant seem to get it to work heres my code


    Code:
    #include <conio.h>
    #include <iostream>
    #include <stdlib.h>
    #include <ctime>
    #include <iomanip.h>
    #include <windows.h>
    #include <cstdlib>
    #include <cstring>
    #include <stdio.h>
    #include <fstream.h>
    #include <time.h>
    
    int RandInt(int a,int b)
    {
    return a + rand() % (b - a + 1);
    }
    
    using namespace std;
    
    int User_Health = 400;
    int User_Max_Health = 400;
    int User_Level = 1;
    int User_Potions = 10;
    int User_Exp = 0;
    int Next_Level = 300;
    int User_Gold = 0;
    int User_Attack;
    
    int Q = 0;
    int USE_POTION;
    int Y;
    
    int User_Location_X = 0;
    int User_Location_Y = 0;
    int chalace = 0;
    int septor = 0;
    int end_game = 100;
    
    char input;
    
    int battle = 1;
    
    int knight_Health = 200;
    int knight_Max_Health = 200;
    int knight_Gold = 60;
    int knight_Exp = 60;
    
    void introtext(char* letter) {
    cout << letter;
    Sleep(40);
    }
    
    
    
    int introtext()
    {
    Sleep(2000);
    gotoxy(34,10);
    introtxt("L");
    introtxt("U");
    introtxt("D");
    introtxt("L");
    introtxt("O");
    introtxt("W");
    
    }
    
    
    int main()
    {
    
            do
            {
    
                    system ("cls");
    
            if(User_Exp >= Next_Level)
                    {
                    Next_Level = Next_Level * 2;
                    User_Max_Health = User_Max_Health + 20;
                    User_Level = User_Level++;
                    User_Health = User_Max_Health;
                    }
    
            srand(time(NULL));
            int Potion_Heal = RandInt(10,55);
            int x = RandInt(1, 100);
            int knight_Attack = RandInt(21,44);
            int User_Attack = RandInt(31,55);
            int knight_Exp = RandInt(30,70);
            int knight_Gold = RandInt(1,3);
    
    
            User_Attack = (User_Attack * User_Level) * 2;
            cout << "-----------------------------------------------------\n";
            cout << "Ludlow                 To Test Your Wits and Strength\n\n";
            cout << "\nLeaving the gates of Ludlow, the guards surround the \n";
            cout << "land, you will die unless you fight for survivol. Slay \n";
            cout << "the Black Knights and collect the 15 jewls lost across\n";
            cout << "the land and return to the Royal Family of Ludlow.\n\n";
            cout << "Attack     =  A      Quit  =  Q\n";
            cout << "Use Potion =  U  \n\n";
    
            cout << "Health: " << User_Health << "/" << User_Max_Health << "      Level: " << User_Level << "\n";
            cout << "Exp: "<<User_Exp<<"               Exp to next level: "<<Next_Level<<"\n";
            cout << "Gold: "<<User_Gold<<"              Potions: "<<User_Potions << "\n";
            cout << "-----------------------------------------------------\n";
    
    
    	if (User_Location_Y == 50)
    	{
    		cout <<"You have reached the valley wall\n";
    		User_Location_Y = User_Location_Y--;
    		getch();
    	}
    
    	else if (User_Location_Y == -50)
    	{
    		cout <<"You have reached the valley wall\n";
    		User_Location_Y = User_Location_Y++;
    		getch();
    	}
    
    	else if (User_Location_X == 50)
    	{
    		cout <<"You have reached the valley wall\n";
    		User_Location_X = User_Location_X--;
    		getch();
    	}
    
    	else if (User_Location_X == -50)
    	{
    		cout <<"You have reached the valley wall\n";
    		User_Location_X = User_Location_X++;
    	}
    
    	end_game = end_game--;
    
    	if (end_game == 0)
    	{
    
    		system("cls");
    		cout <<"You have been slayed in battle!\n";
    		return 0;
    	}
    
            
    	cout <<"         North (8)                        " << User_Location_X << "/50   " << User_Location_Y << "/50\n";
            cout <<"East (4)           West (6)\n";
            cout <<"         South (2)\n";
            cout <<"\n";
            
    	cin >>input;
    	cout <<"\n";
    
    	//Defines user keys
    
    	if (input == 'Q' || input == 'q')
    	{
    		system("cls");
    		cout <<"You have died in combat Warrior.\n";
    		return 0;
    	}
            if(input == 'U' || input == 'u')
            {
    		  if(User_Potions <= 0)
    		  {
    			cout << "You have no remaining health potions.\n";
     			getch();
    			User_Potions = 0;
    			User_Health = User_Health;
            }
         	         else
            {
    		 cout << "You have been healed for "<<Potion_Heal<<".\n";
     			 getch();
    			 User_Potions = User_Potions--;
     			 User_Health = User_Health + Potion_Heal;
     		  }
            }
    
            // Updates user position
    	if (input == '8')
    	{
    		User_Location_Y = User_Location_Y++;
    	}
    
    	else if (input == '2')
    	{
    		User_Location_Y = User_Location_Y--;
    	}
    
    	else if (input == '6')
    	{
    		User_Location_X = User_Location_X++;
    	}
    
    	else if (input == '4')
    	{
    		User_Location_X = User_Location_X--;
    	}
    
            //directinal code
    	if (User_Location_X == -29 && User_Location_Y == 41)
    	{
    		if (chalace == 1)
    		{
    			cout <<"You have found The Ethereal Chalace.\n\n";
                            getch();
    			User_Location_X = 0;
    			User_Location_Y = 0;
    		
    		}
    
    		else if (chalace == 0)
    		{
    			cout <<"You have found The Ethereal Chalace.\n\n";
    			chalace = 1;
                            User_Exp = User_Exp +10;
    			User_Gold = User_Gold + 75;
                            cout << "You have recieved " << User_Gold << " gold pieces, " << User_Exp << " Exp & The Ethereal Chalace.";
    			getch();
                            User_Location_X = 0;
    			User_Location_Y = 0;
    		}
    	}
    
    	if (User_Location_X == 21 && User_Location_Y == 20)
    	{
    		if (septor == 1)
    		{
    			cout <<"You have found a Golden Septor Of The Lord.\n\n";
                            getch();
    			User_Location_X = 0;
    			User_Location_Y = 0;
    		}
    
    		else if (septor == 0)
    		{
    			cout <<"You have found a Golden Septor Of The Lord.\n\n";
    			septor = 1;
                            User_Exp = User_Exp +21;
    			User_Gold = User_Gold + 15;
                            cout << "You have recieved " << User_Gold << " gold pieces, " << User_Exp << " Exp & The Golden Septor Of The Lord.";
                            getch();
    			User_Location_X = 0;
    			User_Location_Y = 0;
    		}
    	}
    
            //Battleing with the black kngiht
            if (x > 90)
            while (battle == 1)
            {
            {
                    cout << "\nBlack Knight attacks, does "<<knight_Attack<<" Damage.\n";
                    User_Health = User_Health - knight_Attack;
                    getch();
    
            if (User_Health >=1)
                    cout << "\nYou attack, and do " <<User_Attack<<" damage.\n\n";
                   knight_Health = knight_Health - User_Attack;
                   getch();
    
            if(User_Health <= 0)
            {
                    User_Health = 0;
                    cout << "\nYou have been slayed in battle!\n";
                    cout << "Press any key to continue...\n";
                    getch();
                    return 0;
             }
            if(knight_Health <= 0)
            {
            cout << "\nYou have defeated a Black Knight.\n";
            cout << "You gain "<< knight_Exp << " Exp and "<<knight_Gold<<" Gold.\n";
            battle = 0;
            getch();
    
            User_Exp = User_Exp + knight_Exp;
            User_Gold = User_Gold + knight_Gold;
            knight_Health = knight_Max_Health;
            }
            else
            {
            }
            }
            }    }
            while(end_game!=1);
    
    	return 0;
    }
    Languages <> C++, HTML

    /*The Ledgend of Ludlow Coming to a PC Near
    You intro Cinenmatic Needed email me of
    Reply to one of my threads if you can make
    one, thats decent. */

  2. #2
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    Holy hell, work on cleaning up that code. introtxt( .. ) should be introtext( .. ). Since the return type of introtext() is int, make it return an int. And using only one function would suffice:

    Code:
    void type(char *text)
    {
         for(int i = 0; text[i] != '\0'; i ++)
         {
              cout << text[i];
              Sleep(40);
         }
    }
    Last edited by abrege; 03-07-2003 at 05:48 PM.
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  3. #3
    |<o>| <--cyclopse LouDu's Avatar
    Join Date
    Mar 2003
    Posts
    137
    wow that confused me can ypu give me the whoel code back cause i was jsut toally lost
    Languages <> C++, HTML

    /*The Ledgend of Ludlow Coming to a PC Near
    You intro Cinenmatic Needed email me of
    Reply to one of my threads if you can make
    one, thats decent. */

  4. #4
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    Surely you can figure it out
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  5. #5
    |<o>| <--cyclopse LouDu's Avatar
    Join Date
    Mar 2003
    Posts
    137
    lol i ahve been at this for 2 days please make my life a lil easy
    Languages <> C++, HTML

    /*The Ledgend of Ludlow Coming to a PC Near
    You intro Cinenmatic Needed email me of
    Reply to one of my threads if you can make
    one, thats decent. */

  6. #6
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    fixed version:
    Code:
    void introtext(char* letter) {
    cout << letter;
    Sleep(40);
    }
    
    int introtext()
    {
    Sleep(2000);
    gotoxy(34,10);
    introtext("L");
    introtext("U");
    introtext("D");
    introtext("L");
    introtext("O");
    introtext("W");
    
    return 1;
    }
    this would work just as well:
    Code:
    void introtext()
    {
         char *text = "LUDLOW";
    
         Sleep(2000);
         gotoxy(34, 10);
    
         for(int i = 0; text[i] != '\0'; i ++)
         {
              cout << text[i];
              Sleep(40);
         }
    }
    You might want to consider rewriting the whole program using OOP, no global variables and none of RoD's code
    Last edited by abrege; 03-07-2003 at 06:26 PM.
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  7. #7
    |<o>| <--cyclopse LouDu's Avatar
    Join Date
    Mar 2003
    Posts
    137
    RoD taough me form his source, but i copuld rewrite it i plan on it, but msot of it is all mine jsu the basic frame if RoD's teachign sto me basically it is all done by me from scratch other then the basic outline of it
    Languages <> C++, HTML

    /*The Ledgend of Ludlow Coming to a PC Near
    You intro Cinenmatic Needed email me of
    Reply to one of my threads if you can make
    one, thats decent. */

  8. #8
    |<o>| <--cyclopse LouDu's Avatar
    Join Date
    Mar 2003
    Posts
    137
    still doenst wokr jsut skips the whole intro right to the game
    Languages <> C++, HTML

    /*The Ledgend of Ludlow Coming to a PC Near
    You intro Cinenmatic Needed email me of
    Reply to one of my threads if you can make
    one, thats decent. */

  9. #9
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    Essentially, RoD's code is newbie and bad, don't learn from it/him. Read a book if you can't figure out why the intro doesn't show up.
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  10. #10
    |<o>| <--cyclopse LouDu's Avatar
    Join Date
    Mar 2003
    Posts
    137
    hehe right now i am recoding it trying to give the code some strucute that I yes me can fallow
    Languages <> C++, HTML

    /*The Ledgend of Ludlow Coming to a PC Near
    You intro Cinenmatic Needed email me of
    Reply to one of my threads if you can make
    one, thats decent. */

  11. #11
    Registered User
    Join Date
    Aug 2001
    Posts
    380
    Originally posted by LouDu
    still doenst wokr jsut skips the whole intro right to the game
    Your program doesn't even call introtext().

    int main()
    {
    introtext();
    do

    There now it calls introtext.

  12. #12
    |<o>| <--cyclopse LouDu's Avatar
    Join Date
    Mar 2003
    Posts
    137
    lol o... thanks alot man appericate the help :0
    Languages <> C++, HTML

    /*The Ledgend of Ludlow Coming to a PC Near
    You intro Cinenmatic Needed email me of
    Reply to one of my threads if you can make
    one, thats decent. */

Popular pages Recent additions subscribe to a feed