Getting Started

Creating a Window

After following the Installation guide, you are ready for your first Kraken Engine program.

 1#include <KrakenEngine.hpp>
 2
 3int main()
 4{
 5    kn::window::init({ 800, 600 });
 6    kn::time::Clock clock;
 7
 8    bool done = false;
 9    while (!done)
10    {
11        clock.tick();
12
13        for (const auto &event : kn::window::getEvents())
14            if (event.type == kn::QUIT)
15                done = true;
16
17        kn::window::cls();
18        kn::window::flip();
19    }
20
21    kn::window::quit();
22    return EXIT_SUCCESS;
23}

This code opens a window and closes it when the user presses the window’s X button. It also clears the screen every frame and flips the buffers. The clock.tick() function returns the time elapsed since the last call to clock.tick() in seconds.