Thread: C++ Knowledge
View Single Post
Old 11-20-2011, 10:38 PM   #10
Vasu
Malingerer
 
Vasu's Avatar
 
Tournaments Won: 3

In-Game Name: None
Current Level: None
Server: None
Posts: 1,899
Vasu is just really niceVasu is just really niceVasu is just really niceVasu is just really niceVasu is just really nice
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.
__________________


Credits to Loveless for the great signature!
We rode on the winds of the rising storm
We ran to the sounds of thunder
We danced among the lightning bolts
And tore the world asunder

Vasu is offline   Reply With Quote