for ^cell: true_cells do *cell = .Empty;
memory.alloc_slice(^mine_locations, mine_count);
- for i: mine_count {
+ for mine_count {
while true {
mx, my := random.between(0, width - 1), random.between(0, height - 1);
if get_true_cell(this, mx, my) != .Mine {
set_true_cell(this, mx, my, .Mine);
- mine_locations[i] = .{mx, my};
+ mine_locations[it] = .{mx, my};
break;
}
}
}
- for ^mine_pos: mine_locations {
- for neighbor: neighbors(this, mine_pos.x, mine_pos.y) {
+ for ^ mine_locations {
+ for neighbor: neighbors(this, it.x, it.y) {
cell := get_true_cell(this, neighbor.x, neighbor.y);
if cell == .Empty do cell = .Number1;
elseif cell&.Is_Number do cell += 1;
reveal_cell(this, p.x, p.y);
if get_true_cell(this, p.x, p.y) & .Is_Number do continue;
- for n: neighbors(this, p.x, p.y, include_corners=true) {
- true_cell := get_true_cell(this, n.x, n.y);
- visible_cell := get_visible_cell(this, n.x, n.y);
+ for neighbors(this, p.x, p.y, include_corners=true) {
+ true_cell := get_true_cell(this, it.x, it.y);
+ visible_cell := get_visible_cell(this, it.x, it.y);
if true_cell != .Mine && visible_cell == .Covered {
- positions << n;
+ positions << it;
}
}
}
}
reveal_mines :: (use this: ^Board) {
- for ^mine: mine_locations {
- reveal_cell(this, mine.x, mine.y);
+ for ^ mine_locations {
+ reveal_cell(this, it.x, it.y);
}
}
hb.graphics.drawImage(dummy, 100, 100, 100, 100);
hb.graphics.newQuad(4, 4, 8, 8, dummy) |> hb.graphics.drawQuad(200, 100, 100, 100);
- for it: squares {
+ for squares {
hb.graphics.setColor(it.r, it.g, it.b, it.a);
hb.graphics.rectangle(.Fill, it.x, it.y, it.w, it.h);
}
}
snake_move :: (use this: ^Snake) {
- for i: iter.as_iterator(range.{ body.count - 1, 1, -1 }) {
- body[i] = body[i - 1];
+ for iter.as_iterator(range.{ body.count - 1, 1, -1 }) {
+ body[it] = body[it - 1];
}
body[0] = head;
snake_grow :: (use this: ^Snake, amount := 1) {
last := body[body.count - 1];
- for i: amount do body << last;
+ for amount do body << last;
}
snake_draw :: (use this: ^Snake, cell_size: f32) {
- for it: iter.enumerate(body) {
+ for iter.enumerate(body) {
hb.graphics.setColor(0, 0.6 - 0.4 * (~~it.index / cast(f32) body.count), 0);
hb.graphics.rectangle(.Fill, ~~it.value.x * cell_size, ~~it.value.y * cell_size, cell_size, cell_size);
}
}
cell_contains_snake_body :: (p: Vec2i) => {
- for ^it: the_snake.body {
+ for ^ the_snake.body {
if *it == p do return true;
}
return false;
menu_info := cast(^type_info.Type_Info_Struct) type_info.get_type_info(active_menu.options);
if menu_info.kind != .Struct do return;
- for it: iter.enumerate(menu_info.members) {
+ for iter.enumerate(menu_info.members) {
text := *(cast(^str) array.first(it.value.tags, (t) => t.type == str).data);
height := hb.graphics.getTextHeight(text);