Need help with text adventure game

  • (6 Pages)
  • +
  • « First
  • 4
  • 5
  • 6

79 Replies - 4676 Views - Last Post: 25 September 2016 - 02:51 PM Rate Topic: -----

Poll: Title of my rpg (3 member(s) have cast votes)

What should the title of my rpg be? (Scary/Mystery Genre)

  1. The Room (0 votes [0.00%])

    Percentage of vote: 0.00%

  2. Deserted (2 votes [66.67%])

    Percentage of vote: 66.67%

  3. Dont care as long as its a cool game (1 votes [33.33%])

    Percentage of vote: 33.33%

Vote Guests cannot vote

#76 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 870
  • View blog
  • Posts: 6,695
  • Joined: 25-December 13

Re: Need help with text adventure game

Posted 25 September 2016 - 01:21 PM

@jon Could you fix your post. The forum's formatter has turned some of the code into happyfaces.
Was This Post Helpful? 1
  • +
  • -

#77 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 12350
  • View blog
  • Posts: 20,984
  • Joined: 19-March 11

Re: Need help with text adventure game

Posted 25 September 2016 - 01:25 PM

Fixed, thanks for the heads-up
Was This Post Helpful? 0
  • +
  • -

#78 Toshritzy   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 22-September 16

Re: Need help with text adventure game

Posted 25 September 2016 - 01:43 PM

View Postjon.kiparsky, on 25 September 2016 - 02:17 PM, said:

de Morgan's laws will be very helpful to you in the future:

if (!P && !Q) is equivalent to if !(P || Q), and similarly if (!P || !Q) is equivalent to if !(P && Q)

Deriving these laws is a useful exercise, I leave it to you if you want to pursue it.

I still think that you'd find this whole business a lot easier if you took the time to extract some shorter functions from this. I get the sense that you're getting lost in the excess complexity.


I would start by getting all of that title stuff out of there. Call it a function, move it somewhere where you don't have to look at it - right there, you're going to feel better looking at all of this. Then you have two things that you might as well call firstQuestion() and secondQuestion() for now. That will change before you're done, but do one thing at a time.

Once you've made those changes, you can focus in on getting that conditional to work right. While you're doing that, you might come up with a way to capture this logic once, as a function, which will save you a lot of debugging.

But you might also want to ask yourself - how many of these functions are you going to have to write? If we assume that you're going to have two choices at each turn, how many total options are you dealing with after eight turns? After sixteen? Contemplating these figures might inspire you to reconsider your design approach.


Thank you so much for all of that great advice. After one question is answered my mind is cluttered with new questions. How will I be able to run this outside of eclipse. I've never actually exported anything. How can I make a save and load option in the game. If I take the title and put it into another class with the title of mainmenu then how do I get that main menu to show up before the main method and have an option to go into the main method from their. Im very new to all of this and I am learning tons more every day. Thank you all for your help.

This post has been edited by Toshritzy: 25 September 2016 - 01:43 PM

Was This Post Helpful? 0
  • +
  • -

#79 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 12350
  • View blog
  • Posts: 20,984
  • Joined: 19-March 11

Re: Need help with text adventure game

Posted 25 September 2016 - 02:22 PM

Let's worry about one conundrum at a time, how's that?
Was This Post Helpful? 1
  • +
  • -

#80 Toshritzy   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 22-September 16

Re: Need help with text adventure game

Posted 25 September 2016 - 02:51 PM

View Postjon.kiparsky, on 25 September 2016 - 03:22 PM, said:

Let's worry about one conundrum at a time, how's that?


10/10. Im just really excited to see what I can do with this game. So how about how to get a main menu working. So I just threw together this basic main menu code. First thing I would like to do is figure out how to run that code first instead of my main class.



import java.util.Scanner;

public class Menu {
	
	public static void mainMenu(String[] args) {
		
				//Scanner
				@SuppressWarnings("resource")
				Scanner input = new Scanner(System.in);
				String choice;
		
				//Title of the game		
				System.out.println("\n\n\n ▄▀▀█▄▄   ▄▀▀█▄▄▄▄  ▄▀▀▀▀▄  ▄▀▀█▄▄▄▄  ▄▀▀▄▀▀▀▄  ▄▀▀▀█▀▀▄  ▄▀▀█▄▄▄▄  ▄▀▀█▄▄ ");
				System.out.println("█ ▄▀   █ ▐  ▄▀   ▐ █ █   ▐ ▐  ▄▀   ▐ █   █   █ █    █  ▐ ▐  ▄▀   ▐ █ ▄▀   █ ");
				System.out.println("▐ █    █   █▄▄▄▄▄     ▀▄     █▄▄▄▄▄  ▐  █▀▀█▀  ▐   █       █▄▄▄▄▄  ▐ █    █ ");
				System.out.println("  █    █   █    ▌  ▀▄   █    █    ▌   ▄▀    █     █        █    ▌    █    █ ");
				System.out.println(" ▄▀▄▄▄▄▀  ▄▀▄▄▄▄    █▀▀▀    ▄▀▄▄▄▄   █     █    ▄▀        ▄▀▄▄▄▄    ▄▀▄▄▄▄▀ ");
				System.out.println("█     ▐   █    ▐    ▐       █    ▐   ▐     ▐   █          █    ▐   █     ▐  ");
				System.out.println("▐         ▐                 ▐                  ▐          ▐        ▐        \n\n\n");
				
				//New Game
				System.out.println("New Game");
				//Continue
				System.out.println("Continue");
				//Help
				System.out.println("Help");
				//Quit
				System.out.println("Quit");
				//Explanation 
				System.out.println("Type one of the choices and hit enter");
				
				choice = input.nextLine();
				
				while(choice.equalsIgnoreCase("New Game") && choice.equalsIgnoreCase("NewGame") && choice.equalsIgnoreCase("Continue") && choice.equalsIgnoreCase("Help") && choice.equalsIgnoreCase("Quit")) {
					System.out.println("Invalid Entry");
        			choice = input.nextLine();
				}
				//New Game choice
				if(choice.equalsIgnoreCase("New Game") && choice.equalsIgnoreCase("NewGame")) {
					
				} else
					
				//Continue choice
				if(choice.equalsIgnoreCase("Continue")) {
					
				} else 
				//Help choice
				if(choice.equalsIgnoreCase("Options")) {
						
				} else
				
				if(choice.equalsIgnoreCase("Quit")) {
			           System.exit(0);	
		}
	}
}

This post has been edited by Toshritzy: 25 September 2016 - 02:54 PM

Was This Post Helpful? 0
  • +
  • -

  • (6 Pages)
  • +
  • « First
  • 4
  • 5
  • 6