Forum Thread
  Posts  
Eclipse Text Adventure Game [HELP] (Forums : Coding & Scripting : Eclipse Text Adventure Game [HELP]) Locked
Thread Options
Jan 28 2013 Anchor

So this is one of the first programs I've made, I have been using a guide but it was very vague and it ended before telling me how to create a second option.
My problem is when the play answers the first question in the game the second question appears, but the player can't type anything into the console anymore.

My code:

import java.util.Scanner;


public class Kynarthain {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
			System.out.println("You awake in a burning forest and are presented with 3 items.");
			System.out.println("A Key, A Map and A Sword.");
			System.out.println("You only have time to choose which item, which item do you choose?\n\nOptions:\n1:The Key\n2:The Map\n3:The Sword");
			
		int a = s.nextInt();
		
		switch (a) {
		case 1:
			System.out.println("You grab the key and run as fast as you can away from the fire");
			System.out.println("Sadly their is a locked gate in your way but your key manages to unlock it");
			System.out.println("Eventually you end up at a fork in the road");
			System.out.println("You can either choose the Path of Dismay, or the Road of Broken Dreams\nOptions\n4:Path of Dismay\n5:Road of Broken Dreams");
			break;
		case 2:
			System.out.println("You grab the Map and run as fast as you can away from the fire");
			System.out.println("Using your map you notice there's a locked gate ahead, so you use the shortcut shown on your map");
			System.out.println("Eventually you end up at a fork in the road");
			System.out.println("You can either choose the Path of Dismay, or the Road of Broken Dreams\nOptions\n6:Path of Dismay\n7:Road of Broken Dreams");
			break;
		case 3:
			System.out.println("You grab the Sword and run as fast as you can away from the fire");
			System.out.println("Eventually you reach a locked gate, you make a desperate attempt to look for another way.");
			System.out.println("You find another gate but there's a demonic fiend guarding it.");
			System.out.println("You pull out your sword and with a swift blow it's gone.");
			System.out.println("You walk out of the burning forest unscathed.");
			System.out.println("Eventually you end up at a fork in the road");
			System.out.println("You can either choose the Path of Dismay, or the Road of Broken Dreams\nOptions\n8:Path of Dismay\n9:Road of Broken Dreams");
			break; 
		}
		
		switch (a) {
		case 4:
			System.out.println("1");
			break;
		case 5:
			System.out.println("2");
			break;
		case 6:
			System.out.println("3");
			break;
		case 7:
			System.out.println("4");
			break;
		case 8:
			System.out.println("5");
			break;
		case 9:
			System.out.println("6");
			break;
		}
	}
}

Please don't troll or hate.

Jan 28 2013 Anchor

you need to put your game in a loop(while())
also,you need to save the path of question answering

Edited by: colonyassault

Jan 28 2013 Anchor

I'm sorry I'm new and I don't understand what you mean.

Jan 28 2013 Anchor

Its ok , I was just bored.Good luck.

Jan 29 2013 Anchor

colonyassault is right. The guide may seem vague because it expects you to know the basics of programming.
There are plenty of programming guides in both written and video form on the internet. You could start here: Thenewboston.org which is convenient as it transitions into Intermediate Java and will eventually cover a simple Java game.
If you want to make text-based adventures then you should work with Twine.

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.