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; }



LinkBack URL
About LinkBacks


