A ? for not so begginers
I was wondering if some oe could hlp me with something. I would like someone to write up the code for a text game...NOT THE WHOLE CODE!!! Just enough to get me started. It would be in C++ and alls i need is the classes and like 2 rooms done so I can ge tthe hang of it. I have tried myself but i had no clue where to start and as such I failed miserably. I do have a fair base knowledge of C++ so far. I am in to classes and onc eI see how its done I will be good to go.
Please either post here, send an email, or send the source via email with subject GameDev.
Thank you in advance
betrayer_of_code@gdnmail.net
BoC HomepageLuck is a Horse to ride like any other...Luckily im not a gambler, I dont know how to ride.
Well, don''t expect somebody to code the game for you.
If you expect someone to design the classes, about "2 rooms", the actual *game* is already developed, it only needs to be filled with content.
Try it yourself, you will learn the most.
Look what parts your game has that can be implemented as classes, e.g. a "room". Then look what member variables and functions a room should have, e.g. a description the character gives when looking around (if you''re making an adventure / rpg).
"Reality is merely an illusion, albeit a very persistent one." (Albert Einstein)
My Homepage
If you expect someone to design the classes, about "2 rooms", the actual *game* is already developed, it only needs to be filled with content.
Try it yourself, you will learn the most.
Look what parts your game has that can be implemented as classes, e.g. a "room". Then look what member variables and functions a room should have, e.g. a description the character gives when looking around (if you''re making an adventure / rpg).
"Reality is merely an illusion, albeit a very persistent one." (Albert Einstein)
My Homepage
---Just trying to be helpful.Sebastian Beschkehttp://randomz.heim.at/
This might not be what you were looking for, but it could help.
http://www.gametutorials.com/Tutorials/Console/Console_Pg1.htm
"Discipline is never an end itself, only a means to an end." - Robert Fripp
http://www.gametutorials.com/Tutorials/Console/Console_Pg1.htm
"Discipline is never an end itself, only a means to an end." - Robert Fripp
"Discipline is never an end itself, only a means to an end." - Robert Fripp
it''s easy... why don''t you try it yourself...
Design it in Notepad and work it out. If you don''t try, you don''t win.
.lick
Design it in Notepad and work it out. If you don''t try, you don''t win.
.lick
hello,
It its an actual text based rpg, for example "in this room there is a boiler, to tuch it and burn yourself press 1". If its like that all you have to do is an #include <iostream.h>; then int main() for the load up scren. Then for each room make a seperate sub function. in the rooms you just have to use a int x; and some cout<<""; to set the text. After that just do a cin>>x; and a switch x;
{
case 1: blah blah blah
case 2: blah blah blah
etc. etc. etc.
}
then in eache case of your switch case statement state the happenings of what you have done then reload the room by going back to the same room but set a global bolean variable like room door open, and if that happens through the switch case function then set that to true. Then give new information via. a if statement like in useing x as an interger
if (x == 1)
{
cout<<"there is now a large firey pit in the middle of the room, it looks fun to jump into!";
cout<<"if you want to jump into it and be severly burned (don''t be a moron) press 1, if not press 2";
cin>>y;''lets just say i declared this as a variable above
switch y
{
case 1: cout<<"you moron, you are very ignorant, but you won the game!";
break;
case 2: cout<<"I comind you for succoming to the fire, but unfortonitly, your vital orgons decited you were no fun so the burst out of your chest and jumped into the fire without you. They were right and you were wrong so how does it feel to have your vital organs be smarter than you. you died and your computer has been notified that you are a anti risk taker.";
break;
}
return 0;
}
there you go, that is how to do a fully old school text based game. sorry, but i cannot get you started by writeing code for you but here is some information. go to www.tutorialbox.com and they have some good beginer tutorials so that you can be on your way to trying to learn direct x 9.0 like i am right now. Un fortunitll, if your trying to add graphics, i cant help you because i am just starting graphics in c++ so talk to some one else. Nut they do have good tutorials. I bid you a great salutations now.
It its an actual text based rpg, for example "in this room there is a boiler, to tuch it and burn yourself press 1". If its like that all you have to do is an #include <iostream.h>; then int main() for the load up scren. Then for each room make a seperate sub function. in the rooms you just have to use a int x; and some cout<<""; to set the text. After that just do a cin>>x; and a switch x;
{
case 1: blah blah blah
case 2: blah blah blah
etc. etc. etc.
}
then in eache case of your switch case statement state the happenings of what you have done then reload the room by going back to the same room but set a global bolean variable like room door open, and if that happens through the switch case function then set that to true. Then give new information via. a if statement like in useing x as an interger
if (x == 1)
{
cout<<"there is now a large firey pit in the middle of the room, it looks fun to jump into!";
cout<<"if you want to jump into it and be severly burned (don''t be a moron) press 1, if not press 2";
cin>>y;''lets just say i declared this as a variable above
switch y
{
case 1: cout<<"you moron, you are very ignorant, but you won the game!";
break;
case 2: cout<<"I comind you for succoming to the fire, but unfortonitly, your vital orgons decited you were no fun so the burst out of your chest and jumped into the fire without you. They were right and you were wrong so how does it feel to have your vital organs be smarter than you. you died and your computer has been notified that you are a anti risk taker.";
break;
}
return 0;
}
there you go, that is how to do a fully old school text based game. sorry, but i cannot get you started by writeing code for you but here is some information. go to www.tutorialbox.com and they have some good beginer tutorials so that you can be on your way to trying to learn direct x 9.0 like i am right now. Un fortunitll, if your trying to add graphics, i cant help you because i am just starting graphics in c++ so talk to some one else. Nut they do have good tutorials. I bid you a great salutations now.
its in C not C++, but its worth a look to get a feeeling of what your getting yourself into.
ftp://ftp.game.org/pub/mud/diku/merc/rom/windows/
not sure which one has the source, but its a port of a MUD to a win32 system. Hope it helps.
oh, and read the docs that come with it.
ftp://ftp.game.org/pub/mud/diku/merc/rom/windows/
not sure which one has the source, but its a port of a MUD to a win32 system. Hope it helps.
oh, and read the docs that come with it.
Evillive2
What you''re lacking is ''technical design'' or ''architecture.'' You say you have a basic knowledge of C++ - how basic? You need to be totally comfortable with classes and inheritance (at least) before undertaking something like this.
Then, think about what types of object your game has:
Player
Monster/NPC
Item (stuff you could pick up, etc)
Room
Keep listing until you''ve got everything down. Then, look at how some things are similar; for example, let''s say Monsters and NPCs can move from room to room. This means that both you (the player) and the monsters can move around, so perhaps they should both come from a base class ''CMovingCreature.'' In that base class you can put all the code needed for a moving creature - for example, a Move() function which takes the direction the creature should move in, and moves it - taking care of things like which room the creature should now be in, or if it''s possible to move that way.
Then, consider the ''data'' that each object should have. Rooms should have descriptions ("The cellar is musty and dark, and smells like ripe cheese."). Objects should have names ("There is a Torch on the ground here."). Monsters/NPCs should have strength/health ratings, or ''friendliness'' ratings ("The monster hits you with his +20 Club of Pain"). It goes on.
Once you''ve got all that, you should have a good idea of how to make your classes - what data and functions they should have, and how they should derive from each other.
Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Then, think about what types of object your game has:
Player
Monster/NPC
Item (stuff you could pick up, etc)
Room
Keep listing until you''ve got everything down. Then, look at how some things are similar; for example, let''s say Monsters and NPCs can move from room to room. This means that both you (the player) and the monsters can move around, so perhaps they should both come from a base class ''CMovingCreature.'' In that base class you can put all the code needed for a moving creature - for example, a Move() function which takes the direction the creature should move in, and moves it - taking care of things like which room the creature should now be in, or if it''s possible to move that way.
Then, consider the ''data'' that each object should have. Rooms should have descriptions ("The cellar is musty and dark, and smells like ripe cheese."). Objects should have names ("There is a Torch on the ground here."). Monsters/NPCs should have strength/health ratings, or ''friendliness'' ratings ("The monster hits you with his +20 Club of Pain"). It goes on.
Once you''ve got all that, you should have a good idea of how to make your classes - what data and functions they should have, and how they should derive from each other.
Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Superpig, sorry but no you don''t have to understand classes and inheritance.. I learnt how to program the basics using C++ by doing just this sort of project. I never used objects, just good old variables. The code ended up at 6000 lines.. and was messy as hell, but I wrote a text adventure.. (never finished it, and lost the source!) All you have to do is think about what you are trying to acheive and how you are going to acheive it.. sit down and think ''Well, to do this I need.. ''
After a while, you may get some messy code, but you take something away from it.. a learning experience.
After a while, you may get some messy code, but you take something away from it.. a learning experience.
quote: Original post by hammerstein_02
The code ended up at 6000 lines.. and was messy as hell, but I wrote a text adventure..
This is the whole point. If you use a procedural style, just like you and VbDestroyer suggested, you get messy code and stuff. If you use well-designed objects, your code is cleaner and you can make a thousand adventures using the same source code. Actually, I''m working on a very generic text adventure "engine". Dunno if I''ll finish it, though.
"Reality is merely an illusion, albeit a very persistent one." (Albert Einstein)
My Homepage
---Just trying to be helpful.Sebastian Beschkehttp://randomz.heim.at/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement