Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.
/ zplay Public archive

A simple framework intended for game/tool creation.

License

Notifications You must be signed in to change notification settings

Jack-Ji/zplay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zplay

A simple framework intended for game/tool creation.

Features

  • Little external dependency, only SDL2 and OpenGL3/GLES3
  • Support PC platforms: windows/linux (possibly macOS, don't know for sure)
  • Flexible render-passes pipeline, greatly simplify rendering code
  • Graphics oriented math library: Vec2/Vec3/Mat4/Quaternion (zalgebra)
  • Vector graphics drawing (nanovg)
  • Immediate mode GUI toolkits (dear-imgui)
  • Realtime data visualization (ImPlot)
  • TrueType font loading and rendering
  • Image picture loading/decoding/writing (support png/jpg/bmp/tga)
  • Audio playback (support wav/flac/mp3/vorbis)
  • 2D toolkits:
    • Camera component
    • Sprite and SpriteBatch system
    • Texture packer used to programmatically create sprite-sheet
    • Particle system
    • Chipmunk physics lib integration
  • 3D toolkits:
    • Camera component
    • Model loading and rendering (only glTF 2.0 for now)
    • Blinn-Phong renderer (directional/point/spot light)
    • Environment mapping renderer
    • Skybox renderer
    • Bullet3 physics lib integration (credit to zig-gamedev)

Getting started

Copy zplay folder or clone repo (recursively) into libs subdirectory of the root of your project.

Install SDL2 library, please refer to docs of SDL2.zig

Then in your build.zig add:

const std = @import("std");
const zplay = @import("libs/zplay/build.zig");

pub fn build(b: *std.build.Builder) void {
    const exe = b.addExecutable("your_bin", "src/main.zig");

    exe.setBuildMode(b.standardReleaseOptions());
    exe.setTarget(b.standardTargetOptions(.{}));
    exe.install();

    zplay.link(exe, .{
      // choose graphics api (gl33/gles3)
      // link optional modules (imgui/nanovg etc)
    });

    const run_cmd = exe.run();
    run_cmd.step.dependOn(b.getInstallStep());

    const run_step = b.step("run", "Run the app");
    run_step.dependOn(&run_cmd.step);
}

Now in your code you may import and use zplay:

const std = @import("std");
const zp = @import("zplay");

fn init(ctx: *zp.Context) anyerror!void {
    _ = ctx;
    std.log.info("game init", .{});

    // your init code
}

fn loop(ctx: *zp.Context) anyerror!void {
    while (ctx.pollEvent()) |e| {
        switch (e) {
            .quit_event => ctx.kill(),
            else => {},
        }
    }

    // your game loop
}

fn quit(ctx: *zp.Context) void {
    _ = ctx;
    std.log.info("game quit", .{});

    // your deinit code
}

pub fn main() anyerror!void {
    try zp.run(.{
        .initFn = init,
        .loopFn = loop,
        .quitFn = quit,
    });
}

Third-Party Libraries

About

A simple framework intended for game/tool creation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published