This commit is contained in:
jonathan santis 2024-11-01 15:24:59 +01:00
parent ece4540426
commit 4c31674539
2 changed files with 7 additions and 7 deletions

View File

@ -82,9 +82,9 @@ fn draw() !void {
// 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.c, 'x');
// mv_axis_border_bounce(w, &primitive.vec.c, 'y');
mv_axis_border_bounce(w, &polygon.head.?.point, 'Y');
try primitive.polygon_draw(buffer, w, &polygon);
try fill_draw(w, buffer);
// try fill_draw(w, buffer);
try out.print("{s}", .{buffer});
sleep(30000000);

View File

@ -23,20 +23,20 @@ pub fn mv_axis_border_bounce(w: Winsize, point: *Point, axis: u8) void {
cor = &point.x;
upper = w.ws_col;
dir = &point.direction.x;
dir.* = -1;
dir.* *= -1;
},
'Y' => {
cor = &point.y;
upper = w.ws_row;
dir = &point.direction.y;
dir.* = -1;
dir.* *= -1;
},
else => {},
}
if (cor.* < upper and cor.* > 0) {
//if (cor.* < upper and cor.* > 0) {
cor.* += dir.*;
}
// }
if (cor.* >= upper or cor.* <= 0) {
dir.* *= -1;
cor.* += dir.*;