begin work on object and array of struct
This commit is contained in:
parent
1d82a2cf42
commit
ed91d9c711
34
main.zig
34
main.zig
@ -64,6 +64,11 @@ fn draw() !void {
|
|||||||
|
|
||||||
var buffer = try allocator.alloc(u8, buffer_size); //utf-8 can be 4 bytes long
|
var buffer = try allocator.alloc(u8, buffer_size); //utf-8 can be 4 bytes long
|
||||||
defer allocator.free(buffer);
|
defer allocator.free(buffer);
|
||||||
|
|
||||||
|
primitive.vec3[0].a.x = 10;
|
||||||
|
print("primitive.vec3[0].a.x:{}\n", .{primitive.vec3[0].a.x});
|
||||||
|
print("primitive.vec3[0].b.x:{}\n", .{primitive.vec3[0].b.x});
|
||||||
|
print("primitive.vec3[9].b.x:{}\n", .{primitive.vec3[9].b.x});
|
||||||
_ = try stdin.readUntilDelimiterOrEof(&buf, '\n');
|
_ = try stdin.readUntilDelimiterOrEof(&buf, '\n');
|
||||||
//video loop
|
//video loop
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -84,21 +89,22 @@ fn draw() !void {
|
|||||||
try out.print("\x1B[2J", .{});
|
try out.print("\x1B[2J", .{});
|
||||||
//sleep(100000);
|
//sleep(100000);
|
||||||
|
|
||||||
try triangle(buffer, w, primitive.vec);
|
// try triangle(buffer, w, primitive.vec);
|
||||||
mv_axis_border_bounce(w, &primitive.vec.a, 'x');
|
// mv_axis_border_bounce(w, &primitive.vec.a, 'x');
|
||||||
mv_axis_border_bounce(w, &primitive.vec.a, 'y');
|
// mv_axis_border_bounce(w, &primitive.vec.a, 'y');
|
||||||
mv_axis_border_bounce(w, &primitive.vec.b, 'x');
|
// mv_axis_border_bounce(w, &primitive.vec.b, 'x');
|
||||||
mv_axis_border_bounce(w, &primitive.vec.b, 'y');
|
// mv_axis_border_bounce(w, &primitive.vec.b, 'y');
|
||||||
mv_axis_border_bounce(w, &primitive.vec.c, 'x');
|
// mv_axis_border_bounce(w, &primitive.vec.c, 'x');
|
||||||
mv_axis_border_bounce(w, &primitive.vec.c, 'y');
|
// mv_axis_border_bounce(w, &primitive.vec.c, 'y');
|
||||||
|
|
||||||
try triangle(buffer, w, primitive.vec2);
|
// try triangle(buffer, w, primitive.vec2);
|
||||||
mv_axis_border_bounce(w, &primitive.vec2.a, 'x');
|
// mv_axis_border_bounce(w, &primitive.vec2.a, 'x');
|
||||||
mv_axis_border_bounce(w, &primitive.vec2.a, 'y');
|
// mv_axis_border_bounce(w, &primitive.vec2.a, 'y');
|
||||||
mv_axis_border_bounce(w, &primitive.vec2.b, 'x');
|
// mv_axis_border_bounce(w, &primitive.vec2.b, 'x');
|
||||||
mv_axis_border_bounce(w, &primitive.vec2.b, 'Y');
|
// 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, 'x');
|
||||||
mv_axis_border_bounce(w, &primitive.vec2.c, 'y');
|
// mv_axis_border_bounce(w, &primitive.vec2.c, 'y');
|
||||||
|
//try triangle(buffer, w, primitive.obj.vec);
|
||||||
|
|
||||||
try fill_draw(w, buffer);
|
try fill_draw(w, buffer);
|
||||||
try out.print("{s}", .{buffer});
|
try out.print("{s}", .{buffer});
|
||||||
|
@ -4,15 +4,15 @@ pub const Direction = struct {
|
|||||||
z: i8 = 1,
|
z: i8 = 1,
|
||||||
};
|
};
|
||||||
pub const Point = struct {
|
pub const Point = struct {
|
||||||
x: i32,
|
x: i32 = 0,
|
||||||
y: i32,
|
y: i32 = 0,
|
||||||
z: i32,
|
z: i32 = 0,
|
||||||
direction: Direction, //for movement state
|
direction: Direction, //for movement state
|
||||||
};
|
};
|
||||||
pub const Vec3 = struct {
|
pub const Vec3 = struct {
|
||||||
a: Point,
|
a: Point = .{ .x = 0, .y = 0, .z = 0, .direction = .{ .x = 0, .y = 0, .z = 0 } },
|
||||||
b: Point,
|
b: Point = .{ .x = 0, .y = 0, .z = 0, .direction = .{ .x = 0, .y = 0, .z = 0 } },
|
||||||
c: Point,
|
c: Point = .{ .x = 0, .y = 0, .z = 0, .direction = .{ .x = 0, .y = 0, .z = 0 } },
|
||||||
};
|
};
|
||||||
pub const Triangle = struct {
|
pub const Triangle = struct {
|
||||||
bufa: *i32,
|
bufa: *i32,
|
||||||
@ -29,3 +29,4 @@ pub var vec2 = Vec3{
|
|||||||
.b = Point{ .x = 50, .y = 30, .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 } },
|
.c = Point{ .x = 30, .y = 1, .z = 0, .direction = .{ .x = 1, .y = 1, .z = 1 } },
|
||||||
};
|
};
|
||||||
|
pub var vec3: [10]Vec3 = undefined;
|
||||||
|
Loading…
Reference in New Issue
Block a user