2 Replies - 3304 Views - Last Post: 28 May 2009 - 05:59 PM Rate Topic: -----

#1 fairie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 22-April 09

Choose your own adventure style game

Posted 24 May 2009 - 02:09 PM

I'm doing is a choose your own adventure game, where the user is presented with two or three options to do at a given point, and the story changes depending on what they choose.

I've got a basic framework done, but I'm stuck on how to actually process the moves - take the option the user chose and figure out the next area. I think the best way to go about with 2d arrays, but I'm not exactly sure how.

I've used a switch statement to process that statements, but I'm unsure of that's correct.

// The "LostinTime" class.
import java.awt.*;
import hsaCIP.Console;

public class LostinTime
{
	static Console c;		   // The output console

	/**
	 *The main method displays the description for the area and the choices.
	 *
	 *@paramargs
	 *	   unused
	 **/

	public static void main (String[] args)
	{
		c = new Console ();

		boolean[] gameover = {false, false, true, }; // determines whether it is a game over scene

		int area = 0; // The area the player is currently in.

		int[] [] areaChoices = new int [10] [10];

		String[] areaDescription = {"Description of area", "description of area", "description of area", };  // This would where the area descriptions would be stored.

		while (gameover [area] == false)
		{
			c.println (areaDescription [area]);	 // Prints the description of the area and the choices.

			processArea (areaChoice);

		}
	}


	/**
	 * This method processes the input from the user as to what area to go   
	 * to next.
	 * @return : What the next area will be.
	 **/
	public static int processArea (int areaChoice)

	{
		int choices;

		c.println ("Which choice do you make?");
		choices = c.getChar () - 48;

		switch (choices)
		{
			case 1:
			case 2:
			case 3:
			case 4:
		}

		areaChoice = choices;
		return areaChoice;
	}
} // LostinTime class


Is This A Good Question/Topic? 0
  • +

Replies To: Choose your own adventure style game

#2 ralph_komer  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 71
  • Joined: 12-May 09

Re: Choose your own adventure style game

Posted 24 May 2009 - 04:34 PM

I don't think I have completely understood your requirement. But based on whatever I have understood, I can suggest you the following:

1. Create a Vector and store objects which will contain the area name, description, different options available in each area and other features of an area. Lets say you have an area A with description D and feature F. You can create a class as given below:


class A 
{
	 String D = "Adventure area";
	 String F = "Loads of adventure";
}




You can then later instantiate this class and store the object in the vector. If the user selects this area, all its members can be accessed and activated in another method which will actually implement those features

This is the most simplest way I can think of.

I hope this is what you are looking for
Was This Post Helpful? 0
  • +
  • -

#3 fairie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 22-April 09

Re: Choose your own adventure style game

Posted 28 May 2009 - 05:59 PM

Hn, I was more looking on how to actually process the choices then how to go about storing the things - not that this isn't helpful either.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1