Sly Engine
Basic Demo

This is a basic demo. More...

Collaboration diagram for Basic Demo:

This is a basic demo.

The beginning of a game must have two major components. We need a scene and we need an object. This tutorial is aimed at getting started with these basic components.

To begin, you will need to create a named scene that inherits from the class Scene.

//TankScene.h
class Tank; // Forward declaration
class TankScene : public Scene {
public:
// We do not create objects at construction
TankScene() = {};
~TankScene() = {};
// Create objects within initialization
void Initialize() override;
void SceneEnd() override;
private:
// Our object
Tank* tank;
}

This is the end of our basic scene header. We next need to setup the Initialize and SceneEnd functions to load in our game object. For further details about setting up the game object and loading in the model, textures, and shader see the Getting started section.

// TankScene.cpp
... // Load in the appropriate headers
TankScene::Initialize() {
pFrigate = new Frigate();
pFrigate.setPosition(Vect(40, 10, 40)); // This can also be done at construction
}
TankScene::SceneEnd() {
delete pFrigate;
}
Scene::SceneEnd
virtual void SceneEnd()=0
Shuts down the scene. Put scene related end tasks here.
Scene
Definition: Scene.h:21
Scene::Initialize
virtual void Initialize()=0
Initializes the scene. Put scene related startup here.