2
1
Fork 0
mirror of https://git.sr.ht/~kikoodx/kble synced 2021-03-14 11:35:18 +01:00
kble/src/main.zig

37 lines
926 B
Zig
Raw Normal View History

const std = @import("std");
const assert = std.debug.assert;
2021-01-26 14:10:29 +01:00
const Level = @import("level.zig");
2021-01-24 19:22:48 +01:00
const ray = @cImport({
@cInclude("raylib.h");
});
pub fn main() !void {
// Create allocator
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer {
const leaked = gpa.deinit();
if (leaked) assert(false); //raise error
}
const allocator = &gpa.allocator;
2021-01-24 19:22:48 +01:00
// Create window
2021-01-24 19:22:48 +01:00
ray.SetConfigFlags(ray.FLAG_WINDOW_RESIZABLE);
ray.InitWindow(640, 480, "KBLE");
2021-01-24 19:22:48 +01:00
defer ray.CloseWindow();
// Limit FPS for performance
2021-01-24 19:22:48 +01:00
ray.SetTargetFPS(60);
// Create level
var level: Level = try Level.init(allocator, 128, 128);
defer level.deinit(allocator);
while (!ray.WindowShouldClose()) {
2021-01-24 19:22:48 +01:00
ray.BeginDrawing();
defer ray.EndDrawing();
ray.ClearBackground(ray.RAYWHITE);
ray.DrawText("Hellowo!", 190, 200, 20, ray.LIGHTGRAY);
2021-01-24 19:22:48 +01:00
}
}