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()
示例#2
0
 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()
示例#3
0
 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()
示例#4
0
 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()
示例#5
0
 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()
示例#6
0
def update():
    global playgame
    if (frog[0].getdeath() == 3):
        pygame.mixer.music.pause()
        g2d.fill_canvas((0, 0, 0))
        g2d.draw_image(gameover, (20, 10))
        g2d.draw_text_centered(("SCORE:" + str(score.count(1) * 1000)),
                               (255, 255, 255), (300, 400), 45)
    elif (playgame == True):
        x, y, w, h = frog[0].position()
        if ((x > 43 and x < 85) and (y > 45 and y < 70) and score[0] != 1):
            score[0] = 1
            frog[0].setposition(0)
            pygame.mixer.music.play()
        elif ((x > 175 and x < 205) and (y > 45 and y < 70) and score[1] != 1):
            score[1] = 1
            frog[0].setposition(0)
            pygame.mixer.music.play()
        elif ((x > 305 and x < 335) and (y > 45 and y < 70) and score[2] != 1):
            score[2] = 1
            frog[0].setposition(0)
            pygame.mixer.music.play()
        elif ((x > 435 and x < 475) and (y > 45 and y < 70) and score[3] != 1):
            score[3] = 1
            frog[0].setposition(0)
            pygame.mixer.music.play()
        elif ((x > 560 and x < 590) and (y > 45 and y < 70) and score[4] != 1):
            score[4] = 1
            frog[0].setposition(0)
            pygame.mixer.music.play()
        if (score.count(1) == 5):
            pygame.mixer.music.pause()
            g2d.fill_canvas((0, 0, 0))
            g2d.draw_image(win, (20, 10))
            g2d.draw_text_centered(("SCORE:" + str(score.count(1) * 1000)),
                                   (255, 255, 255), (300, 400), 45)
        else:
            frog[0].setcollideraft()
            frog[0].setcollidefiume()
            frog[0].setcollideturtle()
            frog[0].setcollidecrocodile()
            arena.move_all()
            g2d.fill_canvas((255, 255, 255))
            g2d.draw_image(background, (0, 0))
            g2d.draw_text(("SCORE:" + str(score.count(1) * 1000)),
                          (255, 0, 100), (0, 0), 25)
            g2d.draw_text(("DEATHS FROG:" + str(frog[0].getdeath())),
                          (255, 0, 100), (150, 0), 25)
            g2d.draw_text(("LIFE FROG:"), (255, 0, 100), (0, 465), 25)
            for i in range(0, 3 - frog[0].getdeath()):
                g2d.draw_image_clip(sprite, (100 + i * 18, 465, 18, 15),
                                    (14, 369, 18, 15))
            for i in range(0, 15):
                veicoli[i].move()
            for i in range(0, 12):
                raft[i].move()
            for i in range(0, 12):
                turtle[i].move()
            for i in range(0, 4):
                crocodile[i].move()
            frog[0].move()
            for a in arena.actors():
                if a != fiume and a != land[0] and a != land[1] and a != land[
                        2] and a != land[3] and a != land[4] and a != land[
                            5] and a != land[6]:
                    g2d.draw_image_clip(sprite, a.position(), a.symbol())

    else:
        g2d.fill_canvas((0, 0, 0))
        g2d.draw_image(logo, (20, 10))
        g2d.draw_text_centered(("PRESS ANY KEY"), (255, 255, 255), (300, 240),
                               25)
示例#7
0
 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)