def update_buttons(self): global solved g2d.clear_canvas() g2d.set_color((0, 0, 0)) cols, rows = self._game.cols(), self._game.rows() for y in range(1, rows): g2d.draw_line((0, y * H), (cols * W, y * H)) for x in range(1, cols): g2d.draw_line((x * W, 0), (x * W, rows * H)) for y in range(rows): for x in range(cols): value = self._game.value_at(x, y) if '#' not in value: center = x * W + W // 2, y * H + H // 2 if '!' in value: g2d.set_color((0, 0, 200)) g2d.fill_circle(center, 14) g2d.set_color((255, 255, 255)) g2d.fill_circle(center, 12) g2d.set_color((0, 0, 0)) g2d.draw_text_centered(value[:-1], center, H // 2) else: g2d.fill_rect((x * W, y * H, W, H)) g2d.update_canvas() if self._game.finished() and not solved: g2d.alert(self._game.message()) g2d.close_canvas()
def update_buttons(self): g2d.clear_canvas() g2d.set_color((0, 0, 0)) cols, rows = self._game.cols(), self._game.rows() for y in range(1, rows): g2d.draw_line((0, y * H), (cols * W, y * H)) for x in range(1, cols): g2d.draw_line((x * W, 0), (x * W, rows * H)) for y in range(rows): for x in range(cols): g2d.set_color((0,0,0)) value = self._game.value_at(x, y) if self._game.checkblack(x,y): g2d.fill_rect((x * W, y * H, W, H)) center = x * W + W//2, y * H + H // 2 if self._game.checkcircle(x,y): g2d.fill_circle((center), W // 2) g2d.set_color((255,255,255)) g2d.fill_circle((center), W // 2 - 1) g2d.set_color((0,0,0)) g2d.draw_text_centered(value, center, H//2) g2d.update_canvas() if self._game.finished(): g2d.alert(self._game.message()) g2d.close_canvas()
def update_buttons(self): g2d.fill_canvas((255, 255, 255)) rows, cols = self._game.rows(), self._game.cols() for y in range(1, rows): g2d.draw_line((0, 0, 0), (0, y * H), (cols * W, y * H)) for x in range(1, cols): g2d.draw_line((0, 0, 0), (x * W, 0), (x * W, rows * H)) for y in range(rows): for x in range(cols): g2d.draw_text_centered(self._game.get_val(x, y), (0, 0, 0), (x * W + W // 2, y * H + H // 2), H // 2) g2d.update_canvas()
def update_buttons(self): g2d.clear_canvas() g2d.set_color((0, 0, 0)) rows, cols = self._game.rows(), self._game.cols() for y in range(1, rows): g2d.draw_line((0, y * H), (cols * W, y * H)) for x in range(1, cols): g2d.draw_line((x * W, 0), (x * W, rows * H)) for y in range(rows): for x in range(cols): value = self._game.value_at(x, y) center = x * W + W // 2, y * H + H // 2 g2d.draw_text_centered(value, center, H // 2) g2d.update_canvas() if self._game.finished(): g2d.alert(self._game.message()) g2d.close_canvas()
def update_buttons(self): g2d.clear_canvas() g2d.set_color((0, 0, 0)) rows, cols = self._game.rows(), self._game.cols() for y in range(1, rows): g2d.draw_line((0, y * H), (cols * W, y * H)) for x in range(1, cols): g2d.draw_line((x * W, 0), (x * W, rows * H)) for y in range(rows): for x in range(cols): value = self._game.value_at(x, y) center = x * W + W//2, y * H + H//2 g2d.draw_text_centered(value, center, H//2) g2d.update_canvas() if self._game.finished(): g2d.alert(self._game.message()) g2d.close_canvas()
def update_buttons(self): g2d.fill_canvas((255, 255, 255)) rows, cols, flag = self._game.rows(), self._game.cols(), 0 cellevuote = 0 for y in range(1, rows): g2d.draw_line((0, 0, 0), (0, y * H), (cols * W, y * H)) for x in range(1, cols + 1): g2d.draw_line((0, 0, 0), (x * W, 0), (x * W, rows * H)) for y in range(rows): for x in range(cols): if (self._game.get_valpos(y, x) == 0): g2d.draw_text_centered(" ", (0, 0, 0), (x * W + W // 2, y * H + H // 2), H // 2) cellevuote = cellevuote + 1 elif (self._game.get_valpos(y, x) == 2): g2d.draw_image(flag1, (x * W + W // 8, y * H + H // 8)) #g2d.draw_text_centered("<|", (0, 0, 0),(x * W + W//2, y * H + H//2), H//2) flag = flag + 1 elif (self._game.get_val(y, x) == -1): g2d.draw_image(bomb, (x * W + W // 8, y * H + H // 8)) else: g2d.draw_text_centered(str(self._game.get_val(y, x)), (0, 0, 0), (x * W + W // 2, y * H + H // 2), H // 2) g2d.draw_text_centered("MINE RIMANENTI DA SEGNALARE", (0, 0, 0), ((x * W) + 160, H // 2), H // 2) g2d.draw_text_centered(str(self._game.mines() - flag), (0, 0, 0), ((x * W) + 160, H), H // 2) g2d.draw_text_centered("CELLE VUOTE RIMANENTI", (0, 0, 0), ((x * W) + 160, H * 2), H // 2) g2d.draw_text_centered(str((cellevuote + flag) - self._game.mines()), (0, 0, 0), ((x * W) + 160, H * 3), H // 2) g2d.update_canvas() if (self._game.finished() == True): g2d.alert(self._game.message()) g2d.exit() g2d.draw_text_centered(self._game.message(), (0, 0, 255), (cols * W // 2, rows * H // 2), H // 2)