I only remove the print statements not the methods.
Be very wary of attributing code problems to threads or other mysterious 'effects' - unless you've found the JVM bug-of-the-century it's much, much
more likely that it's a problem in your code.
Couple of suggested approaches:
Have you tried debugging the code line-by-line to see what's happening? Using print to dump out status messages is fine but adding a breakpoint to the update() method and stepping through the code is more likely to diagnose this problem.
Have you checked the various game-state getter methods for side-effects? e.g. accidentally changing the state when you're getting it.
That code is quite convoluted IMHO - it's difficult to follow so I'm not surprised you are having logic problems (not having a go here, just suggesting).
- Consider using a switch statement rather than lots of chained if...else clauses (assuming your game state thing is an enum).
- What is the need for three states? And are you sure you're getting/setting the right one in each case?
- Maybe strip the code right down / comment it out and start with the first couple of state changes, if that works add the next one, and so on.
I assume this is a SWING based game? Is the while statement running in it's own background thread? Are the various methods that change the game (e.g. reestablishRoom) correctly modifying the GUI on the event-dispatch thread?
I posted in the newbie section because I'm learning and consider myself a newbie. I would assume it would be expected that I would be lacking knowledge and proper skills. I've read a book and have read a lot of those tutorial however doing things in a tutorial or book is different from trying your own project.
With that said I'm sure the problem is my code/lack of knowledge. Which is why I posted the question so I can learn what may be the issue.
I have all getters only return and nothing for test. Like I said the code works when the system.out statements are in place. Yes it is a enum I can use a switch statement. Is that really better or just do you feel its more proper.
yes I've made sure the right things are being called and tested. The states are used to move the game between main menu, normal moving around, battles, and inventory.
I'll strip it down and try that out.
I haven't created any additional threads.
Anyways Thank-you for your help I'll look into those things.
Thank-you everyone for your help.