I am currently making a game and am working on the town code right now. I have booleans for the areas in and out of the town, but when I go to leave an area it resets me back at the beginning of the program. I have it set to when you go into an area, a boolean turns true and the area becomes available. But when I go to leave it keeps turning off the town boolean as well. I am using a simple 'quit' or 'leave' command to leave the areas.
(I am utilizing IF statements for the areas)

(Text-Based Java Game)

Any advice on this would be appreciated.

When I type 'quit' or any word that is not available it also return me to the beginning.

I changed the IF statements to WHILE loops and now it keeps me in the correct area.

Your character should have struct members which define all his attributes in any given area. If not, the area should have that info, so your player has everything he's earned, wherever he goes (some of it may not be functional in some area's, but he still has it).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.