GithubHelp home page GithubHelp logo

isabella232 / zig-gamekit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from prime31/zig-gamekit

0.0 0.0 0.0 1.22 MB

Companion repo for zig-renderkit for making 2D games

License: MIT License

Zig 52.04% Makefile 0.15% C++ 0.30% C 47.31% GLSL 0.06% Metal 0.14%

zig-gamekit's Introduction

Zig GameKit 2D

Companion repo and example implementation for zig-renderkit. GameKit provides an example implementation of a game framework built on top of RenderKit. It includes the core render loop, window (via SDL), input, Dear ImGui and timing support. You can use it as a base to make a 2D game as-is or create your own 2D framework based on it.

GameKit provides the following wrappers around RenderKit's API showing how it can be abstracted away in a real world project: Texture, Shader and OffscreenPass. Building on top of those types, GameKit then provides Mesh and DynamicMesh which manage buffers and bindings for you. Finally, the high level types utilize DynamicMesh and cover pretty much all that any 2D game would require: Batcher (quad/sprite batch) and TriangleBatcher.

Some basic utilities and a small math lib with just the types required for the renderer (Vec2, Vec3, Color, 3x2 Matrix, Quad) are also included.

Dependencies

GameKit has just one external dependency: SDL. You can install SDL with the package manager of your choice. On macOS if you intend to use the Metal renderer you will need to build from source until the next SDL release drops.

Usage

  • clone the repository recursively: git clone --recursive https://github.com/prime31/zig-gamekit
  • zig build help to see what examples are availble
  • zig build EXAMPLE_NAME to run an example

Minimal GameKit Project File

var texture: Texture = undefined;

pub fn main() !void {
    try gamekit.run(.{ .init = init, .render = render });
}

fn init() !void {
    texture = Texture.initFromFile(std.testing.allocator, "texture.png", .nearest) catch unreachable;
}

fn render() !void {
    gamekit.gfx.beginPass(.{ .color = Color.lime });
    gamekit.draw.tex(texture, .{ .x = 50, .y = 50 });
    gamekit.gfx.endPass();
}

zig-gamekit's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.