Ketchup Engine
Loading...
Searching...
No Matches
Getting Started - Creating an EngineSettings Class

Creating an EngineSettings Class

In order to set up our Ketchup environment, we will have to create a class that inherits from EngineSettings. We will override the EngineSettings::InitGame(), EngineSettings::EndGame(), and EngineSettings::LoadResources() methods to define our preferred behavior when setting up and ending the game.

#include "EngineSettings.h"

class TutorialGameSettings : public EngineSettings
{
public:
    TutorialGameSettings() = default;
    TutorialGameSettings(const TutorialGameSettings&) = delete;
    TutorialGameSettings& operator = (const TutorialGameSettings&) = delete;
    ~TutorialGameSettings() = default;

private:

    void LoadResources() override;
    void InitGame() override;
    void EndGame() override;

};

LoadResources()

We'll skip adding anything to EngineSettings::LoadResources, but we'll come back to it in a future tutorial.

InitGame()

In our implementation of EngineSettings::InitGame(), we'll set some settings that Ketchup will use to set up its window.

void TutorialGameSettings::InitGame() {
    SetWindowName("Ketchup Engine Demo");
    SetWidthHeight(1280, 720);
    SetVsync(0);
    SetClearColor(0.4f, 0.4f, 0.8f, 1.0f);
}

This method will be automatically be called by Ketchup before starting up the game.

EndGame()

EngineSettings::EndGame() will be empty for now, but we can use it to clean up after the game runs. Ketchup will also automatically call this method at the end of our game's runtime.

Attaching to Ketchup

We need to attach an instance of our class to Ketchup for the engine to use the behavior we defined. We'll go over how to do this in the next tutorial where we set up main.