Original Post
Hello, and all that.
Being a fan of the numerous incarnations of Bomberman on the SNES, I decided it would be fun (and good practice) to create a Java version of the classic game. The following is just how I expect my game/menu system to function. All I ask is advice and suggestions, if any.
The system:
The system is composed of three main components: a Screen, a ScreenDisplay and AbstractMenus.
Screen - an abstract representation of any screen the game could display, such as the key binding screen, or the map select screen.
ScreenDisplay - responsible for displaying a Screen. ScreenDisplay uses a fixed time step scheme** to alternatively "step()" and "draw()" the screens. Input is initially handled by the ScreenDisplay (to check for ESC presses) then passed to the Screen. Input is tentatively modeled as an array of booleans representing keyDowns (suggestions are welcome here).
AbstractMenu - an extension of Screen representing a basic menu (since all menus appear on the same animated background). Specific menus extend this class to implement thier own functionality.
Menus are keyboard only (for the retro feel) and are created with CyclableMenu and CyclableMenuItem***. Key presses captured by the menu are sent to the CyclableMenu, which handles moving the selection cursor and cycling through choices.
When a screen is exited (enter is pressed), the menu logs all of its data to a static Configuration class which the game reads during initialization. The menu then proceeds to tell the ScreenDisplay which menu to load next (i.e. display.setScreen(NEXT_SCREEN) )
The game itself will be represented by a Screen (including the win/draw/match victory screens), since all it needs to run is step() and draw().
A drawback of this method is that menu flow needs to be hard coded.
Advice? Suggestions? Please!?
Thanks!
**Taken from the article at [url=http://www.flipcode.com/cgi-bin/msg.cgi?showThread=Tip-MainLoopTimeSteps&forum=totd&id=-1]flipCode[/url]. Ensures that the logic is run at a fixed rate (say, 15Hz) regardless of the frame rate the machine is achieving.
***A list of items, with a cursor pointing to the currently selected item. Each item in the menu has a number of states which can be cycled through.