implementing area, car structs
This commit is contained in:
parent
c3cc8f68c1
commit
1c08b255e9
11
build.zig
11
build.zig
@ -65,6 +65,17 @@ pub fn build(b: *std.Build) void {
|
||||
.root_module = exe_mod,
|
||||
});
|
||||
|
||||
const raylib_dep = b.dependency("raylib_zig", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const raylib = raylib_dep.module("raylib"); // main raylib module
|
||||
const raylib_artifact = raylib_dep.artifact("raylib"); // raylib c library
|
||||
|
||||
exe.linkLibrary(raylib_artifact);
|
||||
exe.root_module.addImport("raylib", raylib);
|
||||
|
||||
// This declares intent for the executable to be installed into the
|
||||
// standard location when the user invokes the "install" step (the default
|
||||
// step when running `zig build`).
|
||||
|
@ -36,45 +36,11 @@
|
||||
// Once all dependencies are fetched, `zig build` no longer requires
|
||||
// internet connectivity.
|
||||
.dependencies = .{
|
||||
// See `zig fetch --save <url>` for a command-line interface for adding dependencies.
|
||||
//.example = .{
|
||||
// // When updating this field to a new URL, be sure to delete the corresponding
|
||||
// // `hash`, otherwise you are communicating that you expect to find the old hash at
|
||||
// // the new URL. If the contents of a URL change this will result in a hash mismatch
|
||||
// // which will prevent zig from using it.
|
||||
// .url = "https://example.com/foo.tar.gz",
|
||||
//
|
||||
// // This is computed from the file contents of the directory of files that is
|
||||
// // obtained after fetching `url` and applying the inclusion rules given by
|
||||
// // `paths`.
|
||||
// //
|
||||
// // This field is the source of truth; packages do not come from a `url`; they
|
||||
// // come from a `hash`. `url` is just one of many possible mirrors for how to
|
||||
// // obtain a package matching this `hash`.
|
||||
// //
|
||||
// // Uses the [multihash](https://multiformats.io/multihash/) format.
|
||||
// .hash = "...",
|
||||
//
|
||||
// // When this is provided, the package is found in a directory relative to the
|
||||
// // build root. In this case the package's hash is irrelevant and therefore not
|
||||
// // computed. This field and `url` are mutually exclusive.
|
||||
// .path = "foo",
|
||||
//
|
||||
// // When this is set to `true`, a package is declared to be lazily
|
||||
// // fetched. This makes the dependency only get fetched if it is
|
||||
// // actually used.
|
||||
// .lazy = false,
|
||||
//},
|
||||
.raylib_zig = .{
|
||||
.url = "git+https://github.com/Not-Nik/raylib-zig?ref=devel#5013830647196ba938a3a25a36b8245606e9a9cd",
|
||||
.hash = "raylib_zig-5.6.0-dev-KE8REM0tBQAHVn9Xjqlgu9l1qgfTmP8aJa1kLhD584bV",
|
||||
},
|
||||
},
|
||||
|
||||
// Specifies the set of files and directories that are included in this package.
|
||||
// Only files and directories listed here are included in the `hash` that
|
||||
// is computed for this package. Only files listed here will remain on disk
|
||||
// when using the zig package manager. As a rule of thumb, one should list
|
||||
// files required for compilation plus any license(s).
|
||||
// Paths are relative to the build root. Use the empty string (`""`) to refer to
|
||||
// the build root itself.
|
||||
// A directory listed here means that all files within, recursively, are included.
|
||||
.paths = .{
|
||||
"build.zig",
|
||||
"build.zig.zon",
|
||||
|
8
src/car.zig
Normal file
8
src/car.zig
Normal file
@ -0,0 +1,8 @@
|
||||
const rl = @import("raylib");
|
||||
|
||||
const Car = struct {
|
||||
location: rl.Vector2,
|
||||
color: rl.Color,
|
||||
fuel: u7,
|
||||
speed: u8,
|
||||
};
|
13
src/globals.zig
Normal file
13
src/globals.zig
Normal file
@ -0,0 +1,13 @@
|
||||
const rl = @import("raylib");
|
||||
|
||||
pub var screen_width = 1920;
|
||||
pub var screen_height = 1080;
|
||||
|
||||
fn setWindowSize(new_width: usize, new_height: usize) void {
|
||||
screen_width = new_width;
|
||||
screen_height = new_height;
|
||||
}
|
||||
|
||||
fn checkWindowSizeChanged(new_width: usize, new_height: usize) bool {
|
||||
return screen_width != new_width or screen_height != new_height;
|
||||
}
|
23
src/main.zig
23
src/main.zig
@ -1,5 +1,26 @@
|
||||
const std = @import("std");
|
||||
const rl = @import("raylib");
|
||||
|
||||
pub fn main() !void {
|
||||
std.debug.print("Hello World", .{});
|
||||
const size = .{ 1920, 1080 };
|
||||
|
||||
rl.setConfigFlags(.{
|
||||
.msaa_4x_hint = true,
|
||||
.window_resizable = true,
|
||||
.window_maximized = true,
|
||||
});
|
||||
|
||||
rl.initWindow(size[0], size[1], "Promet SIM");
|
||||
defer rl.closeWindow();
|
||||
|
||||
rl.maximizeWindow();
|
||||
|
||||
rl.setTargetFPS(60);
|
||||
|
||||
while (!rl.windowShouldClose()) {
|
||||
rl.beginDrawing();
|
||||
defer rl.endDrawing();
|
||||
|
||||
rl.clearBackground(.light_gray);
|
||||
}
|
||||
}
|
||||
|
18
src/spawn-area.zig
Normal file
18
src/spawn-area.zig
Normal file
@ -0,0 +1,18 @@
|
||||
const rl = @import("raylib");
|
||||
|
||||
const AreaLocation = enum {
|
||||
TopLeft,
|
||||
TopRight,
|
||||
BottomLeft,
|
||||
BottomRihgt,
|
||||
};
|
||||
|
||||
const SpawnArea = struct {
|
||||
location: rl.Vector2,
|
||||
// cars
|
||||
size: .{ i32, i32 },
|
||||
|
||||
pub fn init(loc: AreaLocation) SpawnArea {
|
||||
return SpawnArea{ .location = loc, .size = .{ undefined, undefined } };
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user