IME

Welcome

Welcome to the official IME documentation. Here you will find a detailed view of all the classes and functions.

Getting started

IME is state based, which means that the game flow is controlled by pushing and popping game states at appropriate times. In IME everything lives in a ime::Scene. To get started, you must create a scene (or state), then instantiate a ime::Engine and initialize it (see ime::Engine::initialize). Finally, add a scene to the engine (see ime::Engine::pushScene) and run it (see ime::Engine::run). This will start the main game loop.

Here is the minimal and complete code to achieve the above steps:

// Includes the entire IME library, you can selectively include headers
// once you know whats going on
#include <IME/IME.h>
// Step 1: Create a ime::Scene
// You define the behavior of your game by overriding ime::Scene functions.
// These functions will be called IME at appropriate times.
// This scene displays a welcome message at the centre of the screen
class StartUpScene : public ime::Scene {
public:
void onEnter() override {
// Greet the user
auto greeting = ime::ui::Label::create("Welcome to Infinite Motion Engine");
greeting->setOrigin(0.5f, 0.5f);
greeting->setPosition("50%", "50%");
greeting->getRenderer()->setTextColour(ime::Colour::White);
getGui().addWidget(std::move(greeting));
// Quit the game when "Esc" key is pressed
getEngine().quit();
});
}
};
int main()
{
// Step 2: Instantiating a ime::Engine
// 2.1 - First we need to specify settings required by ime::Engine. These
// settings are optional. When not specified the engine will use
// default values
settings.addPref({"WINDOW_TITLE", ime::PrefType::String, std::string("IME Demo App")});
settings.addPref({"WINDOW_WIDTH", ime::PrefType::Int, 600});
settings.addPref({"WINDOW_HEIGHT", ime::PrefType::Int, 600});
settings.addPref({"WINDOW_ICON", ime::PrefType::String, std::string("assets/images/icon.png")});
settings.addPref({"FULLSCREEN", ime::PrefType::Bool, false});
settings.addPref({"FPS_LIMIT", ime::PrefType::Int, 60});
settings.addPref({"V_SYNC", ime::PrefType::Bool, true});
settings.addPref({"FONTS_DIR", ime::PrefType::String, std::string("assets/fonts/")});
settings.addPref({"TEXTURES_DIR", ime::PrefType::String, std::string("assets/textures/")});
settings.addPref({"SOUND_EFFECTS_DIR", ime::PrefType::String, std::string("assets/soundEffects/")});
settings.addPref({"MUSIC_DIR", ime::PrefType::String, std::string("assets/music/")});
// Step 2.2 - Instantiating and initializing the engine
ime::Engine engine("My Awesome Game v1", settings);
engine.initialize();
// Step 3: Push a ime::Scene and start the main game loop
engine.pushScene(std::make_unique<StartUpScene>());
engine.run();
return EXIT_SUCCESS;
}
static const Colour White
White colour.
Definition: Colour.h:39
Runs the main game loop.
Definition: Engine.h:55
Container for Preference instances.
Definition: PrefContainer.h:42
bool addPref(const Preference &pref)
Add a preference to the container.
@ String
std::string type (NOT "const char*")
A base class for game scenes.
Definition: Scene.h:63
input::InputManager & getInput()
Get the scene level input manager.
virtual void onEnter()
Handle a scene enter.
Definition: Scene.h:124
ui::GuiContainer & getGui()
Get the scene level gui container.
Engine & getEngine()
Get a reference to the game engine.
int onKeyUp(Callback< Keyboard::Key > callback)
Add an event listener to a key up event.
Key
keyboard key codes
Definition: Keyboard.h:56
@ Escape
The Escape key.
Widget * addWidget(Widget::Ptr widget, const std::string &name="")
Add a widget to the gui.
static Label::Ptr create(const std::string &text="")
Create a new label widget.