Files
project_misth/src/main.cc
T
2026-04-29 21:54:47 +01:00

70 lines
1.4 KiB
C++

#include "../include/window/window.h"
int main() {
printf("Starting engine...\n");
Window w({800, 600}, "Render Test");
ImageID img = w.load_image("./assets/images/arrow.png", true);
FontID font = w.load_font(
"./assets/fonts/charybdis.ttf",
24,
false,
false,
false,
true
);
TextID text = w.create_text(font, "Hello Engine", 12, {255, 255, 255, 255});
float t = 0.0f;
bool running = true;
printf("Entering main loop...\n");
int i = 0;
while (running) {
Event e;
while (w.poll(e)) {
printf("Event polled: %d\n", e.type);
switch (e.type) {
case Event::QUIT:
printf("Exiting\n");
running = false;
break;
case Event::KEY_DOWN:
printf("Key down: %d\n", e.key.key);
if (e.key.key == 41) {
printf("Exiting\n");
running = false;
}
break;
default:
break;
}
w.consume(e);
}
w.clear();
// animated position
t += 0.016f;
float x = 200 + std::sin(t) * 100;
float y = 150 + std::cos(t) * 100;
// background rect (low z)
w.draw_rect({{0, 0}, {800, 600}}, {20, 20, 30, 255}, 0, 20.0f);
// image (mid z)
w.draw(img, {x, y}, 1.0f, t * 50.0f, {2.0f, 2.0f}, 1.0f);
// text (top z)
w.write(text, {0, 0}, 2.0f, 0.0f, {1.0f, 1.0f});
w.render();
}
return 0;
}