summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/main.zig b/src/main.zig
index 0bfbe60..c1c04db 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1,6 +1,9 @@
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,
@@ -9,21 +12,21 @@ pub fn main() !void {
});
defer z.deinit();
- var score: usize = 0;
+ var x: i32 = 16;
while (!z.shouldQuit()) {
z.cycleEvents();
- if (z.getKey(.space) == .pressed) {
- score += 1;
- std.log.info("score: {}", .{score});
- }
+ if (z.getKey(.left).down())
+ x -= 1;
+ if (z.getKey(.right).down())
+ x += 1;
try z.drawBegin();
- try z.drawSetColor(.{ .r = 1, .g = 0, .b = 1 });
+ try z.drawSetColor(purple);
try z.drawClear();
- try z.drawSetColor(.{ .r = 0, .g = 0, .b = 0 });
+ try z.drawSetColor(black);
try z.drawRectangle(.{
- .x = 12,
+ .x = x,
.y = 25,
.w = 32,
.h = 16,