Mutiny - Game Engine

Getting Started

Initializing Mutiny

Starting the Mutiny main loop differs slightly from Unity since the editor and output targets usually manage the application entry points for you. For Mutiny the process is still very simple however and all it requires is that one of your C++ unit files (.cpp) contains a typical main function as shown below.

int main(int argc, char* argv[])
{
  return 0;
}

This will compile and run, however it wont do much since Mutiny is never initialized. It will immediately exit. So we need to call the initialize function of Mutiny.

int main(int argc, char* argv[])
{
  mutiny::engine::Application::init(argc, argv);

  return 0;
}

You will now see a window appear and disappear very quickly. This is because Mutiny prepares the rendering context but then immediately exits. What you now need to do is instruct Mutiny to actually run (by going into its main loop).

int main(int argc, char* argv[])
{
  mutiny::engine::Application::init(argc, argv);  
  mutiny::engine::Application::run();

  return 0;
}

You will now see that a window appears with a dark gray background. This means that the engine is ready to add new GameObjects and cameras etc. Once you close the window, the run function will return and the application will exit. We are next going to add our first GameObject which will be a camera. For this we will add an empty GameObject (called "Camera") to the scene and attach the Camera behavior to it.

using namespace mutiny::engine;

int main(int argc, char* argv[])
{
  Application::init(argc, argv);
  
  GameObject* cameraGo = new GameObject("Camera");
  cameraGo->addComponent();
  
  Application::run();

  return 0;
}

Remember that this needs to be done after Mutiny is initialized but before it is run otherwise the program will wait until Mutiny is finished before attempting to add the Camera. You should now see a blue screen which is the default background color of the Camera. From here you should now be able to add more GameObjects with Behaviors specific to your game. Then you can simply override the onAwake, onStart, onUpdate, etc. methods just like you would in Unity.





(Return to Mutiny Home Page)

Copyright © 2014 Karsten Pedersen. All Rights Reserved.