So, I've started working on my own little 2d rpg game, but I have a few questions.
Obviously the game will have several different screens. A menu when you start the game, where you can choose a new game, load, exit, that kind of stuff. Some of those choices will lead to other menus etc.
There's also the game screen, after you start a new game/load a game. In this screen there'll be several small menus, like character pane etc.
The way I'm doing it right now is having a Screen interface which all the other screens will be extending, so that I can do something like:
1
| Screen screen = new mainMenu(this); |
Also for the mouse/keyboard input I'm doing this:
1 2 3
| im = new inputManager(); im.delegateInputTo(screen); this.addKeyListener(im); |
This way the menu screens will know if the up/down/whatever-key was pressed and act accordingly.
Is this the "right" way to do it? Also, the screens aren't really the ones to control anything, are they? I mean, they're just graphical things that should get painted.
So where would I have the input to actually move the protagonist around?