Zig port of FileHandler

- io directly with iff.zig and filehandler.zig
- Added OpenGL ubuntu build step and made sure lint doesn't start until build is done
- Rewrote motivation section in README
This commit is contained in:
Tony Bark 2024-04-30 23:00:03 -04:00
parent 02827893df
commit c8e8d41fb8
7 changed files with 84 additions and 30 deletions

27
src/io/filehandler.zig Normal file
View file

@ -0,0 +1,27 @@
pub const Asset = struct {
Group: u32,
File: u32,
Type: u32,
};
pub const FileError = enum {
FERR_NOT_FOUND,
FERR_OPEN,
FERR_BLANK,
FERR_MEMORY,
FERR_READ,
FERR_UNRECOGNIZED,
FERR_INVALIDDATA,
};
pub const ImageFormat = enum {
FIMG_BGR24,
FIMG_BGRA32,
};
pub const Image = struct {
Width: u8,
Height: u8,
Format: ImageFormat,
Data: u8,
};

4
src/io/iff.zig Normal file
View file

@ -0,0 +1,4 @@
const iff = @cImport({
@cInclude("./iff/iff.h");
@cInclude("./iff/iffparser.h");
});

View file

@ -8,28 +8,36 @@ pub fn main() !void {
rl.initWindow(screenWidth, screenHeight, "Basic Window");
defer rl.closeWindow();
// var ballPos = rl.Vector2.init(screenWidth / 2, screenHeight / 2);
var ballPos = rl.Vector2.init(screenWidth / 2, screenHeight / 2);
rl.setTargetFPS(60);
while (!rl.windowShouldClose()) {
// Update
// if (rl.isKeyDown(rl.KeyboardKey.key_right)) {
// ballPos.x += 2.0;
// }
if (rl.isKeyDown(rl.KeyboardKey.key_right) or
rl.isKeyDown(rl.KeyboardKey.key_d))
{
ballPos.x += 2.0;
}
// if (rl.isKeyDown(rl.KeyboardKey.key_left)) {
// ballPos.x -= 2.0;
// }
if (rl.isKeyDown(rl.KeyboardKey.key_left) or
rl.isKeyDown(rl.KeyboardKey.key_a))
{
ballPos.x -= 2.0;
}
// if (rl.isKeyDown(rl.KeyboardKey.key_up)) {
// ballPos.y -= 2.0;
// }
if (rl.isKeyDown(rl.KeyboardKey.key_up) or
rl.isKeyDown(rl.KeyboardKey.key_w))
{
ballPos.y -= 2.0;
}
// if (rl.isKeyDown(rl.KeyboardKey.key_down)) {
// ballPos.y -= 2.0;
// }
if (rl.isKeyDown(rl.KeyboardKey.key_down) or
rl.isKeyDown(rl.KeyboardKey.key_s))
{
ballPos.y += 2.0;
}
// Draw
rl.beginDrawing();
@ -39,6 +47,6 @@ pub fn main() !void {
rl.drawText("Hello, zTSO!", 190, 200, 20, rl.Color.sky_blue);
// rl.drawCircle(ballPos, 50, rl.Color.maroon);
rl.drawCircleV(ballPos, 50, rl.Color.maroon);
}
}

View file

@ -1,4 +1,3 @@
const std = @import("std");
const iff = @cImport({
@cInclude("./iff/iff.h");
});
const rl = @import("raylib");
const fh = @import("./io/filehandler.zig");