I’m starting a project that will start at a login screen, move to a lobby system, and then the game will start. How would you guys go about designing the flow of your application? Would you have a Game class with the main method your game loop and your different menus? Or would you have a MainApplication class, that will only create the window, and have that create a LoginScreen, which calls the Lobby, which calls the Game class?
Usually some kind of handler, that has all of the different screens needed. The application goes back up, and changes what screen to render as it runs.
I use a statemanager that uses a String “state” and a “setState”. When I need to change state (ESC is pressed or something) I simply do
main.setState = "menumain";
and in the main method
public void tick()
{
ticks++;
this.state = statemanager.state;
if ((setState != state) && (!setState.equals("null")))
{
if (setState == "quitting")
{
if (!applet) stop();
if (applet) setState = state;
}
statemanager.setState(setState);
setState = "null";
}
This just sets the state only if setState is not equal to null and setState does not equal to state. This probably isn’t the best way to do it, but it works for me.
Don’t use == and != to check for String equality!!! Use the equals(String) method!!! T______T
Also, why Strings? this will cause your tick and render methods to have loooong if-else statements! It is best to have a class called Screen and then the main class just calls the Screen’s update and render methods.
OFFTOPIC:You are the most knowledgeable 16 year old programmer I’ve ever seen. I just can’t get over how you know so many things even though you’re only 16! Most 16 year olds use things like game maker or something, and call themselves programmers, but your ability far surpasses mine! (That’s not saying much, though, because my ability is pretty bad.) Sorry to go off topic, just wanted to make sure you knew how intelligent you are, lol.
When you think about it, someone 16 years old who started at 7 or 8 has already got the sort of experience that normally triples someone’s salary in the real world… start young and you will be an absolute master by the time you’re 30.
I apologize for my terrible error with those strings hahaha. I try to always use .equals, but that time I just forgot and it worked so I didn’t catch it.
I am 17 and started at 12 programming on my TI-83 calculator