A general game engine, which can be reused to create many different games, can be extremely useful, but can also be very difficult to design and implement. The goal is to create games simply by creating game content and letting the engine handle all the hard work. A great deal of work can go into this endeavor. However, an engine can be as simple or complex as a programmer wants it to be. The more complicated, the less the game creator would have to do to create a game, but simpler engines are much easier to implement and can get a game up and running much quicker.
Design the basics of the game engine. These include things like the memory manager, the kernel, and the loggers that will be used by all components of the engine. A memory manager creates a uniform interface for game object creation, and allows you to track memory usage throughout the program. The kernel is the guts of the game engine, the thing that is run every frame that makes sure everything else runs. Loggers are invaluable, and should be a part of any complex program.
Create a general design for a game engine that suits your needs. The main components of the engine are the input component, the game state updater, and the rendering component. The input portion takes user input and translates it to something the game state updater can handle. The game state updater handles the input to update the state of the game. The rendering engine draws the game state to the screen. These can each be as complicated or simple as you need them to be.
Design and implement the input component. This will often depend on the system the game is to be used on, and a more complex design will allow use on multiple operating systems and hardware configurations. The input engine should accept input from key, mouse, joystick, and possibly other human-computer interface devices and translate them into values that are meant to update the game state. It might be useful to create a tool that maps certain inputs to game actions.
Create the game state updater. This is often the most complex component of the game engine. It will handle the game rules, game physics, and any networking the game may need. A lot of time spent designing this portion can save many headaches later.
Create the rendering engine. The complexity that this component needs depends greatly on the game itself. Often, 3D games will have very sophisticated rendering engines in order to create the most visually stunning graphics possible while trying to use as little of the system resources as it can. Sometimes, though, things just need to be drawn to the screen, such as in a poker game, and the programmer need not care much about how the system resources are used.
Create tools for the various components. Tools, in this context, are programs that allow game creators to add content or configure components for a specific game. For example, an input tool would allow a content creator to map keyboard inputs to various game actions, where a tool for the rendering engine could allow a designer to devise a graphical user interface for a game. Tools also allow you to test the components of your game engine without actually running an entire game, and can help lead to better designed components.
Tips & Warnings
- The more time you spend coming up with a good design, the more time you will save later when you have to make a game work using your engine.
- Design the engine to suit your needs. Make it as complex or as simple as you need it to be. It is not necessary to have a renderer capable of drawing incredibly complex scenes in real time when you just want to make card games.
- Book: "3D Game Engine Design: A Practical Approach to Real-Time Computer Graphics;" David H. Eberly; 2001
- Enginuity by Richard Fine