Trying to improve collisions and failing
This commit is contained in:
14
src/Game.zig
14
src/Game.zig
@@ -1,6 +1,7 @@
|
||||
const Game = @This();
|
||||
const std = @import("std");
|
||||
|
||||
const c = @import("const.zig");
|
||||
const glfw = @import("zglfw");
|
||||
const math = @import("math.zig");
|
||||
const shaders = @import("shaders.zig");
|
||||
@@ -23,6 +24,7 @@ const Textures = @import("assets/Textures.zig");
|
||||
const Vector2 = math.Vector2;
|
||||
const Vector2x8 = math.Vector2x8;
|
||||
const Vector3 = math.Vector3;
|
||||
const Vector3Int = math.Vector3Int;
|
||||
|
||||
allocator: std.mem.Allocator,
|
||||
engine: *Engine,
|
||||
@@ -591,7 +593,10 @@ pub fn init(allocator: std.mem.Allocator, engine: *Engine, swapchain: *Swapchain
|
||||
}
|
||||
}
|
||||
|
||||
const player_position = Vector3.init(0, 0, worldgen.heightF(world_seed, .zero) + 0.5);
|
||||
const player_position_vx = Vector3Int.init(0, 0, worldgen.heightI(world_seed, .zero) + 1);
|
||||
const player_position_sv = player_position_vx
|
||||
.mulScalar(c.sv_per_vx)
|
||||
.add(.init(c.sv_per_vx / 2, c.sv_per_vx / 2, 0));
|
||||
|
||||
var chunk_it = chunks.iterator();
|
||||
while (chunk_it.next()) |entry| {
|
||||
@@ -655,7 +660,7 @@ pub fn init(allocator: std.mem.Allocator, engine: *Engine, swapchain: *Swapchain
|
||||
.chunks = chunks,
|
||||
.skybox = skybox,
|
||||
|
||||
.player = .init(player_position, 0, 0),
|
||||
.player = .init(player_position_sv, 0, 0),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -757,7 +762,10 @@ fn render(self: *Game) !void {
|
||||
@floatFromInt(extent.height),
|
||||
);
|
||||
|
||||
const camera_position = self.player.position.add(.init(0, 0, Player.camera_height));
|
||||
const camera_position = self.player.position_sv
|
||||
.asVector3()
|
||||
.divScalar(c.sv_per_vx)
|
||||
.add(.init(0, 0, Player.camera_height_vx));
|
||||
const camera_rotation = Quaternion.mulQuaternion(
|
||||
.initRotationXY(self.player.yaw_rad),
|
||||
.initRotationYZ(self.player.pitch_rad),
|
||||
|
||||
Reference in New Issue
Block a user