Monday, April 3, 2017

How can I implement a command system for a point-and-click style adventure game?


I'm making a point and click adventure game, and I'm currently trying to figure out the best way to implement a command system.


Assume a Monkey Island or Maniac Mansion style interface, with a palette of verbs, and objects in the scene and in the inventory. Clicking on these, you build up a sentence to execute.


for example, you might click look at and then a tree to get "look at tree" or click on an apple, and then give, and then a girl, to get "give apple to girl".


There are three possible forms of a sentence:



  • verb, for example "save"


  • verb noun, for example "pick up apple", "look at octopus"

  • verb noun noun, for example "give pickle to rabid dog", "use crowbar with pickle jar"


In different situations, I'll want the action to be carried out to be defined by different objects.


For example, for the give verb, there might be a default action defined that makes the character say something like "I'd prefer to hang on to that", or the rabid dog might define an action where it eats anything you attempt to give it.


If the interface is to work like Maniac Mansion, then you build the sentence, and then tell it to execute (in Maniac Mansion, by either clicking the sentence, or clicking again on the last thing you clicked on).


If it's to work like Monkey Island, the sentence executes as soon as it's complete, which poses a problem for verbs like use which might sometimes take one noun, and other times two.


So how would you implement a system that handles this?




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...