Thread: C++ Knowledge
View Single Post
Old 11-21-2011, 06:51 AM   #11
Phantom Badger
FF's Official Weirdo
 
Phantom Badger's Avatar
 

In-Game Name: [BlackDragonEX - Paladin]
Current Level: [BlackDragonEX - 73]
Server: Teva
Posts: 1,338
Phantom Badger has a spectacular aura aboutPhantom Badger has a spectacular aura aboutPhantom Badger has a spectacular aura about
Send a message via MSN to Phantom Badger

Originally Posted by Vasu View Post
Since we're not going to be displaying any grids anyway, you can use simple location IDs. I DL'ed and played a bit of Zork, and there is not much scope for movement within a location, so we can have it similar to that. You can have various states based on the location ID. Each location can be the object of a class, with the following properties:
  • List of items that can be taken. (We can use actual strings to describe the items rather than IDs since there may be too many).
  • A string (or strings) that holds the description of the location. This string must have well defined delimiters within itself. In Zork, the description of a location would change based on whether or not certain items were still there, so we can use separate strings like "General description of the location", "Description of item 1", "Description of item 2" etc, and just concat all of them or some of them depending on the current state of the location.
  • Accessible areas and their directions.
  • Usable items, interactive characters if any.

Basically the most important thing to do in OOP is to draw out a list of the various types of objects that you may use within the game such as "Location", "Item", "NPC".

Then when it comes to taking the input, you'll need to really be able to work with strings and separate them out and stuff. C and C++ are really 2 of the worst languages for handling strings, so you'll definitely have your work cut out for you. Basically you'll need to form an exhaustive list of verbs, nouns and conjunctions if you're using those which will be checked against each time they type something in. Form a structure for the input. In Zork it seems to be <verb> <noun> or <verb> <conjunction> <noun>.

I realise you may already have a lot of this planned out, I'm just trying to show how I would approach the problem.
What you're suggesting seems similar to what my original plan was, however I found it to be very difficult to create any form of boundary to stop players typing 'East' when in a building and just end up outside for example. So my current plan is a multi-dimensional array with each section of the array correlating to a co-ordinate of a room.
Inside each section of the array will be a string of 4 letters (eg, "FTTF") which the code will use to determine where it is allowed to move, if the first letter is our ability to go North and it equals F then we cant go north from that area, etc. We can use sub strings to enforce this.

Thats my current general plan anyway, this project definitely seems a lot more complex than when I had first envisioned it :P
Phantom Badger is offline   Reply With Quote