summaryrefslogtreecommitdiff
path: root/src/main.zig
blob: c1c04dbc8c054c83312d9ea7a1097ff293dadf87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const std = @import("std");
const zxc = @import("zxc.zig");

const purple = zxc.Color{ .r = 1, .g = 0, .b = 1, .a = 1 };
const black = zxc.Color{ .r = 0, .g = 0, .b = 0, .a = 1 };

pub fn main() !void {
    var z = try zxc.init(.{
        .width = 400,
        .height = 224,
        .target_fps = 60,
    });
    defer z.deinit();

    var x: i32 = 16;
    while (!z.shouldQuit()) {
        z.cycleEvents();

        if (z.getKey(.left).down())
            x -= 1;
        if (z.getKey(.right).down())
            x += 1;

        try z.drawBegin();
        try z.drawSetColor(purple);
        try z.drawClear();
        try z.drawSetColor(black);
        try z.drawRectangle(.{
            .x = x,
            .y = 25,
            .w = 32,
            .h = 16,
            .fill = true,
        });
        try z.drawEnd();
    }
}