text adventure game

This is a discussion on text adventure game within the Game Programming forums, part of the General Programming Boards category; I'm still working on my text adventure game. I have a general idea for the design, well maybe more than ...

  1. #1
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198

    text adventure game

    I'm still working on my text adventure game. I have a general idea for the design, well maybe more than just that, but I'm not sure how to put it all together.
    Here's what I have:
    Character class (has inventory, name, and location)
    Inventory class (has list of Items, add/remove functionality)
    Item class(es) (has name and bool isUseable)
    Lamp, Door, Chest inherit from Item (has isOn, isLocked, and methods to change state)
    Room class (has description of room, list of items)

    that's what i have so far, i'm not sure how to put it all together... any suggestions? thanks a lot

    [edit]changed item system[/edit]
    Last edited by linucksrox; 07-21-2006 at 07:58 PM.
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,453
    Following on Dave's suggestion, you then need to think what "things" are going to happen. You need to establish the action of the game in order to have an idea of how you are going to code it.

    Fo far you have concentrated on the "nouns". Now you need to establish the "verbs".

    How will my character move?
    What happens when it moves?
    How will my character attack? Can it be attacked too?
    How does it pick items, handle them, use them?
    How can it interact with NPCs? Will I develop a NPC reaction system?
    ... ... ...
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,069
    Well, if he has class implementations, then he has the verbs, as well. Verbs are nothing more than functions of the noun doing said verb.

    When you have your class hierarchy and implementation complete (this is more than just objects, you'll need a class to handle the storyline, key-processing, etc), then I'd say the next step is to make your game loop. Create instances of your objects... ie. your main character, your timeline, what ever enemies are roaming around, etc... the run a loop that constantly waits for user input to process. Perhaps also updating things like an active clock or whatever else you need.
    Sent from my iPad®

  5. #5
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198
    Maybe I'm in a little over my head here. I want to do something a little simpler than what SlyMaelstrom's saying, I mean my goal is to have a main player, items that can or cannot be picked up, items that can or cannot be used, rooms that know their exits, a map, and some kind of simple story. i don't even want to make a story until i have the game working...
    but you're saying i need a class for the input-processing, but another one for the storyline? how would that work?
    should i start over and figure out the objects and inheritance?
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,453
    Not really. If you don't feel comfortable with OOP, don't use it.

    Well, don't use it for this project, but do seriously consider studying this subject. Many programs can be written in C++ without inheritance, data abstraction and dynamic binding in mind. On some cases it makes sense, on most it probably doesn't.

    But since this is a learning process, go ahead and continue your game without it if you don't want to use it.

    What you seem to be missing is the glue that will hold your current objects together. As I said before you need to think slow about what you want your game todo...

    Try first to move your character across the rooms. What keys will allow this to happen? What will happen when the character moves? Will the player class have a data member that informs which room the player is in? That data member could be a pointer or a reference to a room instance. What command will be used to allowa player to pick and item? and what about drop it? What will happen when he does so? The inventory probably needs to be updated and the room too so that the object is removed from the room.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  7. #7
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    What SlyMaelstrom said about the game is completely true. However you should also note that an input class is probably not going to do all that much. An input class most likely needs to do this:

    • Accept valid characters and concatenate those onto the existing input string
    • Perhaps perform background game processing while waiting for input -> IE: Things can happen while you type and while it waits for you to type.
    • When ENTER is pressed, run the input string through the parser.
    • If input string is invalid (from parser class), notify the player of the problem.


    The parser, however, should only parse strings. It should not worry about key input.

    Core classes:
    • CKeyHandler - handles the core input routines, would interact directly with the API, be it DirectX, Windows, etc.
    • CGameInput - handles input for the game
    • CGameParser - parses strings that are typed in
    • CTextWindow - for handling the input text window and the main text window.
    • CGameScript - if the game is this complex, this would be a class handling scripts
    • CConditional -> a conditional script object -> linked to any of the following
    • CEvent -> a script event object -> a container of a combination of conditionals, actions, or triggers.
    • CRandomEvent -> a random event object
    • CAction -> a script action object
    • CTrigger -> a script trigger, possibly linked to a CConditional, CEvent or CAction


    Possible game specific classes/objects:
    • CDoor - a door object
    • CDoorMgr - a small class that handles a collection of doors
    • CRoom - a room object
    • CRoomMgr - a room container
    • CGameObject - base class for all objects
    • CPlayer - derived from CGameObject to implement a character/player object
    • CAIObject - derived from CGameObject to implement an AI object
    • CNPC - a type of CAIObject
    • CStaticItem - a static room object with description and properties
    • CInventoryItem - one inventory item object
    • CInventoryMgr - manages a collection of inventory items


    With this setup, CInventoryItems would be placed in rooms and the player could pick them up. Non-CInventoryItem(s) or CStaticItem(s) would support all forms of interaction, except for being picked up and placed into inventory. Such things as a piano, window, chandelier...etc, etc. would be put into this category.

    I could go on, but it's pointless. Hopefully this might fire off some ideas in your head as to how you want to design the system.

  8. #8
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,069
    Game design you'll find is very similar to the very basic level "don't look over anything" problems they give you in early programming classes, like how to build a robot to start a car or buy a drink from a soda machine. When you write one, you'll find out how much you take for granted and don't really think you need to program. People often on their first time through a game write a character, a sword, a goblin, and a short story and then they get very lost... You gotta put some mortar between those bricks. That's what Bubba is posting above. Interaction of everything is the most important part of game design.
    Sent from my iPad®

  9. #9
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198
    Wow. Thanks for all the info guys. I'm realizing that there's SO much more to this than what I was expecting. It will probably take me a lot more time to complete than I expected, since I don't have a whole lot of free time to figure it all out. But it's a good challenge while I learn Java, and hopefully I will finally complete it and have a fun playable game (eventually).
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

  10. #10
    Registered User
    Join Date
    Jan 2006
    Posts
    14
    ur doing this text based game in C++?

    is it online...cause if it is...PHP is the easiest i would guess...

    sorry if that sounds like a stupid remark but im a newbie and ive just started off with this whole programming language thing...currently doing C++...so far its ok and interesting

  11. #11
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    498
    Quote Originally Posted by Shiv4life
    ur doing this text based game in C++?

    is it online...cause if it is...PHP is the easiest i would guess...

    sorry if that sounds like a stupid remark but im a newbie and ive just started off with this whole programming language thing...currently doing C++...so far its ok and interesting
    Wrong. PHP is a one-way language, meaning that once you write something to the page, it's permanent until the user reloads the page (or browses to another page).

    No. You have to use a language such as C/C++, Java, etc. If you need to make it online, then you can simply add sockets to your program.

  12. #12
    lv.42 Berserker Drake's Avatar
    Join Date
    Jun 2005
    Posts
    67
    linucksrox, this is only a text rpg. I know that what these guys said is a little too hardcore for you right now, so all you really have to do is create some kind of battle system (I would really look at gamefaqs.com, and at the final fantasy pages, this would help with the "how much damage he takes, and how much I take") , after that is completed, all you really have to do is add in the items you gain after battle. The text rpg idea is a VERY GOOD idea for beginners like myself because it helps you get used to the programming language (i'm a newb in c++, but getting up there in my AP class in JAVA). As for your storyline, I suggest you read a really good series (A.K.A Inheritance: Eragon and Eldest).

    hoped I cleared that up a bit, good luck!

  13. #13
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Typically for a lot of online text games I have seen recently people use PHP/Javascript to do it... check out http://blue.bots2.com for an example

  14. #14
    Registered User Osaou's Avatar
    Join Date
    Nov 2004
    Location
    Stockholm, Sweden
    Posts
    69
    You could query the PHP script in a hidden frame and then display its content in a visible container through JavaScript; se yes, it would be possible with PHP without "reloading the page" so to speak.

    But hey, where are my on-topic manners?

  15. #15
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198
    well I am actually planning on using Java to make my game, but I think I'm going to get something going in TADS right now and then try to convert what I have to Java, so that I can have a good understanding of how everything works together and I have a good working model to translate into java code. I don't want anything online, I'm just trying to create my first program basically, and I'd like to go the text adventure route.
    I agree with Drake though, some of the info I've been getting is a little too hardcore (way too hardcore) for me right now. I mean, I've gotten through data structures in c++ and a tiny bit of algorithms, and now I'm learning java stuff. But I have never worked on any project of this complexity (I know it's not even that complex compared to "real world" apps). Thanks for all the help, I'm also getting a ton of help on javagaming.org forums, and I plan on posting my progress as I work on my game.
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Programming 2d Array Question
    By jeev2005 in forum C Programming
    Replies: 3
    Last Post: 04-26-2006, 03:18 PM
  2. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 01:59 PM
  3. Game Independent Anti-cheat Project Needs Programmers
    By GIA Project Lea in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-15-2005, 07:41 PM
  4. Saving a text game
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 03-27-2002, 12:33 PM
  5. Text Based Game
    By drdroid in forum C++ Programming
    Replies: 2
    Last Post: 02-18-2002, 05:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21