I'm working on some starter materials for myself and the community and I wanted to talk to new and experienced developers about their best practices.
Specially, I want (in this post) to talk about the game module.
Before I proceed, let me clearly define what I mean by 'game module'.
In this discussion, a game module is a single file (usually called game.lua).
This file contains/defines a module that has all of the responsibility for creating, destroying, and in general managing game objects, game data, and game-play logic.
For all but the simplest games, a game module will often include/require other modules to do its work. i.e. It is not monolithic.
A game module is NOT responsible for:
- splash screen
- main menu
- help screens
A game module may however implement/manage, HUDS:
- score count(s)
- coin coin
- damage indicators
My Game Module(s) Approach
In my games, the game module may have any of the following functions:
- init() - One time module initialization.
- create() - Create the game world/content + (optionally) start game logic.
- destroy() - Destroy all groups and game content + (optionally) stop game logic.
- start() - Starts game logic.
- stop() - Stop game logic. Usually as the result of of of these:
- Level or Game Loss
- Player Death
- Level Completion
- Game Completion
- continue() - Resumes a game after player death without starting over at the beginning.
- restart() - Restarts the game afresh from the same coditions as the last create() and/or start().
- pause( pause ) - Pauses or resumes game interaction and logic.
Legend: required optional
- Are you a new or experienced game developer?
- Do you use the concept of a game module?
- Do you use some or all of the functions I use?
- If you do not use a game module, how do you organize your game logic?
- If you do use a game module and it is different from mine, can you describe yours?
- Was this an interesting discussion and would you like more discussions like this here?