Initial commit

This commit is contained in:
2021-11-23 20:24:38 -07:00
commit 6120807f92
42 changed files with 7688 additions and 0 deletions

41
src/main.zig Normal file
View File

@ -0,0 +1,41 @@
const std = @import("std");
const minifb = @import("minifb");
const Width = 800;
const Height = 600;
pub fn main() anyerror!void {
std.log.info("All your codebase are belong to us.", .{});
var win = minifb.Window.open("Hello minifb-zig", Width, Height) catch unreachable;
var color: u32 = 0xff000000;
const deltaColor: u32 = 0x00010101;
var increasing = true;
var rawBuffer: [Width*Height]u32 = undefined;
const buffer = rawBuffer[0..rawBuffer.len];
std.mem.set(u32, buffer, color);
while (win.waitSync()) {
if (increasing) {
if (color < 0xffffffff) {
color += deltaColor;
} else {
increasing = false;
}
} else {
if (color > 0xff000000) {
color -= deltaColor;
} else {
increasing = true;
}
}
std.mem.set(u32, buffer, color);
var i: u32 = 0;
while (i < Width) {
buffer[i] = 0xffff0000;
i += 1;
}
_ = win.update(buffer) catch unreachable;
}
}