A game engine is a piece of software that is used to create many different sorts of games. A good, robust engine performs the tasks common to many games, so that game creators need only design the content, instead of reimplementing the same pieces for each game. The engine can be complex enough to handle 3-D online games, 2-D board games and online trivia games, or it can be designed simply to implement card games. Designing one can be a challenging endeavor, but one that can be very rewarding for game creators who wish to implement several games.
1. Create the basic tools the engine will use. You will need a memory manager, which each object created will use to allocate memory, so that you can keep track of memory use and clean up unused chunks. You should also build a logger, which will be used by the various components to keep track of what they do as they do it. Logging is invaluable for larger engines. You will also need a kernel, where the main game loop operates, and decides what task to perform next.
2. Design the game engine’s architecture. The main components of an engine are the input handler, the game state updater and the renderer. The input handler reads user inputs and translates them to commands the engine understands. The updater updates the game state based on the game rules, physics and AI. The renderer draws the current game state as the user is meant to see it.
3. Implement the input handler. You will want to be able to handle keyboard, mouse and joystick inputs, and leave room for other human-computer interaction devices. These inputs should map in an intuitive way to commands that get passed to the game state updater.
4. Create the game state updater. This will receive user inputs and update the game state based on them and the rules of the game. It can be the most complex component, as it will have to handle game physics, and allow game creators to implement game rules. If your games will be online, the network components go here, and it will take a lot of thought to decide which updates the server should perform and which tasks the client should handle.
5. Design and implement the rendering engine. This can also be very complex, but it doesn’t always need to be. If your games require cutting-edge 3-D graphics, you will want more from this component. How much time and effort you need to put into your renderer depends very much on the types of games you wish to create.
6. Test and debug the components. Consider devising tools that assist game creators using each component. These can be a good way to test the individual parts. You may also want to try creating a relatively simple game, to ensure that it is easy to implement one using your engine, and to confirm that the software you created works as intended.