const term = @import("term.zig"); const Winsize = term.Winsize; const primitive = @import("primitives.zig"); const Point = primitive.Point; pub fn mv_axis_border_bounce(w: Winsize, point: *Point, axis: u8) void { var cor = &point.x; var dir = &point.direction.x; var upper = w.ws_col; switch (axis) { 'x' => { cor = &point.x; upper = w.ws_col; dir = &point.direction.x; }, 'y' => { cor = &point.y; upper = w.ws_row; dir = &point.direction.y; }, 'X' => { cor = &point.x; upper = w.ws_col; dir = &point.direction.x; dir.* *= -1; }, 'Y' => { cor = &point.y; upper = w.ws_row; dir = &point.direction.y; dir.* *= -1; }, else => {}, } //if (cor.* < upper and cor.* > 0) { cor.* += dir.*; // } if (cor.* >= upper or cor.* <= 0) { dir.* *= -1; cor.* += dir.*; } }