Fix for bool and includes

This commit is contained in:
ookami125 2025-05-02 22:26:04 -04:00
parent 7d1962307c
commit 04cb434a60
3 changed files with 144 additions and 56 deletions

View file

@ -5,6 +5,10 @@ const std = @import("std");
const spacetime = @import("spacetime.zig");
comptime { _ = spacetime; }
const stdb_math = @import("spacetime/math.zig");
const DbVector2 = stdb_math.DbVector2;
const DbVector3 = stdb_math.DbVector3;
const START_PLAYER_MASS: u32 = 15;
const START_PLAYER_SPEED: u32 = 10;
const FOOD_MASS_MIN: u32 = 2;
@ -196,59 +200,6 @@ pub const spacespec = spacetime.Spec{
}
};
pub const DbVector2 = struct {
x: f32,
y: f32,
pub fn sqr_magnitude(self: @This()) f32 {
return self.x * self.x + self.y * self.y;
}
pub fn magnitude(self: @This()) f32 {
return @sqrt(self.sqr_magnitude());
}
pub fn normalized(self: @This()) DbVector2 {
const length = self.magnitude();
return .{
.x = self.x / length,
.y = self.y / length,
};
}
pub fn scale(self: @This(), val: f32) DbVector2 {
return .{
.x = self.x * val,
.y = self.y * val,
};
}
pub fn add(self: @This(), other: DbVector2) DbVector2 {
return .{
.x = self.x + other.x,
.y = self.y + other.y,
};
}
pub fn add_to(self: *@This(), other: DbVector2) void {
self.x += other.x;
self.y += other.y;
}
pub fn sub(self: @This(), other: DbVector2) DbVector2 {
return .{
.x = self.x - other.x,
.y = self.y - other.y,
};
}
pub fn sub_from(self: *@This(), other: DbVector2) void {
self.x -= other.x;
self.y -= other.y;
}
};
pub const Config = struct {
id: u32,
world_size: u64,