Create your own social network with a free forum. | Welcome to C++ Game Dev. We hope you enjoy your visit.
You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.
Join our community!
If you're already a member please log in to your account to access all of our features:
|
Darkness Falls, My first Text RPG
| soten355 |
|

Teh Adminoxorz
        
Group: Admin
Posts: 339
Member No.: 1
Joined: 21-March 05

|
Well, I guess I should release this now. For a while, I've been working on a text RPG(i've submitted the engine at the CLC). It's called Darkness Falls. I'm still working on the story, but I can give you guys a demo of the engine.
| CODE | #include <iostream> using namespace std; #include <stdlib.h> #include <string> #include <windows.h> #include <fstream>
void DrawColorString(string szText, int X, int Y, WORD color) { HANDLE OutputH; // This will be used for our handle to the output (basically, holds permission to change the output settings) COORD position = {X, Y}; // Create a COORD and set it's x and y to the X and Y passed in.
OutputH = GetStdHandle(STD_OUTPUT_HANDLE); // Get a OUTPUT handle to our screen.
SetConsoleTextAttribute(OutputH, color); // Set the text attribute to what ever color that was passed in. // The function SetConsoleTextAttribute takes (the handle to the output, and the color); SetConsoleCursorPosition(OutputH, position); // Set the cursor position to the desire position passed in.
cout << szText; // Now print out what we wanted to at the position that was passed in.
}
int main() { string answer="", name="", cont=""; int line=0; DrawColorString("Darkness Falls", 15, 0, BACKGROUND_RED); line = line + 1; DrawColorString("Type start to began.\n", 0, 1, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); cin >> answer; line = line + 1; while (answer != "start" && answer != "Start") { cout << "You did not type in a valid command, please do so if you wish to play." << endl; line = line + 1; cin >> answer; line = line + 1; } cout << "In a land of old, years ago, the people were in peace with nature. Then, one daythe evil Wizard Bardoon, set a curse about the world. Eternal Darkness. The \npeople were filled with fear.\nBut, through the Darkness, a warrior of light came to them, and said of a young child who will end the darkness, and bring the fall of Bardoon.\n\nWhat is your name?" << endl; line = line + 4; cin >> name; line = line + 1; cout << "'Wake up " << name << "!' said a voice, 'Wake up!'\n'Huh? oh, it's just you Nanai.' said " << name << "\n'" << name << ", we need you to start your training!' said Nanai.\n" << endl; system("pause"); cout << " Training Field" << endl; cout << "'Alright, you may not remember the basics, so I'll teach 'em to ya.' said Nanai." << endl; system("pause"); cout << "'Okay, first, to attack, you type in attack. Then it will ask you which enemy to attack. You type in the enemy's number, then you attacks. Why don't you try it out on that fighting dummy.' said Nanai." << endl; system("pause"); cout << " FIGHT!" << endl; int dummyhp=10; string command="", slot=""; cout << " Dummy[1] - " << dummyhp << endl; cout << "Command: "; cin >> command; while (command != "attack") { cout << "\nUnknown Command, enter new: "; cin >> command; } cout << "Which enemy: "; cin >> slot; while (slot != "1") { cout << "No enemy there, type another: "; cin >> slot; } cout << "\nAttacking!" << endl; dummyhp = dummyhp -= 2; while (!dummyhp <= 0) { cout << " Dummy[1] - " << dummyhp << endl; cout << "Command: "; cin >> command; while (command != "attack") { cout << "\nUnknown Command, enter new: "; cin >> command; } cout << "Which enemy: "; cin >> slot; while (slot != "1") { cout << "No enemy there, type another: "; cin >> slot; } cout << "\nAttacking!" << endl; dummyhp = dummyhp -= 2; } cout << "Enemy's Defeated!" << endl; cout << "Fight Over!" << endl; cout << "'Well good job, " << name << ". You did good, for your first try. But, let me teach you some other commands.' said Nanai." << endl; system("pause"); return 0; }
|
Just copy and paste. I made it in Dev-C++ so it should run smooth.
--------------------
|
|
|
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
|