const io = @import("io.zig");
const Cursor = @import("cursor.zig").Self;
const Map = @import("map.zig");
neck: Map,
head: Cursor,
tail: Cursor,
const Self = @This();
pub fn init(start: Cursor) Self {
return .{
.head = start,
.tail = start,
.neck = .{},
};
}
pub fn pushdir(self: *Self, dir: u2) void {
self.neck.store(self.head, dir);
self.head.dir = dir ^ 2;
}
pub fn popdir(self: *Self) void {
self.neck.load(&self.tail);
self.neck.zero(self.tail);
}
pub fn collide(self: Self) bool {
return self.head.mask() & self.neck.blank() == 0;
}
pub fn empty(self:Self) u64 {
return self.neck.blank() & ~self.head.mask();
}
//todo
pub fn print() void {
unreachable;
}