The future is here. Let's make some games!
Download Docs as ZIP
I've been doing a lot of minigames
& participated in various game compos
I've been developing a ruby gamedev lib
for a couple of years.
Jaws implements a super simple but robust game state system which can be used to organize different sections of your game neatly.
In jaws, a game state is an object that responds to setup(), update() and draw(). It doesn't have to respond to all three, but a game state Not responding to update() Or draw() will be pretty pointless.
The idea is that we put the initialization in setup(), game logic in update() and drawing in draw(). I've seen various other libs that don't make the update() / draw() separation and only have one method.
I strongly believe it's a good idea to separate them. This will enable us to do some cool things in the future.
Game state ideas
Jaws can ship with some premade game states, for example a EditState().
EditState() would call draw() on the previous game state, jaws.previousGameState, but skip update(), effectively pausing the game.
Then it implements its own edit-logic in its own update().
Or a PopupState() could call draw/update on the previous game state but then draw a semi-transparent layover with some messages/options.
Many interesting possibilities open up with good game state separation.
Controlling the game flow
Game states are used to control the game flow. We start out in the welcome menu: jaws.start(MenuState).
The gamer chooses "Start": jaws.switchGameState(PlayState)
When he dies we'll switch back to MenuState, or maybe HighScoreState.
It's very possible we could reuse the HighScoreState for our next game.