def restart_game(self):
     self.grid = grid_o.Grid(self.cell_textures, self.number_tex_list)
     self.is_alive = True
     self.mines_placed = False
     self.mines_flagged = 0
     self.empty_flagged = 0
     self.restart_button_state = 0
     self.time_elapsed = 0
     self.last_frame_time = pygame.time.get_ticks()
    def __init__(self):
        pygame.init()

        self.my_path = "%s/.." % os.path.dirname(os.path.realpath(__file__))

        logo = pygame.image.load("%s/img/minesweeper_logo.png" % self.my_path)
        pygame.display.set_icon(logo)

        pygame.display.set_caption("Minesweeper")

        self.screen = pygame.display.set_mode((const.WIDTH, const.HEIGHT))

        self.background_tex = pygame.image.load("%s/img/background.png" %
                                                self.my_path)
        self.cell_textures = [
            pygame.image.load("%s/img/cell/cell_hidden.png" % self.my_path),
            pygame.image.load("%s/img/cell/cell_revealed.png" % self.my_path),
            pygame.image.load("%s/img/cell/mine.png" % self.my_path),
            pygame.image.load("%s/img/cell/mine_red.png" % self.my_path),
            pygame.image.load("%s/img/cell/mine_green.png" % self.my_path),
            pygame.image.load("%s/img/cell/flag.png" % self.my_path)
        ]
        self.number_tex_list = [
            pygame.image.load("%s/img/numbers/num_1.png" % self.my_path),
            pygame.image.load("%s/img/numbers/num_2.png" % self.my_path),
            pygame.image.load("%s/img/numbers/num_3.png" % self.my_path),
            pygame.image.load("%s/img/numbers/num_4.png" % self.my_path),
            pygame.image.load("%s/img/numbers/num_5.png" % self.my_path),
            pygame.image.load("%s/img/numbers/num_6.png" % self.my_path),
            pygame.image.load("%s/img/numbers/num_7.png" % self.my_path),
            pygame.image.load("%s/img/numbers/num_8.png" % self.my_path)
        ]
        self.restart_button_list = [
            pygame.image.load(
                "%s/img/restart_button/restart_button_green.png" %
                self.my_path),
            pygame.image.load(
                "%s/img/restart_button/restart_button_yellow.png" %
                self.my_path),
            pygame.image.load("%s/img/restart_button/restart_button_red.png" %
                              self.my_path),
            pygame.image.load(
                "%s/img/restart_button/restart_button_green_clicked.png" %
                self.my_path),
            pygame.image.load(
                "%s/img/restart_button/restart_button_yellow_clicked.png" %
                self.my_path),
            pygame.image.load(
                "%s/img/restart_button/restart_button_red_clicked.png" %
                self.my_path)
        ]
        self.restart_button_rect = pygame.Rect(const.RESTART_BUTTON_COORD,
                                               const.RESTART_BUTTON_SIZE)

        # Highscore button
        self.highscore_button_tex = pygame.image.load("%s/img/highscore.png" %
                                                      self.my_path)
        self.highscore_button_clicked_tex = pygame.image.load(
            "%s/img/highscore_clicked.png" % self.my_path)
        self.highscore_cur_tex = self.highscore_button_tex
        self.highscore_button_rect = pygame.Rect(const.HIGHSCORE_BUTTON_COORD,
                                                 const.HIGHSCORE_BUTTON_SIZE)
        # Highscore panel
        self.highscore_panel_tex = pygame.image.load(
            "%s/img/highscore_menu.png" % self.my_path)
        self.highscore_panel_rect = pygame.Rect(const.HIGHSCORE_PANEL_COORD,
                                                const.HIGHSCORE_PANEL_SIZE)
        self.showing_highscores = False
        self.highscore_list = []
        # Change name button
        self.change_name_button_tex = pygame.image.load(
            "%s/img/change_name_button.png" % self.my_path)
        self.change_name_button_clicked_tex = pygame.image.load(
            "%s/img/change_name_button_clicked.png" % self.my_path)
        self.change_name_button_changing_tex = pygame.image.load(
            "%s/img/change_name_button_changing.png" % self.my_path)
        self.change_name_cur_tex = self.change_name_button_tex
        self.change_name_button_rect = pygame.Rect(const.CHANGE_NAME_COORD,
                                                   const.CHANGE_NAME_SIZE)
        self.changing_name = False

        self.ui_font = pygame.font.SysFont("monospace", 50, True)
        self.highscore_font = pygame.font.SysFont("monospace", 30, True)
        self.name_font = pygame.font.SysFont("monospace", 25, True)

        self.player_name = const.PLAYER_NAME

        ##################
        # This part should match restart_game()
        self.grid = grid_o.Grid(self.cell_textures, self.number_tex_list)
        self.is_alive = True
        self.mines_placed = False
        self.mines_flagged = 0
        self.empty_flagged = 0
        self.restart_button_state = 0
        self.time_elapsed = 0
        self.last_frame_time = pygame.time.get_ticks()
        ##################

        # For input
        self.left_mouse_held = False
        self.last_left_click = 0
        self.right_mouse_held = False
        self.last_cell_held = None
        self.last_clicked_celll = [
            self.grid.get_clicked_cell((100, 100)) for i in range(9)
        ]
        self.lr_mouse_held = False
        self.i = 1
        self.debug = debugger.Debugger("debug.log")