Пример #1
0
 def load_text(self):
     font = pygame.font.SysFont("Arial", 50)
     img = pygame.image.load("assets/img/holders/TextHolder.png")
     move = text_to_sprite("Move Count: ", img, (230, 230, 230), [350, self.coords[1] - 10], font)
     undo = text_to_sprite("Undo Count: ", img, (230, 230, 230), [350, self.coords[1] + 180], font)
     self.move_text = pygame.sprite.Group(move)
     self.undo_text = pygame.sprite.Group(undo)
Пример #2
0
 def get_next_prev(self):
     img = pygame.image.load("assets/img/holders/prevNext.png")
     font = pygame.font.SysFont("Arial", 35)
     next_sprite = text_to_sprite("Next", img, (230, 230, 230), [1200, 900],
                                  font)
     prev_sprite = text_to_sprite("Prev", img, (230, 230, 230), [1050, 900],
                                  font)
     self.next = pygame.sprite.GroupSingle(next_sprite)
     self.prev = pygame.sprite.GroupSingle(prev_sprite)
Пример #3
0
    def load_pause(self):

        holder = pygame.image.load("assets/img/holders/speedHolder.png")
        font = pygame.font.SysFont("Arial", 40)
        pause = text_to_sprite("Pause", holder, (230, 230, 230), [1075, 225],
                               font)
        resume = text_to_sprite("Resume", holder, (230, 230, 230), [1075, 225],
                                font)
        self.pauseButton = pygame.sprite.GroupSingle(pause)
        self.resumeButton = pygame.sprite.GroupSingle(resume)
Пример #4
0
    def get_buttons(self):
        img = pygame.image.load("assets/img/holders/MainMenuHolder.png")
        font = pygame.font.SysFont("Arial", 70)
        play = text_to_sprite("Play", img, (230, 230, 230), [500, 300], font)
        watch = text_to_sprite("Watch", img, (230, 230, 230), [500, 500], font)
        settings = text_to_sprite("Settings", img, (230, 230, 230), [500, 700],
                                  font)

        self.play = pygame.sprite.GroupSingle(play)
        self.watch = pygame.sprite.GroupSingle(watch)
        self.settings = pygame.sprite.GroupSingle(settings)
Пример #5
0
    def get_levels(self, levels):
        self.levels = []
        self.curr_page = 0
        self.total_pages = 0
        levels_page = pygame.sprite.Group()
        img = pygame.image.load("assets/img/holders/level.png")
        font = pygame.font.SysFont("Arial", 70)

        x = 200
        y = 150
        rows = 3
        x_inc = (screen_width - x) // 3
        y_inc = (screen_height - y) // rows

        for i in range(1, len(levels) + 1):
            if i % 9 == 1 and i > 1:
                copy = levels_page.copy()
                self.levels.append(copy)
                pygame.sprite.Group.empty(levels_page)
                self.total_pages += 1
                x = 200
                y = 150

            sprite = text_to_sprite(str(i), img, (230, 230, 230), [x, y], font)
            levels_page.add(sprite)

            if i % 3 == 0 and i > 0:
                x = 200
                y += y_inc
            else:
                x += x_inc

        if len(levels) % 9 != 0:
            self.levels.append(levels_page)
Пример #6
0
    def load_algorithm_fail(self):
        self.solver_failed = False
        holder = pygame.image.load("assets/img/holders/failHolder.png")
        font = pygame.font.SysFont("Arial", 40)
        alg_fail = text_to_sprite(
            "Algorithm couldn't reach a solution in due time", holder,
            (230, 230, 230), [300, 400], font)

        self.alg_fail = pygame.sprite.GroupSingle(alg_fail)
Пример #7
0
    def load_speed(self):

        speed_holder = pygame.image.load("assets/img/holders/speedHolder.png")
        value_holder = pygame.image.load("assets/img/holders/prevNext.png")

        font = pygame.font.SysFont("Arial", 45)
        font2 = pygame.font.SysFont("Arial", 40)
        speed = text_to_sprite("Speed", speed_holder, (230, 230, 230),
                               [1075, 125], font)
        point_five = text_to_sprite("x0.5", value_holder, (230, 230, 230),
                                    [1250, 137.5], font2)
        normal = text_to_sprite("x1", value_holder, (230, 230, 230),
                                [1250, 137.5], font2)
        x2 = text_to_sprite("x2", value_holder, (230, 230, 230), [1250, 137.5],
                            font2)
        x4 = text_to_sprite("x4", value_holder, (230, 230, 230), [1250, 137.5],
                            font2)
        x8 = text_to_sprite("x8", value_holder, (230, 230, 230), [1250, 137.5],
                            font2)

        self.speed_holder = pygame.sprite.GroupSingle(speed)
        self.speeds = []
        self.speeds.append(pygame.sprite.GroupSingle(normal))
        self.speeds.append(pygame.sprite.GroupSingle(x2))
        self.speeds.append(pygame.sprite.GroupSingle(x4))
        self.speeds.append(pygame.sprite.GroupSingle(x8))
        self.speeds.append(pygame.sprite.GroupSingle(point_five))
Пример #8
0
    def get_buttons(self):
        self.sfx_active = True
        self.music_active = True
        self.curr_hint = 0

        img = pygame.image.load("assets/img/holders/SettingsHolders.png")
        hint_img = pygame.image.load("assets/img/holders/level.png")
        off_bg = pygame.image.load("assets/img/holders/offBg.png")
        on_bg = pygame.image.load("assets/img/holders/onBg.png")
        font = pygame.font.SysFont("Arial", 60)
        font2 = pygame.font.SysFont("Arial", 50)
        off1 = text_to_sprite("Off", off_bg, (0, 0, 0), [810, 410], font2)
        off2 = text_to_sprite("Off", off_bg, (0, 0, 0), [810, 560], font2)
        on1 = text_to_sprite("On", on_bg, (230, 230, 230), [810, 410], font2)
        on2 = text_to_sprite("On", on_bg, (230, 230, 230), [810, 560], font2)

        music = text_to_sprite("Music", img, (230, 230, 230), [390, 400], font)
        sfx = text_to_sprite("SFX", img, (230, 230, 230), [390, 550], font)

        hint = text_to_sprite("Hint", img, (230, 230, 230), [390, 700], font)
        greedy = text_to_sprite("greedy", hint_img, (230, 230, 230),
                                [800, 700], font2)
        astar = text_to_sprite("A*", hint_img, (230, 230, 230), [800, 700],
                               font2)
        bfs = text_to_sprite("BFS", hint_img, (230, 230, 230), [800, 700],
                             font2)
        dfs = text_to_sprite("DFS", hint_img, (230, 230, 230), [800, 700],
                             font2)
        ids = text_to_sprite("IDS", hint_img, (230, 230, 230), [800, 700],
                             font2)

        self.music = pygame.sprite.GroupSingle(music)
        self.sfx = pygame.sprite.GroupSingle(sfx)
        self.music_off = pygame.sprite.GroupSingle(off1)
        self.music_on = pygame.sprite.GroupSingle(on1)
        self.sfx_off = pygame.sprite.GroupSingle(off2)
        self.sfx_on = pygame.sprite.GroupSingle(on2)

        self.hint = pygame.sprite.GroupSingle(hint)
        self.algorithms = []
        self.algorithms.append(pygame.sprite.GroupSingle(astar))
        self.algorithms.append(pygame.sprite.GroupSingle(greedy))
        self.algorithms.append(pygame.sprite.GroupSingle(dfs))
        self.algorithms.append(pygame.sprite.GroupSingle(bfs))
        self.algorithms.append(pygame.sprite.GroupSingle(ids))