const std = @import("std"); const SDL = @import("sdl2"); const color = @import("../color.zig"); const Cell = @import("Cell.zig"); const utils = @import("../utils.zig"); const range = utils.range; const Self = @This(); pub const ncolumns = 10; pub const nrows = 30; pub const buffer = 10; cells: [nrows][ncolumns]Cell, topped: bool = false, pub fn init() Self { var self = Self{ .cells = undefined, }; for (self.cells) |_, i| { for (self.cells[i]) |_, j| { self.cells[i][j] = Cell.init(); } } return self; } pub fn clearLines(self: *Self) void { for (self.cells) |_, y| { for (self.cells[y]) |cell_x, x| { if (cell_x.free) { break; } else { // Reached the end of the column? if (x == self.cells[y].len - 1) { // Delete current row and bring the others down for (self.cells[1..y]) |_, i| { self.cells[y - i] = self.cells[y - i - 1]; } } } } } }