What specific part of a game engine do you want to know how to create? Asking "how do I create one" is like asking "How do I make a car?"
Game Engines can be massive pieces of software that consist of a dozen subsystems. Think of a Game Engine as a collection of subsystems that all work together to govern how a game performs; it's logic like collision detection, rendering of images, handling user input from the mouse and keyboard, and audio support for playing sound effects and music, among others, each represent a separate subsystem the determines the rules of the game. Your input handling subsystem for example will determine what actions the system must perform if you press the 'w' key or right click with the mouse.
As an example of how a subsystem might work: within any game you have your main game loop. Basically the way it works is each iteration of the game loop will, for example, accept user input, update the coordinates of graphics, etc... depending on the users interaction and the game/object states.
Since a Game Engine is really a massive collection of objects interacting with each other, the game engine monitors the states of each object and will execute tasks against them. For example you may have something as simple as this:
1 2 3 4 5 6 7 8 9 10 11
|
class Player
{
public:
private:
short int hitPoints;
short int magicPoints;
int xCoordinate;
int yCoordinate;
};
| |
At any given time the game knows where player is in the world and can update it's x/y coordinates based on players interactions. Say for example you hit the 'w' key, then the input system may know to increase your coordinates and move your player up. Your rendering subsystem may then update the screen to show your player move. Ultimately the best way to learn how to create a game engine is to try programming each of the subsystems and have them interact with each other. Again, this is just to nudge you in the right direction. Game Engines can be more complicated than most systems out there.
To give you a broad idea of the types of systems and their interactions, take a look at the engine architecture diagram for the C4 Game Engine:
http://www.terathon.com/c4engine/architecture.php. I also recommend reading the book Game Engine Architecture
http://www.amazon.com/Game-Engine-Architecture-Jason-Gregory/dp/1568814135. It is an advanced book on engine architecture, but it's the best on the market and my Architecture Bible.