~alva/bee

98eafdbee37bc7d4a8984401a0b50c07542438f4 — ugla 3 years ago a00a537
Zig updates
3 files changed, 13 insertions(+), 12 deletions(-)

M build.zig
M src/constants.zig
M src/objects.zig
M build.zig => build.zig +7 -6
@@ 26,23 26,24 @@ pub fn build(b: *Builder) !void {
    if (mode != .Debug)
        exe.strip = true;

    if (mode != .ReleaseSafe)
    if (mode == .ReleaseSafe)
        exe.force_pic = true;

    exe.linkLibC();
    tests.linkLibC();
//    tests.linkLibC();

//     exe.addIncludeDir(try path.join(b.allocator,
//         &[_][]const u8{ b.build_root, "usr", "include", "SDL2" }));
    exe.addIncludeDir(try path.join(b.allocator,
        &[_][]const u8{ b.build_root, "usr", "include", "SDL2" }));
//     exe.addLibPath(try path.join(b.allocator,
//         &[_][]const u8{ b.build_root, "usr", "local", "lib" }));
//     exe.addLibPath(try path.join(b.allocator,
//         &[_][]const u8{ "usr", "lib" }));

//     exe.addObjectFile("usr/local/lib/libSDL2.a");
//     exe.addObjectFile("usr/local/lib/libSDL2_image.a");
//     exe.linkSystemLibraryName("./usr/lib/libSDL2main.a");
//     exe.linkSystemLibraryName("./usr/local/lib/libSDL2_image.a");
    exe.linkSystemLibrary("SDL2");
    exe.linkSystemLibrary("SDL2_image");
//    exe.linkSystemLibrary("SDL2_image");
    //     exe.addLibPath("/usr/lib");
//     inline for (libs) |lib| {
//         exe.linkSystemLibrary(lib);

M src/constants.zig => src/constants.zig +1 -1
@@ 3,7 3,7 @@ const std = @import("std");

pub const resolution = [2]comptime_int{256, 224};

pub fn warn(comptime fmt: []const u8, args: var) void {
pub fn warn(comptime fmt: []const u8, args: anytype) void {
    if (builtin.mode == .Debug)
        std.debug.warn(fmt, args);
}

M src/objects.zig => src/objects.zig +5 -5
@@ 59,7 59,7 @@ pub const Attributes = struct {
    }
};

fn f(x: var) f32 {
fn f(x: anytype) f32 {
    return @intToFloat(f32, x);
}



@@ 184,7 184,7 @@ pub const Stage = struct {
        }
    }

    fn prepare(self: *Self, renderer: *c.SDL_Renderer) !void {
    pub fn prepare(self: *Self, renderer: *c.SDL_Renderer) !void {
        self.textures[0] = try createTexture(renderer, assets.bee);
        self.textures[29] = try createTexture(renderer, assets.boom);
        self.textures[30] = try createTexture(renderer, assets.slime_explosion);


@@ 431,7 431,7 @@ pub const Stage = struct {
        self.bullet_idx = (self.bullet_idx + 1) % 117;
    }

    fn handleKeyUp(self: *Self, event: c.SDL_Event) void {
    pub fn handleKeyUp(self: *Self, event: c.SDL_Event) void {
        const sym = event.key.keysym.sym;
        const a = &self.attributes[0];
        switch (sym) {


@@ 443,8 443,8 @@ pub const Stage = struct {
            else => {},
        }
    }
    
    fn handleKeyDown(self: *Self, event: c.SDL_Event) void {

    pub fn handleKeyDown(self: *Self, event: c.SDL_Event) void {
        if (event.key.repeat != 0)
            return;