TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
HowTo: Start a Game Project

Provides a high level look at creating a Two-Dimensional Game using TurtleBrains.

Starting your first game with TurtleBrains

  1. Derive a custom class for a scene from TurtleBrains::Game::GameScene
  2. Create an instance of the TurtleBrains::Game::GameApplication
  3. Call RunGame(gameScene) and watch the magic unfold

Create your game scene

The most involved step will be creating the gameplay scene, a class derived from TurtleBrains::Game::GameScene that manages the objects and logic for the game.

my_game_scene.h

#ifndef _Example_MyGameScene_h_
#define _Example_MyGameScene_h_
#include "turtle_brains/tb_game_kit.h"
class MyGameScene : public tbGame::GameScene
{
public:
MyGameScene(void);
virtual ~MyGameScene(void);
protected:
virtual void OnSimulate(void) override;
virtual void OnUpdate(const float deltaTime) override;
virtual void OnRender(void) const override;
virtual void OnOpen(void) override;
virtual void OnClose(void) override;
private:
};
#endif _Example_MyGameScene_h_

my_game_scene.cpp

#include "my_game_scene.h"
#include "turtle_brains/tb_application_kit.h"
MyGameScene::MyGameScene(void)
{
}
MyGameScene::~MyGameScene(void)
{
}
void MyGameScene::OnSimulate(void)
{
}
void MyGameScene::OnUpdate(const float deltaTime)
{
if (true == tbApplication::Input::IsKeyPressed(tbApplication::tbKeyEscape))
{
}
}
void MyGameScene::OnRender(void) const
{
}
void MyGameScene::OnOpen(void)
{
tbGame::OnOpen();
}
void MyGameScene::OnClose(void)
{
tbGame::OnClose();
}

That will create an extremely basic scene presenting a black screen, pretty boring. From here you can load assets for the scene in OnOpen(), which is invoked just before the scene will be made active and visible. Also add any graphics and entities, bringing the scene to life.

Start and run the game.

With MyGameScene prepared, even as a mundane black screen, the game can get started. It is a simple process of creating an instance of GameApplication and invoking RunGame with the yet to be interesting MyGameScene.

main.cpp

#include "my_game_scene.h"
int main(int argumentCount, const char* argumentValues[])
{
tbGame::GameApplication gameApplication;
gameApplication.SetWindowTitle(tb_string("A TurtleBrains Game"));
MyGameScene myScene;
gameApplication.RunGame(myScene);
return 0;
}

That was short and simple, and results a blank, black screen. What fun that is!

Bring life into the game.

Now we can add awesome things to the game. [documentation still in progress, need to write a full sample project]