Congratulations on getting Kraken Engine installed! This page helps you launch your first window with in-depth descriptions of what each line means.
Quickstart with the CLI (Optional)
If you want a ready-to-run window template, you can generate one with the built-in CLI:
kraken init my_project
cd my_project && python main.py
Usage:
kraken init [-h] [-f] [--demo] [path]
path: Folder to create the project in (defaults to current directory)-f,--force: Overwrite an existingmain.py--demo: Generate starter code with text and shape rendering
Starter Code Snippet
If you prefer to write it manually, use the following:
import pykraken as kn
kn.init()
kn.window.create("Kraken Example", 900, 500)
while kn.window.is_open():
kn.event.poll()
kn.renderer.clear()
kn.renderer.present()
kn.quit()#include <kraken/KrakenEngine.hpp>
int main() {
kn::init();
kn::window::create("Kraken Example", 900, 500);
while (kn::window::isOpen()) {
kn::event::poll();
kn::renderer::clear();
kn::renderer::present();
}
kn::quit();
return 0;
}
Breakdown
This simple program serves as a basic skeleton for applications built with the Kraken Engine. Let’s break down the key components that make this program function:
- Initializing Kraken Engine
kn.init()prepares the underlying frameworks and features, ensuring the engine is ready to deliver everything it promises.
- Creating the Window
kn.window.create("Kraken Example", 900, 500)creates the window with a size of 900x500 pixels and a title of “Kraken Example”.
- Looping and Event Polling
- The
while kn.window.is_open():loop keeps the application running as long as the window is open. Inside it,kn.event.poll()updates internal event states like keyboard, mouse, and controller user input.
- The
- Rendering
kn.renderer.clear()overwrites the back buffer’s pixels to prepare for new drawing operations.
- Presenting the Frame
kn.renderer.present()copies the back buffer to the screen with any drawing commands issued since the last clear.
- Cleanly Quitting the Application
- Once the window is closed, exiting the main loop,
kn.quit()safely shuts down the engine and frees any resources in use.
- Once the window is closed, exiting the main loop,
This template establishes a foundation for more advanced game logic and rendering.