jack-ji / jok Goto Github PK
View Code? Open in Web Editor NEWA minimal 2d/3d game framework for @ziglang.
License: MIT License
A minimal 2d/3d game framework for @ziglang.
License: MIT License
Using defer
on pairs of setup and cleanup is a common zig idiom, but since the end()
functions can error, its impossible right now.
Suggested refactor:
try
expressions to catch, save the error and return;begin()
try the end
error as the first thing;so it would be something like
+ var end_error: anyerror!void = {};
...
pub fn begin(opt: BeginOpt) !void {
+ try end_error;
....
}
...
-pub fn end() !void {
+pub fn end() void {
- try [expr];
+ [expr] catch |e| return end_error = e;
}
Gonna write down a PR, just thought it would be good to open an issue first.
Right now, if I use any of the functions that use @splat
, it causes a compile error:
/home/mpokhil/Source/jok/src/j2d/Vector.zig:97:39: error: expected type 'u32', found 'type'
const result = self.data / @splat(f32, l);
^~~
referenced by:
move: /home/.../src/main.zig:63:30
update: /home/.../src/main.zig:146:13
remaining reference traces hidden; use '-freference-trace' to see all reference traces
/home/.../jok/src/j2d/Vector.zig:23:27: error: expected type 'u32', found 'type'
const result = @splat(f32, val);
Just changing all instance of @splat(f32, ...)
in jok.j2d.Vector
to @splat(2, ...)
works as expected.
Should I create a PR for this?
Not so sure how other engines/frameworks are dealing with high dpi. Hope someone can provide some clues.
src\main.zig:7:14: error: type '@typeof(null)' does not support field access
var world: cp.World = undefined;
me new to zig so maybe something not get here
the build.zig.zon here doesn't let this project compile
so i created just one dynamic object globaly
const dynamic_body: cp.World.ObjectOption.BodyProperty = .{
.dynamic = .{
.position = .{
.x = 0,
.y = 0,
},
},
};
add to world in init
_= try world.addObject(.{
.body = dynamic_body,
.shapes = &.{
.{
.circle = .{
.radius = 15,
.physics = .{
.weight = .{ .mass = 1 },
.elasticity = 0.5,
},
},
},
},
});
then on update try to read its position, but on every step value is the same :(
where on screen object falls down all work as expected...
pub fn update(ctx: jok.Context) !void {
// _ = ctx;
world.update(ctx.deltaSeconds())
const px: i32 = @intFromFloat(dynamic_body.dynamic.position.x);
const py: i32 = @intFromFloat(dynamic_body.dynamic.position.y);
print("bug {} x, y: {}, {}\n", .{0, px, py});
}
do i mising something agen ?
Hi!
I am trying to just set up the most basic project and build it.
$ zig version
0.13.0
$ cat build.zig
const std = @import("std");
const jok = @import("jok");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = jok.createGame(
b,
"mygame",
"src/main.zig",
target,
optimize,
.{},
);
const install_cmd = b.addInstallArtifact(exe, .{});
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(&install_cmd.step);
const run_step = b.step("run", "Run game");
run_step.dependOn(&run_cmd.step);
}
$ cat build.zig.zon
.{
.name = "playground",
.version = "0.0.0",
.dependencies = .{
.jok = .{
.url = "https://github.com/jack-ji/jok/archive/f0b0794dbc042e80970aff53ac14ea56a5977c27.tar.gz",
.hash = "1220671b150b68fc3f963b790921a9356bc217bfee281f2940e793b4a5e858daa5ba",
},
},
.paths = .{
"build.zig",
"build.zig.zon",
"src",
},
}
$ zig build run
/home/sven/.cache/zig/p/1220ebeeaade31e207a56977aff537a65e6338cddc68d50217ddf30bbc58fb27d367/build.zig:542:50: error: root struct of file 'Build.Step' has no member named 'MakeOptions'
fn make(step: *Step, make_opt: std.Build.Step.MakeOptions) !void {
~~~~~~~~~~~~~~^~~~~~~~~~~~
/home/sven/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/lib/std/Build/Step.zig:1:1: note: struct declared here
id: Id,
^~
referenced by:
create: /home/sven/.cache/zig/p/1220ebeeaade31e207a56977aff537a65e6338cddc68d50217ddf30bbc58fb27d367/build.zig:528:31
init: /home/sven/.cache/zig/p/1220ebeeaade31e207a56977aff537a65e6338cddc68d50217ddf30bbc58fb27d367/build.zig:155:48
remaining reference traces hidden; use '-freference-trace' to see all reference traces
I also tried zig's nightly but this complains about znoise missing.
Hi! I'm trying to compile the examples, but I'm getting:
PS D:\programming\__zig\jok> zig build hello
zig build-exe hello Debug native: error: error(compilation): clang failed with stderr: D:\programming\__zig\jok\src\deps\audio\c\sdl_impl.c:594:18: error: call to undeclared function 'ma_context_init__sdl'; ISO
C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
The SDL version I've setup is SDL2-devel-2.28.5-mingw
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.