This skin was created by Rocky of the IF Skin Zone

Create your own social network with a free forum.
InvisionFree - Free Forum Hosting
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:

Name:   Password:


 

 Darkness Falls, My first Text RPG
soten355
Posted: Jan 22 2006, 06:29 PM


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.


--------------------
user posted image
R.I.P. Shawn Noel
Darkness Falls
Top
Neken
Posted: Jan 22 2006, 06:38 PM


DirectX Guru


Group: Global Moderators
Posts: 515
Member No.: 11
Joined: 24-September 05



You forgot to close your file !

I didn't test it out though, i'll do it soon ...


--------------------
Top
soten355
Posted: Jan 22 2006, 06:41 PM


Teh Adminoxorz


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



i fixed the first post. tested it and it worked. Hope you guys like it.


--------------------
user posted image
R.I.P. Shawn Noel
Darkness Falls
Top
Neken
Posted: Jan 22 2006, 06:44 PM


DirectX Guru


Group: Global Moderators
Posts: 515
Member No.: 11
Joined: 24-September 05



what i meant, is taht you do

fin.open ...

without a fin.close ...

i know the destructor of ifstream does the .close by itself, but most of the time we don't want to wait until the desctructor applies to close the file ...


--------------------
Top
soten355
Posted: Jan 22 2006, 07:33 PM


Teh Adminoxorz


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



yeah, I just noticed that. I'll take it out, don't need it right now.


--------------------
user posted image
R.I.P. Shawn Noel
Darkness Falls
Top
Ludamad
Posted: Jan 22 2006, 11:33 PM


Mega Member


Group: Members
Posts: 97
Member No.: 47
Joined: 17-January 06



it gets tiresome writing out attack everytime
Top
soten355
Posted: Jan 23 2006, 12:45 AM


Teh Adminoxorz


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



keep in mind, it is a work in progress. It's also text based, so it isn't going anywhere fast. biggrin.gif


--------------------
user posted image
R.I.P. Shawn Noel
Darkness Falls
Top
Captn'Red
Posted: Apr 15 2006, 03:01 AM


Advanced Member


Group: Members
Posts: 32
Member No.: 54
Joined: 21-January 06



any more updates??


--------------------
Come get some.

user posted image
user posted image
Top
BGamed
  Posted: Apr 16 2006, 11:06 AM


Elite Member


Group: Members
Posts: 260
Member No.: 24
Joined: 29-December 05



maybe replace the keyword "attack" by just simply "a".
but its a cool thing you made there...


--------------------
user posted imageuser posted image
Top
Captn'Red
Posted: Apr 16 2006, 12:22 PM


Advanced Member


Group: Members
Posts: 32
Member No.: 54
Joined: 21-January 06



oh btw, you can type "attack 1" and it dose the same thing but skips a line....


--------------------
Come get some.

user posted image
user posted image
Top
InvisionFree - Free Forum Hosting
Enjoy forums? Start your own community for free.
Learn More · Register for Free

Topic Options



Hosted for free by InvisionFree* (Terms of Use: Updated 2/10/2010) | Powered by Invision Power Board v1.3 Final © 2003 IPS, Inc.
Page creation time: 0.4613 seconds | Archive