what's a game engine?

This is a discussion on what's a game engine? within the Game Programming forums, part of the General Programming Boards category; I've read many articles on this topic but all they tell me is that the game engine is the reusable ...

what's a game engine?

I've read many articles on this topic but all they tell me is that the game engine is the reusable part of a game. Is it supposed to be a reusable code or is it a reusable executable file that you link DLLs to? Or can it be either? Some articles I've read tells me that the executable i open to start a game is the engine and when i google for open source engines, i get all these "GUI libraries" as I like to call then, like allegro, ogre, etc.
I have a basic idea of what a game engine is supposed to do but I'm not too sure how to go about writing one and what kind of things to include in it.

Well the engine of a game works like...uumm...well....the engine. It drives the game. It includes fundamental parts such as your class inheritance, the way the game is to handle animations, models, and other things. If you create your own file type that will be part of the engine and you will probably have some function to read your unique files. Are you getting the idea? Start by thinking about organization and classes. All the fundamental functions that your program will need to run the game. A good place to start is a movement system I think. One that people use a lot is the quake engine.

I've read many articles on this topic but all they tell me is that the game engine is the reusable part of a game. Is it supposed to be a reusable code or is it a reusable executable file that you link DLLs to? Or can it be either?

Graphics libraries I think would be a more appropriate name, but allegro handles things related to games other than graphics too says wikipedia. For future reference (don't even know how you missed it this time) use wikipedia.

A lot of general facts have been stated, which are all correct and helpful. I will try to give you a concrete example to work off of. I am actually currently working on my own game project right now, and I am being careful to keep the "engine code" and "game code" separate, so that I might be able to reuse the engine code in the future.

In my engine, which is still currently under development, this is what I currently have:

A Sprite class which handles any non-animated images that will be used in the project. An Animation class (which has along with it two other associated classes called AnimationData and AnimationManager) which handles all animations that will be used in the game.

There is also a tile engine, consisting of a Terrain class, which represents one piece of terrain on a game map (along with it is a TerrainManager), and a Map class, which handles all maps to be used in the gaming project.

I am currently in the process of building an entity tree/structure, which right now only consists of an Entity class, but will consist of more soon to come.

There is much more I need to do to complete the engine, but there are also many areas where I am approaching what becomes the border of the engine, and then we enter into the game code.

For example, as entities are on my mind of late, Entity is something generic that any game would need, and so it is engine code. However, a warrior or an archer are game specific entities, and should not be included in the engine, but instead be included in the game code. That is one concrete example of a difference between the two.

There are some aspects as well where AI might overlap. Much of your AI might be in the engine code, but there are certain aspects that are probably game specific. Pathfinding, for example, is probably something that will be on the engine side of things.

btw, what's this manager class you speak of? What is it supposed to do?

I'm not sure how DavidP uses his manager classes, but mine are basically classes that keep track of objects and entities. For example, I have a world class, and then a world manager that keeps a vector of worlds, and contains functions for creating and deleting worlds. I do the same with textures and shaders as well.

"Manager" classes are considered bad. The methods and data of your manager classes should be static members of the class that they are "managing".

I would agree with this in principle perhaps, except just for the heck of it, I'd like to throw something out here for people to comment on.

The Unreal Engine, for those that don't know already, is a game engine that starts up a virtual machine where the language of choice for it is a Java-like language call UnrealScript or UScript for short. UScript does not have static variables, interestingly enough, and therefore they rely on a lot of "manager" classes or the like.

Why UnrealScript does not support static variables: While C++ supports static (per class-process) variables for good reasons true to the language's low-level roots, and Java support static variables for reasons that appear to be not well thought out, such variables do not have a place in UnrealScript because of ambiguities over their scope with respect to serialization, derivation, and multiple levels: should static variables have "global" semantics, meaning that all static variables in all active Unreal levels have the same value? Should they be per package? Should they be per level? If so, how are they serialized -- with the class in its .u file, or with the level in its .unr file? Are they unique per base class, or do derived versions of classes have their own values of static variables? In UnrealScript, we sidestep the problem by not defining static variables as a language feature, and leaving it up to programmers to manage static-like and global-like variables by creating classes to contain them and exposing them in actual objects. If you want to have variables that are accessible per-level, you can create a new class to contain those variables and assure they are serialized with the level. This way, there is no ambiguity. For examples of classes that serve this kind of purpose, see LevelInfo and GameInfo.

Thoughts and comments?

Are manager classes a bad choice for a game engine? Should a game engine provide for better means of managing their data?

Without object managers you will have something just short of an object oriented disaster.

The goal of object oriented managers or more appropriately containers is just that. They contain and manage a set of objects. Using the container approach you would run every request and every action through the container first. No one else has permission to touch, alter, or delete the objects in the container except for the container. This means that all operations on objects are centralized and you know exactly who and what is creating/destroying objects and you also know when they are being destroyed.

Containers are a very good way to ensure you do not leak memory here and there since they alone are responsible for destroying objects. If you leak memory from a certain object or objects then you simply look in the container class to find out why it is leaking memory.

My entire system operates on this principle and while not the easiest to implement it does offer many benfits. In my system there is a base class that every object is derived from. If you understand COM programming you would understand my system. The base object class does next to nothing but implements a few base functions. The derived classes then perform the bulk of the operations on the objects they implement. Each container class is also derived from a base container class which implements basic operations such as adding and deleting objects as well as returning object counts. The derived container classes then begin adding to this foundation and implementing functions as needed.

I have a basic idea of what a game engine is supposed to do but I'm not too sure how to go about writing one and what kind of things to include in it.

There are probably more opinions about what a game engine is/isnt than there are programmers. So heres my 0.02 worth:

A game application consists of three parts, The game engine, the application specific code, and the game data:

The game engine itself is the generic, retargetable code that handles the grunt tasks such as user input, menues, graphics output, sound etc.

The application specific code is the part of the code that handles things that are , well, specific to that game, such as weapons, spell effects, AI etc.

The game data is the stuff like graphics, sound effects, intro movies, weapon range/damage values, etc.

Generally, the game engine will only change when something like DirectX changes. The application code will change with every new iteration of the game ( Awsome Dungeon Romp v1.0 , v2.0 , v37.0 etc. ), and every update or bugfix. The game data will generally only change during bugfixes or playbalancing. i.e the BFS-9k does 200-300 slashing dmg, which is too weak, so you change it to do 300-400. No change in the code would be necessary.

Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.