split up user / testing definitions
This commit is contained in:
parent
4ab7bf6ce1
commit
1634f96817
15
definitions.zig
Normal file
15
definitions.zig
Normal file
@ -0,0 +1,15 @@
|
||||
const primitive = @import("primitives.zig");
|
||||
const Vec3 = primitive.Vec3;
|
||||
const Point = primitive.Point;
|
||||
|
||||
pub var vec = Vec3{
|
||||
.a = Point{ .x = 20, .y = 30, .z = 0, .direction = .{ .x = 1, .y = 1, .z = 1 } },
|
||||
.b = Point{ .x = 50, .y = 40, .z = 0, .direction = .{ .x = 1, .y = 1, .z = 1 } },
|
||||
.c = Point{ .x = 30, .y = 1, .z = 0, .direction = .{ .x = 1, .y = 1, .z = 1 } },
|
||||
};
|
||||
pub var vec2 = Vec3{
|
||||
.a = Point{ .x = 20, .y = 20, .z = 0, .direction = .{ .x = 1, .y = 1, .z = 1 } },
|
||||
.b = Point{ .x = 50, .y = 30, .z = 0, .direction = .{ .x = 1, .y = 1, .z = 1 } },
|
||||
.c = Point{ .x = 30, .y = 1, .z = 0, .direction = .{ .x = 1, .y = 1, .z = 1 } },
|
||||
};
|
||||
pub var obj: [10]Vec3 = undefined;
|
14
main.zig
14
main.zig
@ -19,6 +19,8 @@ const getTermDimension = term.getTermDimension;
|
||||
const movement = @import("movement.zig");
|
||||
const mv_axis_border_bounce = movement.mv_axis_border_bounce;
|
||||
|
||||
const definitions = @import("definitions.zig");
|
||||
|
||||
pub fn main() !void {
|
||||
var win = Winsize{};
|
||||
|
||||
@ -48,10 +50,10 @@ fn draw() !void {
|
||||
var buffer = try allocator.alloc(u8, buffer_size); //utf-8 can be 4 bytes long
|
||||
defer allocator.free(buffer);
|
||||
|
||||
primitive.obj[0].a.x = 10;
|
||||
print("primitive.obj[0].a.x:{}\n", .{primitive.obj[0].a.x});
|
||||
print("primitive.obj[0].b.x:{}\n", .{primitive.obj[0].b.x});
|
||||
print("primitive.obj[9].b.x:{}\n", .{primitive.obj[9].b.x});
|
||||
definitions.obj[0].a.x = 10;
|
||||
print("definitions.obj[0].a.x:{}\n", .{definitions.obj[0].a.x});
|
||||
print("definitions.obj[0].b.x:{}\n", .{definitions.obj[0].b.x});
|
||||
print("definitions.obj[9].b.x:{}\n", .{definitions.obj[9].b.x});
|
||||
_ = try stdin.readUntilDelimiterOrEof(&buf, '\n');
|
||||
//video loop
|
||||
while (true) {
|
||||
@ -66,7 +68,7 @@ fn draw() !void {
|
||||
slice[bytes_written + ii] = 0;
|
||||
}
|
||||
}
|
||||
try triangle(buffer, w, primitive.vec);
|
||||
try triangle(buffer, w, definitions.vec);
|
||||
//_ = try bresenham(buffer, w, Point{ .x = 10, .y = 10, .z = 0 }, Point{ .x = 30, .y = 12, .z = 0 });
|
||||
|
||||
try out.print("\x1B[2J", .{});
|
||||
@ -87,7 +89,7 @@ fn draw() !void {
|
||||
// mv_axis_border_bounce(w, &primitive.vec2.b, 'Y');
|
||||
// mv_axis_border_bounce(w, &primitive.vec2.c, 'x');
|
||||
// mv_axis_border_bounce(w, &primitive.vec2.c, 'y');
|
||||
//try triangle(buffer, w, primitive.obj.vec);
|
||||
//try triangle(buffer, w, definitions.obj.vec);
|
||||
|
||||
try fill_draw(w, buffer);
|
||||
try out.print("{s}", .{buffer});
|
||||
|
@ -23,17 +23,6 @@ pub const Triangle = struct {
|
||||
bufb: *i32,
|
||||
bufc: *i32,
|
||||
};
|
||||
pub var vec = Vec3{
|
||||
.a = Point{ .x = 20, .y = 30, .z = 0, .direction = .{ .x = 1, .y = 1, .z = 1 } },
|
||||
.b = Point{ .x = 50, .y = 40, .z = 0, .direction = .{ .x = 1, .y = 1, .z = 1 } },
|
||||
.c = Point{ .x = 30, .y = 1, .z = 0, .direction = .{ .x = 1, .y = 1, .z = 1 } },
|
||||
};
|
||||
pub var vec2 = Vec3{
|
||||
.a = Point{ .x = 20, .y = 20, .z = 0, .direction = .{ .x = 1, .y = 1, .z = 1 } },
|
||||
.b = Point{ .x = 50, .y = 30, .z = 0, .direction = .{ .x = 1, .y = 1, .z = 1 } },
|
||||
.c = Point{ .x = 30, .y = 1, .z = 0, .direction = .{ .x = 1, .y = 1, .z = 1 } },
|
||||
};
|
||||
pub var obj: [10]Vec3 = undefined;
|
||||
|
||||
pub fn pixel(buffer: []u8, w: Winsize, x: i64, y: i64, symbol: u21) !void {
|
||||
const i: usize = @intCast(4 * (x + y * w.ws_col));
|
||||
|
Loading…
Reference in New Issue
Block a user