Advertisement

Text Rpg

Started by March 21, 2002 06:39 PM
31 comments, last by gamechampionx 22 years, 8 months ago
quote: Original post by gamechampionx
BTW, what's std::cout?
What syntax and format should I use? Also, which header files??

It's to do with "namespaces", which are a way to keep parts of your code in a separate place. You've probably been doing this:

#include <iostream.h>
cout << "whatever" << endl;

However, that's actually non-standard (old, inadvisable). Namespaces let you wrap up things, so if you did this:

      namespace Something{  void myFunc();}namespace AnotherNamespace{  void myFunc();}  

...then you'd access them like this:
Something::myFunc(); // or AnotherNamespace::myFunc();

That can help to reduce conflicts with any code named the same.

The iostream is contained in the namespace "std", which means that you can either do this:


  #include <iostream> /* no .h */using namespace std;// from now on, no need for std:: before everything//...or this:#include <iostream>std::cout << "something" << std::endl;      

etc.

Namespaces are a way of cleaning up your code. There was a discussion about them over here and here not long ago. Also, have a look over here.

Alimonster

"If anyone can show me, and prove to me, that I am wrong in thought or deed, I will gladly change. I seek the truth, which never yet hurt anybody. It is only persistence in self-delusion and ignorance which does harm." -- Marcus Aurelius

[edited by - Alimonster on March 27, 2002 8:41:46 PM]
Perhaps it''s good to be exposed to more advanced things early, but I would just begin with cout<< instead of namespaces. I''ve been programming for awhile, and have never even heard of namespaces. Granted, I''m still a newbie for the most part, but I think cout<< is fine for now

Anyway... I don''t know if this is helpful, but I''d definetly advise switches over multiple ifs. For example, if you wanted to make some sort of battle menu:


  switch(choice){  case ''a'':  case ''A'':  {    Attack();  }  case ''r'':  case ''R'':  {    Run();  }} //switch  


Two cases, in case the user accidentally has capslock on. Of course, you could retrieve choice (a char) using cin or, for a bit of extra spiffiness, use a kbhit() and getch() combo so that the user doesn''t have to press enter For some semblance of a GUI, you could make a box using various ascii charcters and then have something like:

====================
-


' Target=_Blank>Link
Peon
Advertisement
Why not do it in real time?


  void Attack(int direction,int currententity);void Run(int direction,int currententity);void Attack(int direction,int currententity){   // Insert a message in the message loop.   mymessageeventclass M;   M.time = GetMyCurrentTime();   M.message = ATTACK; // can be a constant   M.owner = currententity; // Global owner identifyer.   PostMyMessage(M);}void Run(int direction,int currententity){   // Insert a message in the message loop.   mymessageeventclass M;   M.time = GetMyCurrentTime();   M.message = RUN; // can be a constant   M.owner = currententity; // Global owner identifyer.   PostMyMessage(M);}void DoGameRules(int self){   myentityclass E;   E = GetEntity(self);   // Here you insert you user input stuff or automatic NPC stuff      if(!E.npc)      FeelForUserInput(E);   else      DoNPCInput(E);   switch(something)   {   case ATTACK:      Attack(E.userdirection,self);   case RUN:      Run(E.userdirection,self);   }}int MainLoop(int params){   int ret=0;   // Read all your message events and handle them   while( (ret = GetMyMessage()) != 0)      ;   if(ret == 0)      return 0;   // Produce more messages for next frame.   for(int i=0; i <= NUM_ENTITIES; i++)   {      ret = DoGameRules(i);      if(ret == 0)         return 0;   }   return ret;}int main(void){   while(DoMainLoop() != 0)      ;}  


I left alot for you to write yourself, but it will be fairly easy:
The message event could be a simple linked list or a stack ().

The benefits for this system is that you can post anything into the message loop, even messages to change desktop resolution or send messages over the net.

Even if this is a turn based game, you want to be able to feel for user inputs while it calculates the next frame. This can be done by either threads or message loops. Just post a ''FeelUserInput'' message every now and then and let user do stuff while processing.

This is great stuff, I promise you.



"Self awareness is the interaction between 3 different parts of your brain. The Cog, the Left and the Right side of you brain..."
quote: Original post by Andrew Nguyen
Ahhh... forget I ever said anything.

we will... until you open your bleeding hole again...
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
I probably won''t use namespaces for now. Anyway, how do you locate a certain position on the screen to input/output text? And how do you clear the screen (DOS).


On a separate note, I''m thinking of adding many classes and races, so you can mix and match, like having an elf mage or human fighter. Which classes should I implement.
Also, what sould be different between races. Maybe some start with stats in certain areas, and certain abilities. However, I want it to even out at the end so all races are equal, just getting there is different. I also want to do different spells for different classes. How should you learn magic? Maybe books, or should I go by level, or both?

Input is appreciated!!!
Check out Drunken Brawl at http://www.angelfire.com/games6/drunken_brawl!
quote: Original post by gamechampionx
I probably won''t use namespaces for now. Anyway, how do you locate a certain position on the screen to input/output text? And how do you clear the screen (DOS).


On a separate note, I''m thinking of adding many classes and races, so you can mix and match, like having an elf mage or human fighter. Which classes should I implement.
Also, what sould be different between races. Maybe some start with stats in certain areas, and certain abilities. However, I want it to even out at the end so all races are equal, just getting there is different. I also want to do different spells for different classes. How should you learn magic? Maybe books, or should I go by level, or both?


To clear the screen, put this in: system("cls"); in C++, for classes, make one that''s great in magic, great in strength, great in speed and stuff like that. Get what I''m saying
Advertisement
What about races? Maybe the starting stats are different, but by the max, Lv. 100, they are the same between races, but not classes. In other words, a Lv. 100 human wizard and a Lv. 100 elf wizard are the same, but a Lv. 20 human wizard and a Lv. 20 elf wizard are different. Also, a Lv. 100 human wizard is completely different in stats from a Lv. 100 human warrior. Get the idea? I think it''s pretty good, how about you?
Check out Drunken Brawl at http://www.angelfire.com/games6/drunken_brawl!
system("cls") doesn''t work!!
Also, how do you locate a position for text output???
Check out Drunken Brawl at http://www.angelfire.com/games6/drunken_brawl!
These are questions for the programming forums. As for your game design ideas, I strongly recommend you make some decisions for yourself rather than asking us to design your game for you. Otherwise it will be our game, not yours, and you won''t have learned much on the design side. If you really don''t have any ideas, try looking at existing games and copy what you like.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions ]
Class/Race Info:

In my game, you must choose a class and a race, each with different strengths and weaknesses, and magic spells. Here they are:

Races:

Humans:
good at attack/defence, but not so much at magic; ok at agility

Goblins:
amazing attack, very good defence, horrible magic, bad agility

Elves:
ok attack, bad defence, amazing magic, ok agility

Faeries:
horrible attack, OK defence, very good magic, amazing agility

Dragons
ok at everything

Classes:

Blood Mage:
mix of physical abilities and amazing spells, but they have drawbacks, such as paying life

Thief:
good at agility and magic, has cool thieving abilities, and gains experience from stealing, but not as much as from battling

Elemental Mage:
has great magic skills, and uses elemental spells

Ninja:
uses physical attacks, some magic, and is quick

Gladiator:
good at only physical abilities

Warlord:
uses ranged weapons, amazing agility

What stats do:

Attack- More damage
Defence- More hp
Magic- More mana
Agility- attack more often in battle

How agility works:

-one''s interval is equal to that character''s speed divided into 100; a loop will keep incrementing a value, and when your interval comes up, you attack; if two attack at the same time, the attacker is chosen at random
-therefore, a character with 10 agility will attack twice as much as one with 5

At the beginning of the game, different races of characters are given discounts on certain items.

Humans- 20% off swords/armour
Goblins- 35% off 2-handed weapons
Elves- 25% off armour
Faeries- 50% off mana potions
Dragons- 10% off everything

These last only until the character has reached level 15.

Lastly, one obstacle was to base stats on class and race. Some races start with certain stats higher than others, but they even out by lv. 100 (max). However, it''s the character''s class that adds a certain value to each stat, making them work well according to character class. This is so that every class will work with every race, so that by lv. 100, one''s race is irrelevant.

That''s it for now, what do you think?

Check out Drunken Brawl at http://www.angelfire.com/games6/drunken_brawl!

This topic is closed to new replies.

Advertisement