day end
This commit is contained in:
parent
1634f96817
commit
acb8e8163d
25
main.zig
25
main.zig
@ -36,13 +36,10 @@ fn draw() !void {
|
|||||||
var w = Winsize{};
|
var w = Winsize{};
|
||||||
var i: u64 = 0;
|
var i: u64 = 0;
|
||||||
var ii: u64 = 0;
|
var ii: u64 = 0;
|
||||||
var buf = std.mem.zeroes([2]u8);
|
|
||||||
var slice: []u8 = undefined;
|
var slice: []u8 = undefined;
|
||||||
var bytes_written: u3 = 0;
|
var bytes_written: u3 = 0;
|
||||||
var buffer_size: u32 = 0;
|
var buffer_size: u32 = 0;
|
||||||
|
|
||||||
buf[0] = 0;
|
|
||||||
|
|
||||||
w = try getTermDimension();
|
w = try getTermDimension();
|
||||||
buffer_size = w.ws_row;
|
buffer_size = w.ws_row;
|
||||||
buffer_size = buffer_size * w.ws_col * 4;
|
buffer_size = buffer_size * w.ws_col * 4;
|
||||||
@ -51,13 +48,10 @@ fn draw() !void {
|
|||||||
defer allocator.free(buffer);
|
defer allocator.free(buffer);
|
||||||
|
|
||||||
definitions.obj[0].a.x = 10;
|
definitions.obj[0].a.x = 10;
|
||||||
print("definitions.obj[0].a.x:{}\n", .{definitions.obj[0].a.x});
|
wait_for_enter();
|
||||||
print("definitions.obj[0].b.x:{}\n", .{definitions.obj[0].b.x});
|
// defer std.heap.page_allocator.free(tmp);
|
||||||
print("definitions.obj[9].b.x:{}\n", .{definitions.obj[9].b.x});
|
|
||||||
_ = try stdin.readUntilDelimiterOrEof(&buf, '\n');
|
|
||||||
//video loop
|
//video loop
|
||||||
while (true) {
|
while (true) {
|
||||||
buffer[0] = 0;
|
|
||||||
i = 0;
|
i = 0;
|
||||||
//clear buffer
|
//clear buffer
|
||||||
while (i < buffer.len) : (i += 4) {
|
while (i < buffer.len) : (i += 4) {
|
||||||
@ -82,18 +76,8 @@ fn draw() !void {
|
|||||||
// 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);
|
|
||||||
// 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.b, 'x');
|
|
||||||
// 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, definitions.obj.vec);
|
|
||||||
|
|
||||||
try fill_draw(w, buffer);
|
try fill_draw(w, buffer);
|
||||||
try out.print("{s}", .{buffer});
|
try out.print("{s}", .{buffer});
|
||||||
//_ = try stdin.readUntilDelimiterOrEof(&buf, '\n');
|
|
||||||
sleep(30000000);
|
sleep(30000000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,3 +117,8 @@ fn fill_draw(w: Winsize, buffer: []u8) !void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn wait_for_enter() void {
|
||||||
|
_ = stdin.readUntilDelimiterAlloc(std.heap.page_allocator, '\n', 3) catch |err| {
|
||||||
|
print("string to long{}", .{err});
|
||||||
|
}; //Memory leak?
|
||||||
|
}
|
||||||
|
@ -24,6 +24,15 @@ pub const Triangle = struct {
|
|||||||
bufc: *i32,
|
bufc: *i32,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const Polygon = struct{
|
||||||
|
const Node = struct{point:Point,*Node};
|
||||||
|
|
||||||
|
head: *Node;
|
||||||
|
length: u32;
|
||||||
|
|
||||||
|
pub fn new() Node {
|
||||||
|
return Node
|
||||||
|
|
||||||
pub fn pixel(buffer: []u8, w: Winsize, x: i64, y: i64, symbol: u21) !void {
|
pub fn pixel(buffer: []u8, w: Winsize, x: i64, y: i64, symbol: u21) !void {
|
||||||
const i: usize = @intCast(4 * (x + y * w.ws_col));
|
const i: usize = @intCast(4 * (x + y * w.ws_col));
|
||||||
if (i < buffer.len) { //-1 ??
|
if (i < buffer.len) { //-1 ??
|
||||||
|
Loading…
Reference in New Issue
Block a user