Libprimis
Imprimis' 3D destroyable world engine
|
Note that this is a draft and subject to expansion and modification.
An interface describes the behavior and capabilities of the game and its engine. They allow for a structured self-documenting object-oriented codebase with more predictable behaviors and outputs.
In C++, interfaces are declared in a header file (.h) and defined in a source code file (.cpp).
Below is a code example of an interface declaration and definition.
Take note of the implicit and explicit references to ExampleInterface
in both files.
To augment an interface, you need to understand the following:
To give an example, let's say you want to Set
a Player
's Weapon
.
As the target of our method is a Player
object, we will be placing it inside a Player
interface with the prefix Set
and the suffix Weapon
.
This logic helps keep the codebase self-documenting and the interfaces predictable. You will then be calling PlayerObject::set_weapon("pistol");
to access the method.
Standard interfaces are hard-coded in C++ and define the engine's capabilities.
The Game
interface keeps track of gameplay elements, such as players, weapons, projectiles as well as their states, properties and methods.