• Advertisement
Sign in to follow this  
  • entries
    12
  • comments
    6
  • views
    6154

Java Text Adventuring

Sign in to follow this  

202 views

I took a break from my applet engine, which is almost done, to play around with text adventures. I use to play a lot of them when I was younger and some of the first games I ever wrote were text adventures on my Atari 400 when I was about eight years old. If I had only kept programming through the last few years of high school....

I am working on putting together a simple text adventure in Java and am having problems, due to my lack of proper design. My basic setup goes something like this:

- Get line of input from user
- Tokenize the line, checking each word to make
sure it is in the 'language'.
- If they are, convert them to integers.
- Based on the first word (which has to be a verb, move, look, listen etc..)
Execute the proper method to handle the command (actionMove(), actionLook() etc..) Which handles the processing of the rest of the line.

Now my issue is, I have a Parser class that does the converting and checking. Now my current thought is to simply make the appropriate constants (ACTIN_MOVE, ACTION_LISTEN etc..) static and to make the parse method return the list of tokens and have the other class check to see which method to execute. This is the way I am probably going to do it right now, since I can't think of a better way to do it, and can't find much help in coding a text adventure. Everything I am finding is about using the different engines that have been built for it.

Somewhat Structured Thoughts
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement