Пример #1
0
    def update_colors(self, h=None, s=None, v=None):
        self.update_color_choosers(h, s, v)
        if self.current_funct is not None:
            self.current_funct(self.custom_color_hsv[0],
                               self.custom_color_hsv[1],
                               self.custom_color_hsv[2])
            self.active_selection.set_color(
                ex.hsv_to_rgb(self.custom_color_hsv[0],
                              self.custom_color_hsv[1],
                              self.custom_color_hsv[2]))
            self.active_selection.update_me = True
            self.cat_ind.redraw_image()
            self.game_ind.redraw_image()
            self.cat_ind2.redraw_image()
            self.game_ind2.redraw_image()

        self.active_color = ex.hsv_to_rgb(self.custom_color_hsv[0],
                                          self.custom_color_hsv[1],
                                          self.custom_color_hsv[2])
        self.active_color.append(127)

        if self.active_selection.my_id == 5:
            self.info_ind.change_colors(self.bg_color, None, self.active_color,
                                        self.active_color)
            self.mainloop.dialog.load_images()
            self.mainloop.info.load_font_colors()
            self.mainloop.info.reload_colors()

        if self.active_selection.my_id == 0:
            for each in self.shape_inds:
                each.change_colors(self.bg_color, None, self.active_color,
                                   None)
                each.update_me = True
                each.init_images()
Пример #2
0
    def update_color_choosers(self, h=None, s=None, v=None):
        if h is not None:
            self.custom_color_hsv[0] = h * self.step
        if s is not None:
            self.custom_color_hsv[1] = s * self.step
        if v is not None:
            self.custom_color_hsv[2] = v * self.step

        if self.horizontal:
            ind = 0
        else:
            ind = 1

        for i in range(0, self.data[ind]-1):
            self.h_units[i].color = ex.hsv_to_rgb(i * self.step, self.custom_color_hsv[1], self.custom_color_hsv[2])
            self.h_units[i].initcolor = self.h_units[i].color
            self.h_units[i].update_me = True

        for i in range(0, self.data[ind]-1):
            self.s_units[i].color = ex.hsv_to_rgb(self.custom_color_hsv[0], i * self.step, self.custom_color_hsv[2])
            self.s_units[i].initcolor = self.s_units[i].color
            self.s_units[i].update_me = True

        for i in range(0, self.data[ind]-1):
            self.v_units[i].color = ex.hsv_to_rgb(self.custom_color_hsv[0], self.custom_color_hsv[1], i * self.step)
            self.v_units[i].initcolor = self.v_units[i].color
            self.v_units[i].update_me = True

        self.active_color = ex.hsv_to_rgb(self.custom_color_hsv[0], self.custom_color_hsv[1], self.custom_color_hsv[2])
Пример #3
0
    def update_color_choosers(self, h=None, s=None, v=None):
        if h is not None:
            self.custom_color_hsv[0] = h * self.step
        if s is not None:
            self.custom_color_hsv[1] = s * self.step
        if v is not None:
            self.custom_color_hsv[2] = v * self.step

        for i in range(0, 17):
            self.h_units[i].color = ex.hsv_to_rgb(i * self.step,
                                                  self.custom_color_hsv[1],
                                                  self.custom_color_hsv[2])
            self.h_units[i].initcolor = self.h_units[i].color
            self.h_units[i].update_me = True

        for i in range(0, 17):
            self.s_units[i].color = ex.hsv_to_rgb(self.custom_color_hsv[0],
                                                  i * self.step,
                                                  self.custom_color_hsv[2])
            self.s_units[i].initcolor = self.s_units[i].color
            self.s_units[i].update_me = True

        for i in range(0, 17):
            self.v_units[i].color = ex.hsv_to_rgb(self.custom_color_hsv[0],
                                                  self.custom_color_hsv[1],
                                                  i * self.step)
            self.v_units[i].initcolor = self.v_units[i].color
            self.v_units[i].update_me = True
Пример #4
0
    def create_game_objects(self, level=1):
        self.max_size = 99
        self.board.draw_grid = False

        # self.rng = (random.randrange(-30, -5, 5), random.randrange(5, 30, 5))
        self.rng = [-30, 30]
        self.number = random.randint(self.rng[0], self.rng[1])

        if self.mainloop.scheme is not None:
            white = self.mainloop.scheme.u_color
            h1 = 170
            color1 = ex.hsv_to_rgb(h1, 255, 255)
            bd_color1 = ex.hsv_to_rgb(h1, 127, 155)
        else:
            white = (255, 255, 255)
            color1 = self.temp2col(self.number)
            hsv_col = ex.rgb_to_hsv(color1[0], color1[1], color1[2])
            bd_color1 = ex.hsv_to_rgb(hsv_col[0], 187, 200)
        transp = (0, 0, 0, 0)

        data = [7, 10]
        self.data = data

        self.vis_buttons = [0, 0, 0, 0, 1, 1, 1, 0, 0]

        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0], data[1])
        scale = self.layout.scale
        self.board.level_start(data[0], data[1], scale)
        self.board.board_bg.update_me = True

        self.board.board_bg.line_color = (20, 20, 20)
        self.points = int(round((self.board.scale * 72 / 96) * 1.2, 0))
        self.t_font = pygame.font.Font(os.path.join('res', 'fonts', 'FreeSans', 'FreeSans.ttf'),
                                       (int(self.points / (self.board.scale / (60 * self.board.scale * 3 / 500.0)))))

        self.board.add_unit(0, 0, 3, data[1], classes.board.Label, "", white, "", 0)
        self.ther_canvas = self.board.units[-1]

        self.thermometer = classes.drw.thermometer.Thermometer(self, 3, self.data[1], self.board.scale,
                                                               color1, bd_color1, self.rng, self.number, 5)
        self.ther_canvas.painting = self.thermometer.get_canvas().copy()

        self.board.add_unit(4, 6, 2, 2, classes.board.ImgCenteredShip, "", transp,
                            img_src='nav_d_mts.png', alpha=True)
        self.board.ships[-1].set_tint_color(bd_color1)

        self.board.add_unit(3, 4, 4, 2, classes.board.Label, str(self.number)+"°C", white, "", 31)
        self.nm1 = self.board.units[-1]
        self.board.units[-1].font_color = bd_color1

        self.board.add_unit(4, 2, 2, 2, classes.board.ImgCenteredShip, "", transp,
                            img_src='nav_u_mts.png', alpha=True)
        self.board.ships[-1].set_tint_color(bd_color1)

        for each in self.board.ships:
            each.readable = False
            each.immobilize()
Пример #5
0
 def load_font_colors(self):
     self.font_color = ex.hsv_to_rgb(
         self.mainloop.cl.color_sliders[5][0] * 16, 255, 220)
     self.font_color1 = ex.hsv_to_rgb(
         self.mainloop.cl.color_sliders[5][0] * 16, 255, 255)
     self.font_color4 = ex.hsv_to_rgb(
         self.mainloop.cl.color_sliders[5][0] * 16, 150, 255)
     self.font_color2 = self.font_color
     self.font_color3 = self.font_color4
Пример #6
0
    def create_game_objects(self, level=1):
        self.max_size = 99
        self.board.draw_grid = False

        if self.mainloop.scheme is not None:
            white = self.mainloop.scheme.u_color
            h1 = 170
            h2 = 40
            color1 = ex.hsv_to_rgb(h1, 255, 255)
            color2 = ex.hsv_to_rgb(h2, 75, 255)
            bd_color1 = ex.hsv_to_rgb(h1, 127, 155)
            bd_color2 = ex.hsv_to_rgb(h2, 127, 155)
        else:
            white = (255, 255, 255)
            h1 = random.randrange(0, 255)
            h2 = (h1 + 128) % 255
            color1 = ex.hsv_to_rgb(h1, 150, 255)
            color2 = ex.hsv_to_rgb(h2, 40, 255)
            bd_color1 = ex.hsv_to_rgb(h1, 187, 200)
            bd_color2 = ex.hsv_to_rgb(h2, 100, 200)

        transp = (0, 0, 0, 0)

        data = [12, 8]
        self.data = data

        self.vis_buttons = [0, 0, 0, 0, 1, 1, 1, 0, 0]

        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0], data[1])
        scale = self.layout.scale
        self.board.level_start(data[0], data[1], scale)
        self.board.board_bg.update_me = True
        self.board.board_bg.line_color = (20, 20, 20)

        num2 = 10
        num1 = random.randint(1, num2-1)
        self.numbers = [num1, num2]

        self.board.add_unit(0, 0, data[1], data[1], classes.board.Label, "", white, "", 0)
        self.fraction_canvas = self.board.units[-1]
        self.fraction = classes.drw.fraction_hq.Fraction(1, self.board.scale * data[1], color1, color2, bd_color1, bd_color2, self.numbers, 2)
        self.fraction_canvas.painting = self.fraction.get_canvas().copy()

        self.board.add_unit(data[1] + 1, 5, 2, 2, classes.board.ImgCenteredShip, "", transp,
                            img_src='nav_d_mts.png', alpha=True)
        self.board.ships[-1].set_tint_color(bd_color1)

        self.board.add_unit(data[1] + 1, 3, 2, 2, classes.board.Label, "0.%d" % num1, white, "", 31)
        self.nm1 = self.board.units[-1]
        self.board.units[-1].font_color = bd_color1

        self.board.add_unit(data[1] + 1, 1, 2, 2, classes.board.ImgCenteredShip, "", transp,
                            img_src='nav_u_mts.png', alpha=True)
        self.board.ships[-1].set_tint_color(bd_color1)

        for each in self.board.ships:
            each.readable = False
            each.immobilize()
Пример #7
0
    def add_keys(self):
        if self.game_board.mainloop.scheme is not None and self.game_board.mainloop.scheme.dark:
            s = [170, 50, 50, 200]
            v = [150, 255, 255, 140]
            g = [150, 106, 16, 0]  # greys
        else:
            s = [50, 200, 150, 25]
            v = [255, 205, 200, 255]
            g = [186, 106, 32, 20]

        colors = [ex.hsv_to_rgb(35 * i, s[0], v[0]) for i in range(8)]
        colors.extend([ex.hsv_to_rgb(25, s[0], v[0]), [g[0], g[0], g[0]]])

        highlight_colors = [
            ex.hsv_to_rgb(35 * i, s[1], v[1]) for i in range(8)
        ]
        highlight_colors.extend(
            [ex.hsv_to_rgb(25, s[1], v[1]), [g[1], g[1], g[1]]])

        font_colors = [ex.hsv_to_rgb(35 * i, s[2], v[2]) for i in range(8)]
        font_colors.extend([ex.hsv_to_rgb(25, s[2], v[2]), [g[2], g[2], g[2]]])

        font_highlight_colors = [
            ex.hsv_to_rgb(35 * i, s[3], v[3]) for i in range(8)
        ]
        font_highlight_colors.extend(
            [ex.hsv_to_rgb(25, s[3], v[3]), [g[3], g[3], g[3]]])

        keys = self.game_board.lang.kbrd.kbrd_keys
        for each in keys:
            self.add_key(each, colors[each[10]], highlight_colors[each[10]],
                         font_colors[each[10]],
                         font_highlight_colors[each[10]])
        self.kbrd_h = self.keys[61].y + self.keys[61].h
Пример #8
0
    def __init__(self, kbrd, data_list, init_color, highlight_color):
        # data_list = [x, y, w, h, top_left, bottom_left, middle, letter, right_top, right_bottom,color_group]
        pygame.sprite.Sprite.__init__(self)
        self.kbrd = kbrd
        self.id = len(kbrd.keys)
        kbrd_w = self.kbrd.kbrd_w - 10
        self.x = (kbrd_w * data_list[0] // 445) + 5
        self.y = (kbrd_w * data_list[1] // 445) + 5
        self.w = (kbrd_w * data_list[2] // 445)
        self.h = (kbrd_w * data_list[3] // 445)
        self.data_list = data_list
        self.labels = [
            data_list[4], data_list[5], data_list[6], data_list[7],
            data_list[8], data_list[9]
        ]
        self.color = init_color
        self.init_color = init_color
        self.highlight_color = highlight_color
        hsv = ex.rgb_to_hsv(highlight_color[0], highlight_color[1],
                            highlight_color[2])
        self.outline_color = ex.hsv_to_rgb(hsv[0], hsv[1], hsv[2] - 50)
        self.font_1 = self.kbrd.kbrd_font[0]
        self.font_2 = self.kbrd.kbrd_font[1]

        self.image = pygame.Surface([self.w, self.h])

        self.rect = self.image.get_rect()
        self.rect.topleft = [self.x, self.y]

        self.draw_key()
Пример #9
0
    def __init__(self, kbrd, data_list, init_color, highlight_color):
        # data_list = [x, y, w, h, top_left, bottom_left, middle, letter, right_top, right_bottom,color_group]
        pygame.sprite.Sprite.__init__(self)
        self.kbrd = kbrd
        self.id = len(kbrd.keys)
        kbrd_w = self.kbrd.kbrd_w-10
        self.x = (kbrd_w * data_list[0] // 445)+5
        self.y = (kbrd_w * data_list[1] // 445)+5
        self.w = (kbrd_w * data_list[2] // 445)
        self.h = (kbrd_w * data_list[3] // 445)
        self.data_list = data_list
        self.labels = [data_list[4], data_list[5], data_list[6],data_list[7],data_list[8],data_list[9]]
        self.color = init_color
        self.init_color = init_color
        self.highlight_color = highlight_color
        hsv = ex.rgb_to_hsv(highlight_color[0],highlight_color[1],highlight_color[2])
        self.outline_color = ex.hsv_to_rgb(hsv[0],hsv[1],hsv[2]-50)
        self.font_1 = self.kbrd.kbrd_font[0]
        self.font_2 = self.kbrd.kbrd_font[1]

        self.image = pygame.Surface([self.w, self.h])

        self.rect = self.image.get_rect()
        self.rect.topleft = [self.x,self.y]

        self.draw_key()
Пример #10
0
    def create_game_objects(self, level = 1):
        self.board.draw_grid = False
        self.show_info_btn = False

        self.color = (255,255,255)#(234,218,225)

        font_color = ex.hsv_to_rgb(227,255,50)
        data = [23,15]
        #stretch width to fit the screen size
        x_count = self.get_x_count(data[1],even=None)
        if x_count > 23:
            data[0] = x_count

        self.data = data
        self.vis_buttons = [0,0,0,0,1,0,1,0,0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0],data[1])
        scale = self.layout.scale
        self.board.level_start(data[0],data[1],scale)

        self.board.board_bg.initcolor = self.color
        self.board.board_bg.color = self.color
        self.board.board_bg.update_me = True

        self.board.add_unit(0,0,data[0],1,classes.board.Label,"Copyright (C) 2012 - 2014  Ireneusz Imiolek",self.color,"",1)
        self.board.add_unit(0,1,data[0],1,classes.board.Label,"",self.color,"",2)
        self.board.add_unit(0,2,data[0],5,classes.board.Label,self.lang.d["Credits_long"],self.color,"",2)
        self.board.units[-1].valign = 1
        self.board.add_unit(0,7,data[0],1,classes.board.Label,"",self.color,"",2)
        self.board.add_unit(0,8,data[0],1,classes.board.Label,self.lang.d["Lic_title"],self.color,"",1)
        self.board.add_unit(0,9,data[0],6,classes.board.Label,self.lang.d["Lic_desc"],self.color,"",2)
        self.board.units[-1].valign = 1
        for each in self.board.units:
            each.font_color = font_color
Пример #11
0
    def load_images(self):
        self.bg_tint_color = ex.hsv_to_rgb(
            self.wnd.mainloop.cl.color_sliders[5][0] * 16, 255, 100)
        if len(self.img_src1) > 0:
            self.img_pos = (0, 0)
            try:
                self.img1 = pygame.image.load(
                    os.path.join('res', 'images', "dialog",
                                 self.img_src1)).convert_alpha()
                self.img3 = pygame.image.load(
                    os.path.join('res', 'images', "dialog",
                                 "dialog_bg_n.png")).convert_alpha()
                self.img3.fill(self.bg_tint_color,
                               special_flags=pygame.BLEND_ADD)

                self.img4 = pygame.image.load(
                    os.path.join('res', 'images', "dialog",
                                 "dialog_bg_h.png")).convert_alpha()
                self.img4.fill(self.bg_tint_color,
                               special_flags=pygame.BLEND_ADD)

                self.active_img = self.img1
            except:
                pass
        self.update()
Пример #12
0
    def change_num_btn(self, n1):
        if n1 == -1:
            if self.number > self.rng[0]:
                self.number -= 1
        elif n1 == 1:
            if self.number < self.rng[1]:
                self.number += 1

        color1 = self.temp2col(self.number)
        hsv_col = ex.rgb_to_hsv(color1[0], color1[1], color1[2])
        bd_color1 = ex.hsv_to_rgb(hsv_col[0], 187, 200)

        self.thermometer.update_colors(color1, bd_color1)
        self.nm1.set_value(str(self.number)+"°C")
        self.thermometer.update_values(self.number)
        self.ther_canvas.painting = self.thermometer.get_canvas().copy()
        self.ther_canvas.update_me = True

        for each in self.board.ships:
            each.set_tint_color(bd_color1)
            each.update_me = True

        self.nm1.font_color = bd_color1
        self.nm1.update_me = True

        self.mainloop.redraw_needed[0] = True
Пример #13
0
 def check_drawing(self):
     h = random.randrange(0, 255, 1)
     if self.mainloop.scheme is None:
         self.canvas_block.font_color = ex.hsv_to_rgb(h, self.color_s + 100, self.color_v - 100)
         self.active_color = ex.hsv_to_rgb(h, self.color_s, self.color_v)
     else:
         self.canvas_block.font_color = self.mainloop.scheme.u_font_color
         self.active_color = self.mainloop.scheme.shape_color
     if self.max_points == 4:
         self.check_quadrilateral(self.points)
         self.fill_poli(4)
     elif self.max_points == 3:
         self.check_triangle(self.points)
         self.fill_poli(3)
     elif self.max_points == 2:
         self.check_circle(self.points)
         self.fill_circle()
Пример #14
0
    def next_number(self):
        if self.mainloop.scheme is None:
            s = random.randrange(150, 225, 5)
            v = random.randrange(190, 225, 5)
            h = random.randrange(0, 255, 5)
            color0 = ex.hsv_to_rgb(h, 40, 230)  # highlight 1
            color1 = ex.hsv_to_rgb(h, 70, v)  # highlight 2
            color2 = ex.hsv_to_rgb(h, s, v)  # normal color
            color3 = ex.hsv_to_rgb(h, 230, 100)
        else:
            s = 200
            v = 200
            h = 170
            color0 = ex.hsv_to_rgb(h, 40, 230)  # highlight 1
            color1 = ex.hsv_to_rgb(h, 70, v)  # highlight 2
            color2 = ex.hsv_to_rgb(h, s, v)  # normal color
            color3 = (0, 0, 0)

        ln = len(self.number_hat)
        if ln > 0:
            index = random.randrange(0, ln)
            choice = self.number_hat[index]
            del (self.number_hat[index])
            num1 = int(choice[0:2])
            num2 = int(choice[2:])
            self.solution = [num1, num2, num1 - 1 + num2 - 1]
            for i in range(1, self.data[0] + 1, 2):
                for j in range(1, self.data[1] + 1):
                    unit_id = self.board.get_unit_id(i - 1, j - 1)
                    if (i + 1) // 2 == num1 and j == num2:
                        color = color0
                        self.board.units[unit_id].font_color = color3
                    elif (i + 1) // 2 == num1 or j == num2:
                        color = color1
                        self.board.units[unit_id].font_color = color1
                    elif (i + 1) // 2 == num2 and j == num1:  # ?
                        color = color2
                        self.board.units[unit_id].font_color = color2
                    else:
                        color = color2
                        self.board.units[unit_id].font_color = color1
                    mul = ((i + 1) // 2) + j
                    if i == 1 or j == 1:
                        if (i + 1) // 2 == num1 or j == num2:
                            self.board.units[unit_id].font_color = color3  # !
                        else:
                            self.board.units[unit_id].font_color = color1
                    else:
                        caption = ""

                    self.board.units[unit_id].color = color
                    self.board.units[unit_id].update_me = True
            self.board.units[0].font_color = color3
            self.outline_all(0, 1)

            self.home_square = self.board.units[(num1 - 1) * self.data[1] + num2 - 1]

            self.mainloop.redraw_needed[0] = True
        else:
            self.level.next_board()
Пример #15
0
 def check_drawing(self):
     h = random.randrange(0, 255, 1)
     if self.mainloop.scheme is None:
         self.canvas_block.font_color = ex.hsv_to_rgb(
             h, self.color_s + 100, self.color_v - 100)
         self.active_color = ex.hsv_to_rgb(h, self.color_s, self.color_v)
     else:
         self.canvas_block.font_color = self.mainloop.scheme.u_font_color
         self.active_color = self.mainloop.scheme.shape_color
     if self.max_points == 4:
         self.check_quadrilateral(self.points)
         self.fill_poli(4)
     elif self.max_points == 3:
         self.check_triangle(self.points)
         self.fill_poli(3)
     elif self.max_points == 2:
         self.check_circle()
         self.fill_circle()
Пример #16
0
 def reselect(self, selectid):
     for each in self.board.ships:
         if each.unit_id != selectid:
             each.font_color = (40, 40, 40)
             each.font = self.board.font_sizes[2]
         else:
             each.font_color = ex.hsv_to_rgb(self.mainloop.cl.color_sliders[5][0] * 16, 255, 200)
             each.font = self.board.font_sizes[0]
         each.update_me = True
Пример #17
0
    def __init__(self, game_board, wrapper, size, time, prefs):
        self.game_board = game_board
        self.show_outer_ring = prefs[0]
        self.show_minutes = prefs[1]
        self.show_24h = prefs[2]
        self.show_only_quarters_h = prefs[3]
        self.show_only_quarters_m = prefs[4]
        self.show_only_fives_m = prefs[5]
        self.show_roman = prefs[6]
        self.show_highlight = prefs[7]
        self.show_hour_offset = prefs[8]

        self.roman = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII"]

        if self.game_board.mainloop.scheme is not None:
            color1 = self.game_board.mainloop.scheme.color1  # bright side of short hand
            color3 = self.game_board.mainloop.scheme.color3  # inner font color
            color5 = self.game_board.mainloop.scheme.color5  # dark side of short hand
            color7 = self.game_board.mainloop.scheme.color7  # inner circle filling

            color2 = self.game_board.mainloop.scheme.color2  # bright side of long hand
            color4 = self.game_board.mainloop.scheme.color4  # ex.hsv_to_rgb(170,255,255)#outer font color
            color6 = self.game_board.mainloop.scheme.color6  # dark side of long hand
            color8 = self.game_board.mainloop.scheme.color8  # outer circle filling

        else:
            color1 = ex.hsv_to_rgb(225, 70, 230)
            color3 = ex.hsv_to_rgb(225, 255, 255)
            color5 = ex.hsv_to_rgb(225, 180, 240)
            color7 = ex.hsv_to_rgb(225, 10, 255)

            color2 = ex.hsv_to_rgb(170, 70, 230)
            color4 = ex.hsv_to_rgb(170, 255, 255)
            color6 = ex.hsv_to_rgb(170, 180, 240)
            color8 = ex.hsv_to_rgb(170, 10, 255)

        self.colors = [color1, color2]
        self.colors2 = [color3, color4]
        self.colors3 = [color5, color6]
        self.colors4 = [color7, color8]

        self.hand_coords = [[], []]
        self.size = size
        self.time = time
        self.center = [self.size // 2, self.size // 2]

        self.clock_wrapper = wrapper  # self.board.ships[-1]
        self.clock_wrapper.font = game_board.clock_fonts[0]
        self.clock_wrapper.font2 = game_board.clock_fonts[1]
        self.clock_wrapper.font3 = game_board.clock_fonts[2]

        self.clock_wrapper.hidden_value = [2, 3]
        self.clock_wrapper.font_color = color2
        self.draw_all(self.time)
Пример #18
0
    def next_number(self):
        if self.mainloop.scheme is None:
            s = random.randrange(150, 225, 5)
            v = random.randrange(190, 225, 5)
            h = random.randrange(0, 255, 5)
            color0 = ex.hsv_to_rgb(h,40,230) #highlight 1
            color1 = ex.hsv_to_rgb(h,70,v) #highlight 2
            color2 = ex.hsv_to_rgb(h,s,v) #normal color
            color3 = ex.hsv_to_rgb(h,230,100)
        else:
            s = 200#random.randrange(150, 225, 5)
            v = 200#random.randrange(190, 225, 5)
            h = 170#random.randrange(0, 255, 5)
            color0 = ex.hsv_to_rgb(h,40,230) #highlight 1
            color1 = ex.hsv_to_rgb(h,70,v) #highlight 2
            color2 = ex.hsv_to_rgb(h,s,v) #normal color
            color3 = (0,0,0)#ex.hsv_to_rgb(h,230,100)
        self.points = 1
        ln = len(self.number_hat)
        if ln > 0:
            index = random.randrange(0,ln)
            choice = self.number_hat[index]
            del(self.number_hat[index])
            num1 = int(choice[0:2])
            num2 = int(choice[2:])
            self.solution = [num1,num2,num1 * num2]
            for i in range(1,self.data[0]+1,2):
                for j in range(1,self.data[1]+1):
                    unit_id = self.board.get_unit_id(i-1,j-1)
                    if (i+1)//2 == num1 and j == num2:
                        color=color0
                        self.board.units[unit_id].font_color = color3
                    elif (i+1)//2 == num1 or j == num2:
                        color=color1
                        self.board.units[unit_id].font_color = color1
                    elif (i+1)//2 == num2 and j == num1:#?
                        color=color2
                        self.board.units[unit_id].font_color = color2
                    else:
                        color = color2#!
                        self.board.units[unit_id].font_color = color1
                    mul = ((i+1)//2)*j
                    if i == 1 or j == 1:
                        if (i+1)//2 == num1 or j == num2:
                            self.board.units[unit_id].font_color = color3# !
                        else:
                            self.board.units[unit_id].font_color = color1

                    self.board.units[unit_id].color = color
                    self.board.units[unit_id].update_me = True
            self.board.units[0].font_color = color3
            self.outline_all(0,1)

            self.home_square = self.board.units[(num1-1)*self.data[1] + num2-1]

            self.mainloop.redraw_needed[0] = True
        else:
            self.update_score(self.bonus)
            self.level.next_board()
Пример #19
0
    def create_game_objects(self, level=1):
        self.board.draw_grid = False
        self.show_info_btn = False

        self.color = (255, 255, 255)

        font_color = ex.hsv_to_rgb(227, 255, 50)
        font_color2 = ex.hsv_to_rgb(self.mainloop.cl.color_sliders[5][0] * 16,
                                    255, 150)
        #font_color2 = (20, 75, 92)
        data = [23, 16]

        self.data = data
        self.vis_buttons = [0, 0, 0, 0, 1, 0, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0], data[1])
        scale = self.layout.scale
        self.board.level_start(data[0], data[1], scale)

        self.board.board_bg.initcolor = self.color
        self.board.board_bg.color = self.color
        self.board.board_bg.update_me = True
        self.board.board_bg.line_color = (20, 20, 20)

        self.board.add_unit(0, 0, data[0], 1, classes.board.Label,
                            "Copyright (C) 2012 - 2019  Ireneusz Imiolek",
                            self.color, "", 1)
        self.board.add_unit(0, 1, data[0], 1, classes.board.Label, "",
                            self.color, "", 2)
        self.board.add_unit(0, 2, data[0], 5, classes.board.Label,
                            self.lang.d["Credits_long"], self.color, "", 2)
        self.board.units[-1].valign = 1
        if self.mainloop.android is None:
            self.board.add_unit(0, 7, data[0], 1, classes.board.Label, "",
                                self.color, "", 2)
            self.board.add_unit(0, 8, data[0], 1, classes.board.Label,
                                self.lang.d["Lic_title"], self.color, "", 1)
            self.board.add_unit(0, 9, data[0], 6, classes.board.Label,
                                self.lang.d["Lic_desc"], self.color, "", 2)
            self.board.units[-1].valign = 1

        for each in self.board.units:
            each.font_color = font_color2
Пример #20
0
    def create_game_objects(self, level=1):
        self.max_size = 99
        self.board.draw_grid = True

        if self.mainloop.scheme is not None:
            white = self.mainloop.scheme.u_color
        else:
            white = (255, 255, 255)

        data = [13, 8]
        self.data = data

        self.vis_buttons = [0, 0, 0, 0, 1, 1, 1, 0, 0]

        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0], data[1])
        scale = self.layout.scale
        self.board.level_start(data[0], data[1], scale)
        self.board.board_bg.update_me = True

        self.board.board_bg.line_color = (20, 20, 20)
        self.number_count = random.randint(2, 5)
        self.numbers = self.get_numbers(self.number_count, 5, 5)

        hues = []
        step = 255 // self.number_count
        hues.append(random.randint(5, 245))
        for i in range(1, self.number_count):
            hues.append((hues[0] + step * i) % 255)

        colors = [ex.hsv_to_rgb(hues[i], 187, 255) for i in range(self.number_count)]
        b_colors = [ex.hsv_to_rgb(hues[i], 187, 255) for i in range(self.number_count)]

        self.board.add_unit(0, 0, data[1], data[1], classes.board.Label, "", white, "", 0)
        self.fraction_canvas = self.board.units[-1]
        self.fraction = classes.drw.percentage_multi_hq.Percentage(1, self.board.scale * data[1], colors, b_colors, self.numbers)
        self.fraction_canvas.painting = self.fraction.get_canvas().copy()

        for each in self.board.ships:
            each.readable = False
            each.immobilize()
Пример #21
0
 def set_outline(self, color=[255, 0, 0], width=2):
     'enables the draw_outline and sets line color and width'
     self.perm_outline = True
     if color == 0 and hasattr(self, "door_outline") is False:  # if color is 0 calculate colour from base colour
         # convert to hsv
         c = self.color
         h, s, v = ex.rgb_to_hsv(c[0], c[1], c[2])
         outline_color = ex.hsv_to_rgb(h, s + 50, v - 50)
         self.perm_outline_color = outline_color
     elif color == 1:
         c = self.color
         h, s, v = ex.rgb_to_hsv(c[0], c[1], c[2])
         outline_color = ex.hsv_to_rgb(h, s + 20, v - 20)
         self.perm_outline_color = outline_color
     elif hasattr(self, "door_outline") is False:
         self.perm_outline_color = color
     else:
         pass
     self.perm_outline_width = width
     self.init_pow = width
Пример #22
0
    def update_colors(self, h=None, s=None, v=None):
        if h is not None:
            self.custom_color_hsv[0] = h * self.step
        if s is not None:
            self.custom_color_hsv[1] = s * self.step
        if v is not None:
            self.custom_color_hsv[2] = v * self.step

        for i in range(self.data[1] - 2):
            self.h_units[i].color = ex.hsv_to_rgb(i * self.step, self.custom_color_hsv[1], self.custom_color_hsv[2])
            self.h_units[i].initcolor = self.h_units[i].color
            self.h_units[i].update_me = True

        for i in range(self.data[1] - 2):
            self.s_units[i].color = ex.hsv_to_rgb(self.custom_color_hsv[0], i * self.step, self.custom_color_hsv[2])
            self.s_units[i].initcolor = self.s_units[i].color
            self.s_units[i].update_me = True

        for i in range(self.data[1] - 2):
            self.v_units[i].color = ex.hsv_to_rgb(self.custom_color_hsv[0], self.custom_color_hsv[1], i * self.step)
            self.v_units[i].initcolor = self.v_units[i].color
            self.v_units[i].update_me = True
        self.current_col_ind.color = ex.hsv_to_rgb(self.custom_color_hsv[0], self.custom_color_hsv[1], self.custom_color_hsv[2])
        self.active_color = self.current_col_ind.color
        self.active_color.append(127)
        if self.custom_color_hsv[2] > 127:
            self.border_color = ex.hsv_to_rgb(self.custom_color_hsv[0], self.custom_color_hsv[1], self.custom_color_hsv[2] - 50)
        else:
            self.border_color = ex.hsv_to_rgb(self.custom_color_hsv[0], self.custom_color_hsv[1], self.custom_color_hsv[2] + 50)
        #self.border_color.append(127)
        self.current_col_ind.update_me = True
Пример #23
0
    def create_colors(self):
        self.tc_fg_tint_color = ex.hsv_to_rgb(self.color_sliders[0][0] * 16,
                                              self.color_sliders[0][1] * 16,
                                              self.color_sliders[0][2] * 16)

        self.tc_bg_tint_color = ex.hsv_to_rgb(self.color_sliders[1][0] * 16,
                                              self.color_sliders[1][1] * 16,
                                              self.color_sliders[1][2] * 16)

        # category
        self.c_bg_tint_color = ex.hsv_to_rgb(self.color_sliders[0][0] * 16,
                                             self.color_sliders[0][1] * 16,
                                             self.color_sliders[0][2] * 16)

        self.c_fg_tint_color = ex.hsv_to_rgb(self.color_sliders[1][0] * 16,
                                             self.color_sliders[1][1] * 16,
                                             self.color_sliders[1][2] * 16)

        # game
        self.g_bg_tint_color = ex.hsv_to_rgb(self.color_sliders[2][0] * 16,
                                             self.color_sliders[2][1] * 16,
                                             self.color_sliders[2][2] * 16)

        self.g_fg_tint_color = ex.hsv_to_rgb(self.color_sliders[3][0] * 16,
                                             self.color_sliders[3][1] * 16,
                                             self.color_sliders[3][2] * 16)

        # game progress
        self.lvl_completed_col = ex.hsv_to_rgb(self.color_sliders[4][0] * 16,
                                               self.color_sliders[4][1] * 16,
                                               self.color_sliders[4][2] * 16)

        self.lvl_not_compl_col = ex.hsv_to_rgb(self.color_sliders[4][0] * 16,
                                               96, 255)
        self.lvl_not_compl_col_dark = ex.hsv_to_rgb(
            self.color_sliders[4][0] * 16, 96, 96)

        self.info_buttons_col = ex.hsv_to_rgb(self.color_sliders[5][0] * 16,
                                              self.color_sliders[5][1] * 16,
                                              self.color_sliders[5][2] * 16)
Пример #24
0
    def create_game_objects(self, level=1):
        self.board.draw_grid = False
        self.show_info_btn = False

        self.color = (255, 255, 255)  #(234,218,225)

        font_color = ex.hsv_to_rgb(227, 255, 50)
        data = [23, 16]
        #stretch width to fit the screen size
        x_count = self.get_x_count(data[1], even=None)
        if x_count > 23:
            data[0] = x_count

        self.data = data
        self.vis_buttons = [0, 0, 0, 0, 1, 0, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0], data[1])
        scale = self.layout.scale
        self.board.level_start(data[0], data[1], scale)

        self.board.board_bg.initcolor = self.color
        self.board.board_bg.color = self.color
        self.board.board_bg.update_me = True

        self.board.add_unit(0, 0, data[0], 1, classes.board.Label,
                            "Copyright (C) 2012 - 2015  Ireneusz Imiolek",
                            self.color, "", 1)
        self.board.add_unit(0, 1, data[0], 1, classes.board.Label, "",
                            self.color, "", 2)
        self.board.add_unit(0, 2, data[0], 5, classes.board.Label,
                            self.lang.d["Credits_long"], self.color, "", 2)
        self.board.units[-1].valign = 1
        self.board.add_unit(0, 7, data[0], 1, classes.board.Label, "",
                            self.color, "", 2)
        self.board.add_unit(0, 8, data[0], 1, classes.board.Label,
                            self.lang.d["Lic_title"], self.color, "", 1)
        self.board.add_unit(0, 9, data[0], 6, classes.board.Label,
                            self.lang.d["Lic_desc"], self.color, "", 2)
        self.board.units[-1].valign = 1

        self.board.add_unit(0, 15, data[0], 1, classes.board.Letter, "<<",
                            self.color, "", 0)
        self.btn_back = self.board.ships[-1]

        for each in self.board.units:
            each.font_color = font_color

        self.btn_back.font_color = (255, 0, 0)
        self.btn_back.highlight = False
        self.btn_back.readable = False
Пример #25
0
    def load_images(self):
        self.bg_tint_color = ex.hsv_to_rgb(
            self.mainloop.cl.color_sliders[5][0] * 16, 255, 100)
        self.font_color = ex.hsv_to_rgb(
            self.mainloop.cl.color_sliders[5][0] * 16, 255, 100)

        for each in self.elements:
            each.load_images()

        self.img_pos = (40, 40)
        try:
            #self.img = pygame.image.load(os.path.join('res', 'images', "dialog_bg.png")).convert_alpha()
            self.img1 = pygame.image.load(
                os.path.join('res', 'images', "dialog",
                             "dialog_bg.png")).convert_alpha()
            self.img1.fill(self.bg_tint_color, special_flags=pygame.BLEND_ADD)

            self.img2 = pygame.image.load(
                os.path.join('res', 'images', "dialog",
                             "dialog_bg_star.png")).convert_alpha()
            self.img2.fill(self.bg_tint_color, special_flags=pygame.BLEND_ADD)

            self.img3 = pygame.image.load(
                os.path.join('res', 'images', "dialog",
                             "dialog_bg_d.png")).convert_alpha()

            self.img4 = pygame.image.load(
                os.path.join('res', 'images', "dialog",
                             "dialog_bg_star_d.png")).convert_alpha()

            self.img5 = pygame.image.load(
                os.path.join('res', 'images', "dialog",
                             "dialog_bg_allstar_d.png")).convert_alpha()
            self.images = [self.img1, self.img2]
            self.decors = [self.img3, self.img4, self.img5]
        except:
            pass
Пример #26
0
    def create_game_objects(self, level = 1):
        self.board.decolorable = False
        self.board.draw_grid = False

        color = (234,218,225)
        self.color = color
        self.grey = (200,200,200)
        self.greyoutline = (190,190,190)
        self.font_hl = (100,0,250)
        self.font_hl2 = (250,0,200)
        self.font_hl3 = (200,0,250)

        self.task_str_color = ex.hsv_to_rgb(200,200,230)
        self.activated_col = self.font_hl
        white = (255,255,255)
        self.white = white
        self.bg_col = white
        if self.mainloop.scheme is not None:
            if self.mainloop.scheme.dark:
                self.bg_col = (0,0,0)
        self.level.games_per_lvl = 5
        self.auto_select = True
        if self.level.lvl == 1:
            self.level.games_per_lvl = 3
            rngs = [2,5,20,50]
        elif self.level.lvl == 2:
            self.level.games_per_lvl = 3
            rngs = [3,9,20,50]
        elif self.level.lvl == 3:
            self.level.games_per_lvl = 3
            rngs = [3,9,50,99]
        elif self.level.lvl == 4:
            rngs = [3,9,100,150]
        elif self.level.lvl == 5:
            rngs = [3,9,200,500]
        elif self.level.lvl == 6:
            rngs = [3,9,500,999]
        elif self.level.lvl == 7:
            rngs = [20,50,21,99]
        elif self.level.lvl == 8:
            rngs = [3,9,200,500]
            self.auto_select = False
        elif self.level.lvl == 9:
            rngs = [3,9,500,999]
            self.auto_select = False
        elif self.level.lvl == 10:
            rngs = [20,50,21,99]
            self.auto_select = False

        if self.lang.lang == 'pl':
            self.divisor_pos = 1
        else:
            self.divisor_pos = 0

        data = [39,25]

        self.points = self.level.lvl
        #stretch width to fit the screen size
        x_count = self.get_x_count(data[1],even=None)
        if x_count > 39:
            data[0] = x_count

        self.data = data

        self.vis_buttons = [1,1,1,1,1,1,1,0,0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0],data[1])
        scale = self.layout.scale
        self.board.level_start(data[0],data[1],scale)
        
        self.top_line = self.board.scale//2
        
        nr1 = random.randrange(rngs[0],rngs[1])
        nr2 = random.randrange(rngs[2],rngs[3])
        self.n1 = nr1 * nr2
        self.n2 = nr1
        self.sumn1n2 = nr2 #self.n1+self.n2
        self.n1s = str(self.n1)
        self.n2s = str(self.n2)
        self.sumn1n2s = str(self.sumn1n2)
        self.n1sl = len(self.n1s)
        self.n2sl = len(self.n2s)
        self.sumn1n2sl =len(self.sumn1n2s)
        self.cursor_pos = 0
        self.correct = False
        self.carryl = []
        self.resultl = []
        self.nums1l = []
        self.nums2l = []
        self.ship_id = 0
        self.digits = ["0","1","2","3","4","5","6","7","8","9"]

        if self.divisor_pos == 0:
            r_offset = 0
            d_offset = 0
            ds_offset = 0
            d_str = "¥"
            d_h = 3
            num2_align = 2
        else:
            r_offset = 4
            d_offset = self.n1sl*2+1
            ds_offset = self.n1sl*2-3
            d_str = "÷"
            d_h = 4
            num2_align = 1

        if self.lang.lang == 'el':
            qm = ";"
        else:
            qm = "?"
        question = self.n1s + " ÷ " + self.n2s + " = " + qm
        #question
        self.board.add_unit(1,0,data[0]-1-self.sumn1n2sl*2-1-self.n1sl*2 ,2,classes.board.Label,question,self.bg_col,"",21)
        self.board.units[-1].align = 1
        j = 0
        xs = self.data[0]-self.n1sl*2
        #first number
        for i in range(self.n1sl):
            self.board.add_unit(xs+i*2-r_offset,3,2,2,classes.board.Label,self.n1s[i],self.bg_col,"",21)
            self.nums1l.append(self.board.units[-1])
            self.nums1l[-1].font_color = self.grey
            self.nums1l[-1].pos_id = i
            j += 1

        self.board.add_unit(data[0]-4-j*2+d_offset,3,3,2,classes.board.Label,self.n2s,self.bg_col,"",21)
        self.num2 = self.board.units[-1]
        self.num2.align = num2_align

        #line = "―" * (self.n1sl*2)

        self.board.add_unit(data[0]-self.n1sl*2-r_offset,2,self.n1sl*2,1,classes.board.Label,"",self.bg_col,"",21)
        self.line_unit = self.board.units[-1]
        self.draw_hori_line(self.line_unit)
        
        #self.board.units[-1].text_wrap = False
        if self.divisor_pos == 0:
            self.board.add_unit(data[0]-self.n1sl*2-1+ds_offset,2,1,d_h,classes.board.Label,"",self.bg_col,"",21)
            self.vert_line = self.board.units[-1]
            self.draw_vert_line(self.vert_line)
        else:
            self.board.add_unit(data[0]-self.n1sl*2-1+ds_offset,2,1,d_h,classes.board.Label,d_str,self.bg_col,"",21)
        self.division_sign = self.board.units[-1]
        
        
        self.resl = []
        self.nbel = []
        self.mpll = []
        self.subl = []
        self.minl = [] # to store minus signs

        res = [0 for i in range(self.n1sl)]
        nbr = [0 for i in range(self.n1sl)]
        nbe = [0 for i in range(self.n1sl)]
        mpl = [0 for i in range(self.n1sl)]
        sub = [0 for i in range(self.n1sl)]
        #[res,nbr,mpl,sub,line]
        yp = [0,3,5,8,7]

        xp = [xs,xs,xs+2,xs+2,xs]
        self.activables = 0
        for i in range(self.n1sl):
            if i > 0:
                nbr[i] = sub[i-1] * 10 + int(self.n1s[i])
                nbe[i] = int(self.n1s[i])
                self.board.add_unit(xp[1]-r_offset,yp[1],2,2,classes.board.Letter,"",self.bg_col,"",21)
                self.nbel.append(self.board.ships[-1])
                self.nbel[-1].pos_id = i
                self.activables += 1
            elif i == 0:
                nbr[i] = int(self.n1s[i])
                nbe[i] = int(self.n1s[i])
            res[i] = nbr[i] / self.n2
            self.board.add_unit(xp[0]-r_offset,yp[0],2,2,classes.board.Letter,"",self.bg_col,"",21)
            self.resl.append(self.board.ships[-1])
            self.resl[-1].pos_id = i
            self.activables += 1

            mpl[i] = self.n2 * res[i]
            mpls = str(mpl[i])
            mplsl = len(mpls)
            self.board.add_unit(xp[2]-mplsl*2 - 2-r_offset,yp[2],2,2,classes.board.Label,"-",self.bg_col,"",21)
            self.minl.append(self.board.units[-1])
            self.mpll.append([])
            for j in range(mplsl):
                self.board.add_unit(xp[2]-mplsl*2 + j*2-r_offset,yp[2],2,2,classes.board.Letter,"",self.bg_col,"",21)
                self.mpll[i].append(self.board.ships[-1])
                self.mpll[i][-1].pos_id = i
                self.mpll[i][-1].posy_id = j
                self.activables += 1
            sub[i] = nbr[i] - mpl[i]
            subs = str(sub[i])
            subsl = len(subs)
            self.subl.append([])
            for j in range(subsl):
                self.board.add_unit(xp[3]-subsl*2 + j*2-r_offset,yp[3],2,2,classes.board.Letter,"",self.bg_col,"",21)
                self.subl[i].append(self.board.ships[-1])
                self.subl[i][-1].pos_id = i
                self.subl[i][-1].posy_id = j
                self.activables += 1

            self.board.add_unit(xp[4]+(2-len(str(nbr[i]))*2)-r_offset,yp[4],len(str(nbr[i]))*2,1,classes.board.Label,"",self.bg_col,"",21)
            #self.board.units[-1].text_wrap = False
            self.draw_hori_line(self.board.units[-1])
            for i in range(5):
                xp[i] += 2
                if i > 0:
                    yp[i] += 5
            self.home_square = self.board.ships[0]
            self.board.active_ship = self.home_square.unit_id

        for each in self.board.ships:
            each.immobilize()

        self.deactivate_colors()
        self.reactivate_colors()
Пример #27
0
    def create_game_objects(self, level = 1):
        self.board.decolorable = False
        self.board.draw_grid = False

        color = (234,218,225)
        self.color = color
        self.grey = (200,200,200)
        self.greyoutline = (190,190,190)
        self.grey2 = (150,150,150)
        self.font_hl = (100,0,250)
        self.font_hl2 = (250,0,200)
        self.task_str_color = ex.hsv_to_rgb(200,200,230)
        self.activated_col = self.font_hl
        white = (255,255,255)
        self.bg_col = white
        self.top_line = 3#self.board.scale//2
        if self.mainloop.scheme is not None:
            if self.mainloop.scheme.dark:
                self.bg_col = (0,0,0)
        self.level.games_per_lvl = 5
        if self.level.lvl == 1:
            rngs = [11,50,11,20]
            self.level.games_per_lvl = 3
        elif self.level.lvl == 2:
            rngs = [20,50,20,30]
            self.level.games_per_lvl = 3
        elif self.level.lvl == 3:
            rngs = [50,150,30,75]
            self.level.games_per_lvl = 3
        elif self.level.lvl == 4:
            rngs = [150,500,50,75]
        elif self.level.lvl == 5:
            rngs = [500,1000,75,100]
        elif self.level.lvl == 6:
            rngs = [1000,2500,100,299]
        elif self.level.lvl == 7:
            rngs = [2500,9999,250,999]

        data = [39,24]
        self.points = self.level.lvl
        #stretch width to fit the screen size
        x_count = self.get_x_count(data[1],even=None)
        if x_count > 39:
            data[0] = x_count

        self.data = data

        self.vis_buttons = [1,1,1,1,1,1,1,0,0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0],data[1])
        scale = self.layout.scale
        self.board.level_start(data[0],data[1],scale)
        self.n1 = random.randrange(rngs[0],rngs[1])
        self.n2 = random.randrange(rngs[2],rngs[3])
        self.sumn1n2 = self.n1*self.n2
        self.n1s = str(self.n1)
        self.n2s = str(self.n2)
        self.sumn1n2s = str(self.sumn1n2)
        self.n1sl = len(self.n1s)
        self.n2sl = len(self.n2s)
        self.sumn1n2sl =len(self.sumn1n2s)

        self.cursor_pos = 0
        self.correct = False
        self.carryl = []
        self.carrylall = []
        self.carrysuml = []
        self.semiresultl = []
        self.semiresultlall = []
        self.semiresultlengths = []
        self.resultl = []
        self.all_count = 0
        for i in range(self.n2sl):
            self.carryl.append([])
            self.semiresultl.append([])
            if int(self.n2s[self.n2sl-1-i]) == 0:
                self.semiresultlengths.append(self.n1sl)
            else:
                self.semiresultlengths.append(len(str(int(self.n2s[self.n2sl-1-i])*self.n1)))
        self.semi_count = sum(self.semiresultlengths)
        self.nums1l = []
        self.nums2l = []
        self.ship_id = 0
        self.digits = ["0","1","2","3","4","5","6","7","8","9"]

        if self.lang.lang == 'el':
            qm = ";"
        else:
            qm = "?"

        question = self.n1s + " × " + self.n2s + " = " + qm
        #question
        self.board.add_unit(1,3,data[0]-1-self.sumn1n2sl*3 ,3,classes.board.Label,question,self.bg_col,"",21)
        self.board.units[-1].align = 1

        #carry 1
        for i in range(self.n2sl):
            for j in range(self.n1sl):
                self.board.add_unit(data[0]-5-j*3,2-i,1,1,classes.board.Letter,"",self.bg_col,"",0)
                self.carryl[i].append(self.board.ships[-1])
                self.carryl[i][-1].set_outline(self.grey, 1)
                self.carryl[i][-1].pos_id = j
                self.carryl[i][-1].posy_id = i
                self.carrylall.append(self.carryl[i][-1])

        #first number
        for i in range(self.n1sl):
            self.board.add_unit(data[0]-3-i*3,3,3,3,classes.board.Label,self.n1s[-(i+1)],self.bg_col,"",21)
            self.nums1l.append(self.board.units[-1])
            self.nums1l[-1].font_color = self.grey
            self.nums1l[-1].pos_id = i
        #second number
        i = 0
        for i in range(self.n2sl):
            self.board.add_unit(data[0]-3-i*3,6,3,3,classes.board.Label,self.n2s[-(i+1)],self.bg_col,"",21)
            self.nums2l.append(self.board.units[-1])
            self.nums2l[-1].pos_id = i
        i += 1
        self.board.add_unit(data[0]-3-i*3,6,3,3,classes.board.Label,"×",self.bg_col,"",21)
        self.plus_label = self.board.units[-1]
        #line
        #line = "―" * (self.sumn1n2sl*2)
        self.board.add_unit(data[0]-self.sumn1n2sl*3,9,self.sumn1n2sl*3,1,classes.board.Label,"",self.bg_col,"",21)
        self.draw_hori_line(self.board.units[-1])
        self.board.units[-1].text_wrap = False

        for i in range(self.sumn1n2sl - 2):
            self.board.add_unit(data[0]-8-i*3,10,1,1,classes.board.Letter,"",self.bg_col,"",0)
            self.carrysuml.append(self.board.ships[-1])
            self.carrysuml[-1].set_outline(self.grey, 1)
            self.carrysuml[-1].pos_id = i

        for j in range(self.n2sl):
            for i in range(self.semiresultlengths[j]):
                self.board.add_unit(data[0]-3-i*3-j*3,11+j*3,3,3,classes.board.Letter,"",self.bg_col,"",21)
                self.semiresultl[j].append(self.board.ships[-1])
                self.semiresultl[j][-1].set_outline(self.grey, 1)
                self.semiresultl[j][-1].pos_id = i
                self.semiresultl[j][-1].posy_id = j
                self.semiresultlall.append(self.semiresultl[j][-1])

        self.board.add_unit(data[0]-self.sumn1n2sl*3,10+self.n2sl*3+1,self.sumn1n2sl*3,1,classes.board.Label,"",self.bg_col,"",21)
        self.draw_hori_line(self.board.units[-1])
        #self.board.units[-1].text_wrap = False
        self.board.add_unit(data[0]-(self.sumn1n2sl+1)*3,7+self.n2sl*3+1,3,3,classes.board.Label," + ",self.bg_col,"",21)
        self.plus2_label = self.board.units[-1]
        for i in range(self.sumn1n2sl):
            self.board.add_unit(data[0]-3-i*3,10+self.n2sl*3+2,3,3,classes.board.Letter,"",self.bg_col,"",21)
            self.resultl.append(self.board.ships[-1])
            self.resultl[-1].set_outline(self.grey, 1)
            self.resultl[-1].pos_id = i

        self.resultl[0].set_outline(self.activated_col, 1)
        self.home_square = self.semiresultl[0][0]
        self.board.active_ship = self.home_square.unit_id

        self.all_count = sum(self.semiresultlengths) + self.n1sl + self.n2sl + self.sumn1n2sl * 2 - 2 + (self.sumn1n2sl - 1) * self.n2sl
        self.all_a_count = len(self.board.ships) #self.all_count - self.n1sl - self.n2sl

        for each in self.board.ships:
            each.immobilize()

        self.deactivate_colors()
        self.reactivate_colors()
Пример #28
0
    def create_game_objects(self, level = 1):
        self.board.decolorable = False
        self.board.draw_grid = True

        color = ex.hsv_to_rgb(225,15,235)
        self.col_bg = (180,180,180)
        if self.mainloop.scheme is None or not self.mainloop.scheme.dark:
            self.red_color = (220,220,255)
            self.green_color = (220,255,220)
            self.blue_color = (255,255,220)
            self.red_color2 = (0,0,255)
            self.green_color2 = (0,255,0)
            self.blue_color2 = (255,255,0)
            font_color = (0,0,0)
        else:
            self.red_color = (0,0,55)
            self.green_color = (0,55,0)
            self.blue_color = (55,55,0)
            self.red_color2 = (0,0,155)
            self.green_color2 = (0,155,0)
            self.blue_color2 = (155,155,0)
            font_color = (255,255,255)
            self.col_bg = (50,50,50)
        self.turn=1
        if self.level.lvl == 1:
            data = [10,12,2]
        elif self.level.lvl == 2:
            data = [10,14,2]
        elif self.level.lvl == 3:
            data = [10,16,1]
        elif self.level.lvl == 4:
            data = [10,18,0]
        elif self.level.lvl == 5:
            data = [10,20,0]
        #stretch width to fit the screen size
        x_count = self.get_x_count(data[1],even=True)
        if x_count > 10:
            data[0] = x_count

        self.data = data
        self.scores = [0,0,0]
        self.score_board = []
        self.imgs=[]
        self.moves_taken = 0
        self.max_moves = self.data[0]*(self.data[1]-3)
        self.game_state = [[0 for x in range(0,data[1])] for y in range(0,data[0])]
        self.lookaround = [[-1,-1],[0,-1],[1,-1],[1,0],[1,1],[0,1],[-1,1],[-1,0]]

        self.vis_buttons = [0,1,1,1,1,1,1,0,0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0],data[1])
        scale = self.layout.scale
        self.board.level_start(data[0],data[1],scale)

        #player label
        self.board.add_unit(1,0,data[0]-6,1,classes.board.Letter,self.d["Player"] +" 1",self.red_color2,"",self.data[2])
        self.board.add_unit(1,1,data[0]-6,1,classes.board.Letter,self.d["Player"] +" 2",self.green_color,"",self.data[2])
        self.board.add_unit(1,2,data[0]-6,1,classes.board.Letter,self.d["Player"] +" 3",self.blue_color,"",self.data[2])
        self.board.board_bg.line_color = self.col_bg
        scheme = "white"
        if self.mainloop.scheme is not None:
            self.board.board_bg.line_color = self.col_bg
            if self.mainloop.scheme.dark:
                scheme = "black"
                self.board.board_bg.line_color = (200,200,200)
        self.board.board_bg.update_me = True

        ttx = os.path.join("schemes", scheme, "tictactoe_x.png")
        tto = os.path.join("schemes", scheme, "tictactoe_o.png")
        tts = os.path.join("schemes", scheme, "tictactoe_s.png")
        ttx2 = os.path.join("schemes", scheme, "tictactoe_x2.png")
        tto2 = os.path.join("schemes", scheme, "tictactoe_o2.png")
        tts2 = os.path.join("schemes", scheme, "tictactoe_s2.png")
        ttv = os.path.join("schemes", scheme, "tictactoe_v.png")
        ttyx = os.path.join("schemes", scheme, "tictactoe_y.png")

        #player colour label
        self.board.add_unit(data[0]-5,0,1,1,classes.board.ImgShip,"x",self.red_color,ttx,0)
        self.imgs.append(self.board.ships[-1].img.copy())

        self.board.add_unit(data[0]-5,1,1,1,classes.board.ImgShip,"o",self.green_color,tto,0)
        self.imgs.append(self.board.ships[-1].img.copy())

        self.board.add_unit(data[0]-5,2,1,1,classes.board.ImgShip,"s",self.blue_color,tts,0)
        self.imgs.append(self.board.ships[-1].img.copy())

        self.board.add_unit(data[0]-4,0,1,1,classes.board.ImgShip,"x",self.red_color,ttx2,0)
        self.imgs.append(self.board.ships[-1].img.copy())

        self.board.add_unit(data[0]-4,1,1,1,classes.board.ImgShip,"o",self.green_color,tto2,0)
        self.imgs.append(self.board.ships[-1].img.copy())

        self.board.add_unit(data[0]-4,2,1,1,classes.board.ImgShip,"s",self.blue_color,tts2,0)
        self.imgs.append(self.board.ships[-1].img.copy())

        #score counters
        self.board.add_unit(data[0]-3,0,3,1,classes.board.Letter,str(self.scores[0]),self.red_color,"",0)
        self.score_board.append(self.board.ships[-1])

        self.board.add_unit(data[0]-3,1,3,1,classes.board.Letter,str(self.scores[1]),self.green_color,"",0)
        self.score_board.append(self.board.ships[-1])

        self.board.add_unit(data[0]-3,2,3,1,classes.board.Letter,str(self.scores[1]),self.blue_color,"",0)
        self.score_board.append(self.board.ships[-1])

        #indicator
        self.board.add_unit(0,0,1,1,classes.board.ImgShip,"",self.red_color,ttv,0)
        self.ind = self.board.ships[-1]

        self.legend_count = len(self.board.ships)
        for k in range(self.legend_count):
            self.board.ships[k].immobilize()
            self.board.ships[k].readable=False
            self.board.ships[k].outline=False

        k=self.legend_count
        for j in range(3,data[1]):
            for i in range(data[0]):
                self.board.add_unit(i,j,1,1,classes.board.ImgShip,"",color,ttyx,0)
                self.board.ships[k].immobilize();
                self.board.ships[k].readable=False
                self.board.ships[k].outline=False
                k+=1

        for each in self.board.ships:
            each.font_color = font_color
Пример #29
0
    def create_game_objects(self, level=1):
        self.vis_buttons = [1, 1, 1, 1, 1, 1, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)
        # s = random.randrange(30, 80)
        # v = random.randrange(200, 255)
        h = 230  # random.randrange(0, 255)
        color1 = (255, 255, 255)
        # color2 = ex.hsv_to_rgb(h,150,v)
        color3 = ex.hsv_to_rgb(h, 150, 75)

        self.correct = False
        self.digits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]

        # data = [0-x_count, 1-y_count, 2-bottom_range1, 3-top_range1, 4-bottom_range2, 5-top_range2, 6-operator, 7-font_size]

        if self.mainloop.m.game_variant == 0:
            self.points = self.level.lvl
            self.level.lvl_count = 11
            if self.level.lvl == 1:  # addition - ch0
                data = [20, 14, 1, 5, 1, 5, "+", 2]
            elif self.level.lvl == 2:
                data = [20, 14, 3, 9, 1, 5, "+", 2]
            elif self.level.lvl == 3:
                data = [20, 14, 5, 15, 3, 9, "+", 2]
            elif self.level.lvl == 4:
                data = [20, 14, 5, 15, 5, 15, "+", 2]
            elif self.level.lvl == 5:
                data = [20, 14, 15, 55, 5, 35, "+", 2]
            elif self.level.lvl == 6:
                data = [20, 14, 35, 75, 15, 25, "+", 2]
            elif self.level.lvl == 7:
                data = [20, 14, 55, 99, 55, 99, "+", 2]
            elif self.level.lvl == 8:
                data = [20, 14, 100, 250, 100, 250, "+", 4]
            elif self.level.lvl == 9:
                data = [20, 14, 300, 500, 250, 499, "+", 4]
            elif self.level.lvl == 10:
                data = [20, 14, 400, 650, 150, 349, "+", 4]
            elif self.level.lvl == 11:
                data = [20, 14, 500, 850, 100, 149, "+", 4]
        elif self.mainloop.m.game_variant == 1:
            self.points = self.level.lvl
            self.level.lvl_count = 11
            if self.level.lvl == 1:  # subtraction  - ch1
                data = [20, 14, 3, 10, 1, 0, "-", 2]
            elif self.level.lvl == 2:
                data = [20, 14, 5, 10, 3, 0, "-", 2]
            elif self.level.lvl == 3:
                data = [20, 14, 10, 15, 3, 0, "-", 2]
            elif self.level.lvl == 4:
                data = [20, 14, 15, 20, 5, 0, "-", 2]
            elif self.level.lvl == 5:
                data = [20, 14, 20, 49, 9, 0, "-", 2]
            elif self.level.lvl == 6:
                data = [20, 14, 49, 99, 9, 0, "-", 2]
            elif self.level.lvl == 7:
                data = [20, 14, 100, 250, 30, 0, "-", 4]
            elif self.level.lvl == 8:
                data = [20, 14, 100, 250, 30, 0, "-", 4]
            elif self.level.lvl == 9:
                data = [20, 14, 100, 250, 30, 0, "-", 4]
            elif self.level.lvl == 10:
                data = [20, 14, 250, 499, 50, 0, "-", 4]
            elif self.level.lvl == 11:
                data = [20, 14, 499, 999, 99, 0, "-", 4]
        elif self.mainloop.m.game_variant == 2:
            self.points = self.level.lvl * 2
            self.level.lvl_count = 7
            if self.level.lvl > 7:
                self.level.lvl = 7
            if self.level.lvl == 1:  # multiplication  - ch2
                data = [20, 14, 1, 3, 1, 3, "*", 2]
            elif self.level.lvl == 2:
                data = [20, 14, 1, 9, 1, 2, "*", 2]
            elif self.level.lvl == 3:
                data = [20, 14, 2, 6, 2, 6, "*", 2]
            elif self.level.lvl == 4:
                data = [20, 14, 2, 7, 3, 7, "*", 2]
            elif self.level.lvl == 5:
                data = [20, 14, 2, 9, 2, 9, "*", 2]
            elif self.level.lvl == 6:
                data = [20, 14, 2, 15, 2, 15, "*", 4]
            elif self.level.lvl == 7:
                data = [20, 14, 2, 20, 2, 20, "*", 4]
        elif self.mainloop.m.game_variant == 3:
            self.points = self.level.lvl * 2
            self.level.lvl_count = 7
            if self.level.lvl > 7:
                self.level.lvl = 7
            if self.level.lvl == 1:  # division - ch3
                data = [20, 14, 1, 3, 1, 3, "/", 2]
            elif self.level.lvl == 2:
                data = [20, 14, 1, 9, 1, 2, "/", 2]
            elif self.level.lvl == 3:
                data = [20, 14, 2, 6, 2, 6, "/", 2]
            elif self.level.lvl == 4:
                data = [20, 14, 2, 7, 3, 7, "/", 2]
            elif self.level.lvl == 5:
                data = [20, 14, 2, 9, 2, 9, "/", 2]
            elif self.level.lvl == 6:
                data = [20, 14, 2, 15, 2, 15, "/", 4]
            elif self.level.lvl == 7:
                data = [20, 14, 2, 20, 2, 20, "/", 4]
        # stretch width to fit the screen size
        data[0] = self.get_x_count(data[1], even=True)
        if data[0] < 20:
            data[0] = 20
        self.data = data

        self.layout.update_layout(data[0], data[1])
        scale = self.layout.scale
        self.board.level_start(data[0], data[1], scale)

        self.num_list = []
        self.num_list2 = []
        # self.solution = []

        # for i in range(1):
        if data[6] == "+":
            first_num = random.randrange(data[2], data[3] + 1)
            second_num = random.randrange(data[4], data[5] + 1)
            self.solution = first_num + second_num

        elif data[6] == "-":
            first_num = random.randrange(data[2], data[3] + 1)
            second_num = random.randrange(data[4], first_num - 1)
            self.solution = first_num - second_num

        elif data[6] == "*":
            first_num = random.randrange(data[2], data[3] + 1)
            second_num = random.randrange(data[4], data[5] + 1)
            self.solution = first_num * second_num

        elif data[6] == "/":  # reversed multiplication - looking for the first factor
            first = random.randrange(data[2], data[3] + 1)
            second_num = random.randrange(data[4], data[5] + 1)
            first_num = first * second_num
            self.solution = first

        self.num_list.append(first_num)
        self.num_list2.append(second_num)

        # self.shuffled = self.solution[:]
        # random.shuffle(self.shuffled)

        # create objects
        if data[6] == "*":
            operator = chr(215)
        elif data[6] == "/":
            operator = chr(247)
        else:
            operator = data[6]

        x = (data[0] - 12) // 2
        y = 1
        i = 0

        scheme = "white"
        if self.mainloop.scheme is not None:
            if self.mainloop.scheme.dark:
                scheme = "black"
                img_bg_col = (0, 0, 0)
        img_src0 = os.path.join("schemes", scheme, "robot0.png")
        img_src1 = os.path.join("schemes", scheme, "robot1.png")

        self.board.add_unit(x, y, 5, 5, classes.board.Label, str(self.num_list[i]), color1, "", 21)
        self.board.add_unit(x + 5, y, 2, 5, classes.board.Label, operator, color1, "", 21)
        self.board.add_unit(x + 7, y, 5, 5, classes.board.Label, str(self.num_list2[i]), color1, "", 21)

        self.board.add_unit(x - 4, y, 4, 5, classes.board.ImgShip, "", color1, img_src0)
        self.board.add_unit(x + 7 + 5, y, 4, 5, classes.board.ImgShip, "", color1, img_src1)

        # adding the edit field for the asnwer
        self.board.add_unit(x + 3, y + 6, 6, 2, classes.board.Letter, "", color1, "", 21)
        self.home_square = self.board.ships[-1]
        self.home_square.immobilize()
        self.home_square.set_outline(color3, 5)
        """
        #adding possible answers
        if self.solution < 7:
            answers = [i for i in range(7)]
        else:
            shift = random.randrange(0,7)
            answers = [i for i in range(self.solution-shift,self.solution-shift+7)]
        for i in range(7):
            self.board.add_unit(x-1+i*2,y+5,2,2,classes.board.Letter,str(answers[i]),color1,"",0)
            self.board.ships[-1].immobilize()
        """
        # self.board.add_unit(x+2,y,1,1,classes.board.Label,"=",color1,"",data[7])
        # self.board.add_door(x+3,y,1,1,classes.board.Door,"",color1,"")
        # self.board.units[-1].door_outline = True
        # self.board.add_unit(x+5,y,1,1,classes.board.Letter,str(self.shuffled[i]),color2,"",data[7])
        # self.board.ships[-1].audible = False
        # self.board.ships[-1].readable = False
        # self.outline_all(1,1)

        """
        #calculating positions for lights around the task
        fx1 = [x+5 - i for i in range(0,6)] + [x-1 for i in range(5)] + [x + i for i in range(0,6)]
        fx2 = [x+i for i in range(6,12)] + [x+12 for i in range(5)] + [x+12 - i for i in range(1,7)]
        fy0 = [y-1 for i in range(7)] + [y + i for i in range(0,3)] + [y+3 for i in range(7)] 
        #fh0 = [85 - i for i in range(0,85,5)]
        fh0 = [68 - i for i in range(0,68,4)]
        #adding the lights
        for i in range(17):
            bg_color = ex.hsv_to_rgb(fh0[i],255,255)
            self.board.add_unit(fx1[i],fy0[i],1,1,classes.board.Label,"",bg_color,"",2)
            self.board.units[-1].decolorable = False
            self.board.units[-1].bg_color = bg_color
            
        for i in range(17):
            bg_color = ex.hsv_to_rgb(fh0[i],255,255)
            self.board.add_unit(fx2[i],fy0[i],1,1,classes.board.Label,"",bg_color,"",2)
            self.board.units[-1].decolorable = False
            self.board.units[-1].bg_color = bg_color
        """
        # y += 1

        # for i in range(2,15,3):
        #    self.board.all_sprites_list.move_to_front(self.board.units[i])
        for each in self.board.units:
            each.font_color = color3
        for each in self.board.ships:
            each.font_color = color3
Пример #30
0
    def create_game_objects(self, level = 1):
        self.active_tool = 0
        self.active_letter = "A"
        self.active_word = "Apple"
        self.word_pos_y = 0
        self.var_brush = 1
        s = random.randrange(30, 80)
        v = random.randrange(200, 255)
        h = random.randrange(0, 255)
        letter_color = ex.hsv_to_rgb(h,s,v)
        if self.mainloop.scheme is not None:
            self.bg_color = self.mainloop.scheme.u_color
            color = self.mainloop.scheme.u_color
        else:
            self.bg_color = [255,255,255]
            color = [255,255,255]

        data = [35,26,0,8]

        font_size = 12
        font_size2 = 14
        self.brush_size = data[3]

        #stretch width to fit the screen size
        max_x_count = self.get_x_count(data[1],even=None)
        if max_x_count > 35:
            data[0] = max_x_count
        self.data = data

        self.vis_buttons = [0,0,0,0,1,0,1,0,0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0],data[1])
        scale = self.layout.scale
        self.board.level_start(data[0],data[1],scale)

        #canvas
        self.board.add_unit(10,0,data[0]-16,data[1],classes.board.Letter,"",color,"",font_size)
        self.canvas_block = self.board.ships[0]
        self.canvas_block.set_outline([0,54,229],1)

        self.canvas_block.font3 = self.board.font_sizes[font_size2]
        images = ["paint_pencil.png","paint_brush.png","paint_wide_brush.png","paint_rect.png","paint_circle.png","paint_eraser.png","paint_bucket.png"]
        x=0
        y=0
        i_chr = 65
        for i in range(0,65):
            if i <52:
                caption = chr(i_chr)
            else:
                caption = str(i-52)
            self.board.add_unit(x,y,2,2,classes.board.Letter,caption,letter_color,"",25)
            y += 2
            i_chr += 1
            if y > 24:
                y = 0
                x += 2
            if i == 25:
                i_chr = 97
            if i == 51:
                i_chr = 48
        self.board.add_door(0,0,2,2,classes.board.Door,"",color,"")
        self.board.add_door(data[0]-1,17,1,1,classes.board.Door,"",color,"")
        tool_len = len(self.board.ships)
        tool_max = tool_len - 3
        #self.word_list = ['Apple', 'Bear', 'Car', 'Dog', 'Egg', 'Flower', 'Goat','House', 'Ice', 'Jar', 'Kite', 'Leaf', 'Mug', 'Nut', 'Owl', 'Pig', 'Queen', 'Rabbit', 'Snake', 'Turtle', 'Unit', 'Violin', 'Wagon', 'X-ray', 'Yarn', 'Zebra','apple', 'bear', 'car', 'dog', 'egg', 'flower', 'goat', 'house', 'ice', 'jar', 'kite', 'leaf', 'mug', 'nut', 'owl', 'pig', 'queen', 'rabbit', 'snake', 'turtle', 'unit', 'violin', 'wagon', 'x-ray', 'yarn', 'zebra','zero','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine','ten', 'eleven', 'twelve']

        #color pallette
        h = 0
        s = 250
        v = 70
        #number of available color spaces minus 2 for black and white
        number_of_col_per_hue = 6#number_of_colors // number_of_hues
        v_num = (255-v)//(number_of_col_per_hue)
        #greyscale
        grey_num = 6 #number_of_colors+2 - number_of_hues * number_of_col_per_hue
        if grey_num > 1:
            grey_v_num = (255 // (grey_num-1))
        else:
            grey_v_num = 0
        grey_count = 0
        for j in range(0,data[1]):
            for i in range(data[0]-6, data[0]):
                color2 = ex.hsv_to_rgb(h,s,v)
                self.board.add_unit(i,j,1,1,classes.board.Ship,"",color2,"",2)
                if h < 249:
                    if i < data[0]-1:
                        v += v_num
                    else:
                        v = 70
                        s = 250
                        h += 10
                if h > 248:
                    if grey_count == 0:
                        s = 0
                        v = 0
                        grey_count += 1
                    else:
                        v += grey_v_num

        self.active_color = self.board.ships[173].initcolor
        self.size_display = self.board.units[0]
        self.tool_door = self.board.units[-2]
        self.color_door = self.board.units[-1]
        self.btn_down = False

        #points
        self.p_first = [0,0]
        self.p_last = [0,0]
        self.p_prev = [0,0]
        self.p_current = [0,0]

        self.outline_all(1,1)

        doors = [self.tool_door,self.color_door]
        for each in doors:
            each.door_outline = True
            each.perm_outline_color = [255,0,0]
            self.board.all_sprites_list.move_to_front(each)

        for each in self.board.ships:
            each.outline = False
            each.immobilize()

        self.canvas = pygame.Surface([self.canvas_block.grid_w*self.board.scale, self.canvas_block.grid_h*self.board.scale-1])
        self.canvas.fill(self.canvas_block.initcolor)
        self.paint_bg_letter()
        self.canvas_org = self.canvas.copy()
Пример #31
0
    def create_game_objects(self, level = 1):
        self.board.decolorable = False
        self.vis_buttons = [0,1,1,1,1,1,1,0,0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.ai_enabled = False
        self.board.draw_grid = False

        h = random.randrange(0, 255, 5)
        color0 = ex.hsv_to_rgb(h,30,240) #highlight 1
        self.color2 = ex.hsv_to_rgb(h,255,170) #contours & borders
        self.font_color = self.color2
        black = (2,2,2)
        white = (255,255,255)

        bg_col = (255,255,255)
        if self.mainloop.scheme is not None:
            if self.level.lvl > 1:
                self.font_color = self.mainloop.scheme.u_font_color
            if self.mainloop.scheme.dark:
                bg_col = (0,0,0)
                color0 = (0,0,0)
                black = (30,30,30)
            else:
                color0 = (255,255,255)
                white = (240,240,240)


        choice = [x for x in range(0,20)]
        self.color_choice = [self.d["white"],self.d["black"],self.d["grey"],self.d["red"],self.d["orange"],self.d["yellow"],self.d["olive"],self.d["green"],self.d["sea green"],self.d["teal"],self.d["blue"],self.d["navy"],self.d["purple"],self.d["magenta"],self.d["indigo"],self.d["pink"],self.d["maroon"],self.d["brown"],self.d["aqua"],self.d["lime"]]
        #self.color_choice= ["white",    "black",      "grey",       "red",     "orange",  "yellow",   "olive",    "green",  "sea green","teal",     "blue",   "navy",   "purple",   "violet",     "magenta",  "indigo",  "pink"       "maroon",  "brown",     "aqua",      "lime" ]
        self.hue_choice = [[255,255,255],[2,2,2],      [140,140,140],[255,0,0],[255,138,0],[255,255,0],[181,219,3],[0,160,0],[41,131,82],[0,130,133],[0,0,255],[0,0,132],[132,0,132],[255,0,255],[74,0,132],[255,20,138],[132,0,0], [140,69,16], [0,255,255], [0,255,0]]
        self.hue_choice2 =[[150,150,150],[100,100,100],[100,100,100],[200,0,0],[200,80,0], [200,200,0],[121,159,3],[0,100,0],[31,100,52],[0,90,90],  [0,0,200],[0,0,82], [92,0,92],  [200,0,200],[44,0,82], [200,10,88], [100,0,0], [100,39,6],  [0,200,200], [0,200,0]]
        self.font_colorx  =[[0,0,0],      [225,225,225],[0,0,0],      [100,0,0],[100,40,0], [100,100,0],[60,80,3],  [0,50,0],[11,50,22], [0,40,40],  [0,0,100],[0,0,255],[255,0,255],[100,0,100],[140,0,255],[100,5,48],  [200,50,50],  [200,100,26],  [0,155,155], [0,155,0]]
        self.init_font_color = [white,black,      [140,140,140],[255,0,0],[255,138,0],[255,255,0],[181,219,3],[0,160,0],[41,131,82],[0,130,133],[0,0,255],[0,0,132],[132,0,132],[255,0,255],[74,0,132],[255,20,138],[132,0,0], [140,69,16], [0,255,255], [0,255,0]]

        font_size = 6
        self.disp_counter = 0
        self.disp_len = 1

        if self.level.lvl == 1:
            data = [10,5,3,2,3]
        elif self.level.lvl == 2:
            data = [10,6,3,2,4]
        elif self.level.lvl == 3:
            data = [10,7,3,2,5]

        self.points = data[4] * 2

        #rescale the number of squares horizontally to better match the screen width
        m = data[0] % 2
        if m == 0:
            x = self.get_x_count(data[1],even=True)
        else:
            x = self.get_x_count(data[1],even=False)

        if x > data[0]:
            data[0] = x

        self.data = data

        self.found = 0
        self.clicks = 0

        self.squares = self.data[3]*self.data[4]

        self.square_count = self.squares * 2 #self.data[3]*self.data[4]
        self.history = [None,None]

        self.layout.update_layout(data[0],data[1])
        self.board.level_start(data[0],data[1],self.layout.scale)

        self.completed_mode = False

        shuffled = choice[:]
        random.shuffle(shuffled)
        self.chosen = shuffled[0:self.square_count//2]
        self.chosen = self.chosen * 2

        h1=(data[1]-data[4])//2 #height of the top margin
        h2=data[1]-h1-data[4]#-1 #height of the bottom margin minus 1 (game label)
        w2=(data[0]-data[3]*4)//2 #side margin width

        small_slots = []
        for j in range(h1,data[1]-h2):
            for i in range(w2,w2+data[3]):
                small_slots.append([i,j])
        random.shuffle(small_slots)

        wide_slots = []
        for j in range(h1,data[1]-h2):
            for i in range(w2+data[3],data[0]-w2,3):
                wide_slots.append([i,j])
        random.shuffle(wide_slots)

        switch = self.square_count // 2
        for i in range(self.square_count):
            fc = self.font_color
            if i < switch:
                caption = ""
                position_list = small_slots
                pos = i
                xw = 1
            else:
                caption = self.color_choice[self.chosen[i-switch]]
                position_list = wide_slots
                pos = i-switch
                xw = 3
                if self.level.lvl == 1:
                    fc = self.init_font_color[self.chosen[i-switch]]
            self.board.add_unit(position_list[pos][0],position_list[pos][1],xw,1,classes.board.Letter,caption,color0,"",font_size)
            self.board.ships[-1].font_color=fc

            self.board.ships[i].immobilize()
            self.board.ships[i].readable = False
            self.board.ships[i].perm_outline = True
            self.board.ships[i].uncovered = False
        self.outline_all(self.color2,1)

        self.board.add_door(0,data[1]-1,data[0],1,classes.board.Door,"0/0",bg_col,"",font_size=3)
        self.counter = self.board.units[-1]
        self.counter.font_color = (80,80,80)

        lines = [[135, 128],[133, 132],[135, 137],[157, 157],[158, 161],[155, 165],[150, 166],[146, 163],[133, 140],[129, 138],[125, 139],
            [122, 142],[122, 144],[128, 157],[128, 159],[126, 161],[123, 161],[121, 160],[114, 147],[112, 145],[107, 145],[104, 148],
            [104, 154],[110, 179],[111, 186],[110, 192],[105, 194],[100, 193],[98, 188],[98, 180],[101, 154],[100, 148],[96, 146],
            [93, 147],[92, 149],[88, 163],[86, 165],[83, 165],[80, 164],[80, 161],[80, 158],[83, 147],[82, 143],[73, 139],
            [65, 143],[55, 167],[52, 174],[48, 179],[42, 178],[37, 174],[38, 169],[43, 163],[57, 151],[63, 144],[67, 137],
            [66, 129],[60, 126],[51, 138],[47, 141],[44, 142],[40, 140],[38, 136],[40, 134],[44, 131],[57, 124],[56, 117],
            [51, 114],[43, 120],[40, 122],[38, 124],[36, 124],[34, 122],[34, 119],[36, 117],[50, 111],[52, 108],[53, 102],
            [51, 98],[46, 96],[38, 97],[11, 103],[5, 103],[3, 99],[4, 94],[10, 92],[36, 94],[44, 94],[50, 91],
            [53, 87],[52, 83],[46, 81],[21, 79],[14, 78],[9, 76],[8, 73],[10, 71],[15, 71],[22, 72],[45, 77],
            [51, 77],[53, 74],[52, 69],[40, 60],[39, 57],[39, 55],[41, 53],[44, 53],[47, 54],[55, 59],[58, 59],
            [61, 58],[62, 55],[61, 52],[54, 43],[54, 41],[55, 38],[58, 37],[61, 39],[71, 51],[74, 52],[80, 50],
            [81, 46],[80, 40],[77, 32],[66, 18],[62, 12],[61, 6],[65, 3],[70, 2],[74, 6],[76, 13],[79, 30],
            [81, 37],[86, 42],[91, 43],[95, 41],[95, 39],[93, 28],[93, 25],[93, 23],[96, 22],[99, 22],[100, 24],
            [100, 28],[99, 39],[101, 41],[103, 42],[106, 42],[108, 40],[111, 29],[112, 26],[114, 25],[117, 24],[119, 26],
            [120, 29],[119, 33],[116, 45],[117, 48],[119, 50],[122, 50],[135, 33],[137, 31],[140, 31],[142, 34],[142, 37],
            [133, 53],[133, 56],[134, 59],[137, 59],[141, 56],[155, 40],[160, 36],[164, 35],[169, 38],[170, 42],[168, 46],
            [163, 50],[146, 59],[144, 62],[145, 66],[149, 67],[160, 64],[162, 63],[164, 64],[165, 66],[165, 69],[164, 71],
            [150, 77],[148, 79],[148, 84],[150, 88],[155, 89],[173, 81],[179, 79],[183, 79],[185, 83],[186, 90],[184, 93],
            [180, 95],[175, 94],[158, 95],[154, 99],[153, 103],[156, 106],[163, 108],[185, 113],[190, 115],[191, 118],[189, 122],
            [184, 121],[163, 111],[156, 109],[151, 110],[147, 115],[145, 120],[146, 124],[151, 128],[163, 135],[168, 139],[171, 142],
            [171, 146],[167, 146],[162, 144],[158, 140],[149, 132],[144, 128],[140, 127]]
        size = self.board.ships[0].grid_w*self.board.scale
        margin = size//20
        #new point = size * orig_point / 200
        self.scaled_lines = [[int((size-2*margin) * each[0] / 200.0)+margin, int((size-2*margin) * each[1] / 200.0)+margin] for each in lines]
        for i in range(self.squares):
            color1 = self.hue_choice[self.chosen[i]] #ex.hsv_to_rgb(h,s,v)
            color2 = self.hue_choice2[self.chosen[i]] #ex.hsv_to_rgb(h,255,255)
            canvas = pygame.Surface([size, size-1])
            canvas.fill(self.board.ships[i].initcolor)
            self.draw_splash(canvas,size,color1,color2)#data[7](data, canvas, i)
            self.board.ships[i].painting = canvas.copy()
            self.board.ships[i].image = canvas.copy()
Пример #32
0
    def create_game_objects(self, level=1):
        self.board.draw_grid = False
        self.allow_unit_animations = False
        s = random.randrange(30, 50)
        v = random.randrange(230, 255)
        h = random.randrange(0, 225)
        white = (255, 255, 255)
        card_color = ex.hsv_to_rgb(h + 10, s - 25, v)
        font_color = ex.hsv_to_rgb(h, 255, 140)
        scheme = "white"
        if self.mainloop.scheme is not None:
            if self.mainloop.scheme.dark:
                scheme = "black"

        data = [15, 10]
        # stretch width to fit the screen size
        data[0] = self.get_x_count(data[1], even=False)
        if data[0] < 15:
            data[0] = 15
        self.data = data
        self.x_offset = (data[0] - 15) // 2

        self.vis_buttons = [0, 0, 0, 0, 1, 0, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0], data[1])
        scale = self.layout.scale
        self.board.level_start(data[0], data[1], scale)

        t_area = "½ah"

        self.shape_names = self.lang.shape_names
        if self.lang.lang in ["ru", "he"]:
            self.shape_namesp = self.lang.dp["shape_names"]
        else:
            self.shape_namesp = self.shape_names
        # self.shape_names = ["Equilateral Triangle", "Isosceles Triangle", "Acute Triangle", "Right Triangle", "Obtuse Triangle", "Square", "Rectangle", "Trapezium", "Isosceles Trapezium", "Rhombus", "Parallelogram", "Pentagon", "Hexagon", "Circle", "Ellipse"]
        self.shape_areas = ["½ah", "½ah", "½ah", "½ab", "½ah", "a²", "ab", "½(a+b)h", "½(a+b)h", "ah", "ah", "------",
                            "------", "πr²", "πab"]
        self.shape_circ = ["3a", "a + 2b", "a + b + c", "a + b + c", "a + b + c", "4a", "2a + 2b", "a + b + c + d",
                           "a + b + 2c", "4a", "2a + 2b", "5a", "6a", "2πr", "------"]

        x = self.x_offset
        # x2 = (data[0] - (26 - data[0]))//2
        y = 0

        for i in range(15):
            self.board.add_unit(x, y, 1, 1, classes.board.Letter, self.shape_names[i], white, "", 2)
            self.board.ships[-1].speaker_val = self.shape_namesp[i]
            self.board.ships[-1].speaker_val_update = False
            self.board.ships[-1].font_color = (255, 255, 255, 0)
            x += 1

        x = (data[0] - 4) // 2
        y = 1

        self.shape_count = len(self.board.ships)

        # Card
        self.board.add_unit(x - 2, y + 1, 9, 2, classes.board.Letter, self.shape_names[0], card_color, "", 2)
        self.board.ships[-1].speaker_val = self.shape_namesp[0]
        self.board.ships[-1].speaker_val_update = False

        self.board.add_unit(x + 2, y + 3, 5, 1, classes.board.Letter, self.d["area:"], card_color, "", 3)
        self.board.ships[-1].speaker_val = self.dp["area:"]
        self.board.ships[-1].speaker_val_update = False
        self.board.add_unit(x + 2, y + 4, 5, 1, classes.board.Label, t_area, card_color, "", 3)
        self.board.add_unit(x + 2, y + 5, 5, 1, classes.board.Letter, self.d["perimeter:"], card_color, "", 3)
        self.board.ships[-1].speaker_val = self.dp["perimeter:"]
        self.board.ships[-1].speaker_val_update = False
        self.perimeter = self.board.ships[-1]
        self.board.add_unit(x + 2, y + 6, 5, 1, classes.board.Label, "3a", card_color, "", 3)

        # frame size 288 x 216
        self.board.add_unit(x - 2, y + 3, 4, 4, classes.board.MultiImgSprite, self.shape_names[0], card_color,
                            os.path.join("schemes", scheme, "flashcard_shapes.jpg"), row_data=[15, 1])
        self.board.ships[-1].speaker_val = self.shape_namesp[0]
        self.board.ships[-1].speaker_val_update = False

        self.board.add_door(x - 2, y + 1, 9, 6, classes.board.Door, "", card_color, "")

        self.board.add_door(x - 5, 0, 15, 1, classes.board.Door, "", card_color,
                            os.path.join("schemes", scheme, "flashcard_shapes_72.jpg"))

        self.board.units[2].door_outline = True
        self.board.units[2].perm_outline_color = font_color
        self.board.all_sprites_list.move_to_front(self.board.units[2])
        self.board.all_sprites_list.move_to_front(self.board.units[3])

        self.slide = self.board.ships[self.shape_count + 3]
        self.slide.build_frame_flow(self.shape_count + 3)
        self.slide.correction = True
        self.slide.perm_outline = True
        self.slide.perm_outline_color = font_color

        for each in self.board.ships:
            each.immobilize()
            each.font_color = font_color

        for each in self.board.units:
            each.font_color = font_color
Пример #33
0
    def create_game_objects(self, level = 1):
        self.board.decolorable = False
        self.vis_buttons = [0,1,1,1,1,1,1,1,0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.ai_enabled = True
        self.board.draw_grid = False
        h = random.randrange(0, 255, 5)
        color0 = ex.hsv_to_rgb(h,30,230) #highlight 1
        self.color = color0
        self.highlight_color = ex.hsv_to_rgb(h,230,150)
        font_color = ex.hsv_to_rgb(h,70,230)
        white = (255,255,255)

        if self.mainloop.scheme is not None:
            if self.mainloop.scheme.dark:
                white = (0,0,0)
        self.level.game_step = 1
        self.start_sequence = True
        self.completed_mode = False
        self.game_over_mode = False
        self.disp_counter = 0
        self.disp_len = 3
        self.found = set()
        #setting level variable
        #data = [x_count, y_count, number_count, top_limit, ordered]
        if self.level.lvl == 1:
            data = [13,9,5,3,3]
        elif self.level.lvl == 2:
            data = [13,9,8,3,4]
        elif self.level.lvl == 3:
            data = [12,9,8,4,4]
        elif self.level.lvl == 4:
            data = [12,9,7,4,5]
        elif self.level.lvl == 5:
            data = [13,9,7,5,5]
        elif self.level.lvl == 6:
            data = [13,9,11,5,6]
        elif self.level.lvl == 7:
            data = [12,9,11,6,6]
        elif self.level.lvl == 8:
            data = [12,9,15,6,7]
        elif self.level.lvl == 9:
            data = [13,9,15,7,7]
        elif self.level.lvl == 10:
            data = [13,9,9,7,8]
        elif self.level.lvl == 11:
            data = [12,9,9,8,8]
        elif self.level.lvl == 12:
            data = [12,9,14,8,9]
        elif self.level.lvl == 13:
            data = [13,9,14,9,9]
        elif self.level.lvl == 14:
            data = [12,9,14,10,9]
        elif self.level.lvl == 15:
            data = [13,9,14,11,9]
        elif self.level.lvl == 16:
            data = [12,9,14,12,9]
        elif self.level.lvl == 17:
            data = [13,9,14,13,9]
        self.chapters = [1,3,5,7,9,11,13,15,17]
        #rescale the number of squares horizontally to better match the screen width
        m = data[0] % 2
        if m == 0:
            data[0] = self.get_x_count(data[1],even=True)
        else:
            data[0] = self.get_x_count(data[1],even=False)

        self.data = data

        self.square_count = self.data[3]*self.data[4]

        if self.square_count % 2 == 0: a = 0
        else: a = 1

        self.max_games = self.square_count // 2 + a

        self.level.games_per_lvl = self.max_games
        self.layout.update_layout(data[0],data[1])
        self.board.level_start(data[0],data[1],self.layout.scale)
        self.current_count = 1
        self.choice_list = [x for x in range(1,data[2]+1)]
        self.shuffled = self.choice_list[:]
        random.shuffle(self.shuffled)

        h1=(data[1]-data[4])//2 #height of the top margin
        h2=data[1]-h1-data[4]#-1 #height of the bottom margin minus 1 (game label)
        w2=(data[0]-data[3])//2 #side margin width
        self.board.add_door(w2,h1,data[3],data[4],classes.board.Door,"",white,"")

        x = w2
        y = h1
        for i in range(self.square_count):
            caption = str(i+1)
            self.board.add_unit(x,y,1,1,classes.board.Letter,caption,color0,"",3)
            self.board.ships[i].highlight = False
            self.board.ships[i].readable = False
            self.board.ships[i].font_color = font_color
            if x >= w2+data[3]-1:
                x = w2
                y += 1
            else:
                x += 1
        self.outline_all(0,1)

        #horizontal
        if data[4] < 8:
            self.board.add_unit(0,0,data[0],h1,classes.board.Obstacle,"",white,"",7)#top

        if data[4] < 9:
            self.board.add_unit(0,h1+data[4],data[0],h2,classes.board.Obstacle,"",white,"",7)#bottom 1
        #side obstacles
        if data[3]<12:
            self.board.add_unit(0,h1,w2,data[4],classes.board.Obstacle,"",white,"",7)#left
            self.board.add_unit(w2+data[3],h1,w2,data[4],classes.board.Obstacle,"",white,"",7)#right

        self.board.all_sprites_list.move_to_front(self.board.units[0])

        self.draw_nums()
Пример #34
0
    def create_game_objects(self, level=1):
        self.board.decolorable = False
        self.vis_buttons = [1, 1, 1, 1, 1, 1, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)
        if self.mainloop.scheme is None:
            s = random.randrange(100, 150, 5)
            v = random.randrange(230, 255, 5)
            h = random.randrange(0, 255, 5)
            white = (255, 255, 255)
            self.bg_col = white
            color1 = ex.hsv_to_rgb(h, s, v)  # highlight 2
            color3 = ex.hsv_to_rgb(h, s, v)
            color1a = color1
            self.color2 = ex.hsv_to_rgb(h, 255, 170)  # contours & borders
            self.font_color = ex.hsv_to_rgb(h, 255, 100)
        else:
            color1a = self.mainloop.scheme.u_font_color
            self.font_color = self.mainloop.scheme.u_font_color  # ex.hsv_to_rgb(h,255,100)
            if self.mainloop.scheme.dark:
                self.bg_col = (0, 0, 1)
                color1 = (30, 30, 35)
                self.color2 = (0, 0, 200)
                color3 = (0, 0, 1)
            else:
                self.bg_col = (254, 254, 255)
                color1 = (254, 254, 255)
                self.color2 = (0, 0, 200)
                color3 = (254, 254, 255)

        if self.level.lvl == 1:
            data = [9, 5, 3, 5, 2, 5]
        elif self.level.lvl == 2:
            data = [9, 5, 3, 7, 2, 5]
        elif self.level.lvl == 3:
            data = [9, 5, 3, 10, 2, 5]
        self.points = 1
        self.data = data
        self.board.set_animation_constraints(3, data[0] - 3, 0, data[1] - 1)
        self.board.level_start(data[0], data[1], self.layout.scale)

        self.num_list = []
        self.num_list2 = []

        sign = "/"
        numbers = []
        for i in range(data[4]):
            num1 = random.randrange(1, data[3] - 1)
            num2 = random.randrange(num1 + 1, data[3])
            numbers.append([num1, num2])
            expr = str(float(num1)) + sign + str(float(num2))
            disp = ["", str(num1), str(num2), ""]
            self.num_list.append(expr)
            self.num_list2.append(disp)

        # create table to store the solution
        self.solution_grid = [1, 1, 1, 1, 1, 1, 1, 1, 1]
        self.expression = [" " for x in range(data[0])]
        # find position of first door square
        xd = (data[0] - data[2]) // 2

        # add objects to the board
        self.board.add_unit(0, 1, 3, 3, classes.board.Label, "", self.bg_col, "", data[5])
        self.board.add_unit(6, 1, 3, 3, classes.board.Label, "", self.bg_col, "", data[5])

        size = self.board.scale
        center = [size // 2, size // 2]

        for i in range(0, data[4]):
            x2 = xd + i * 2
            caption = self.num_list2[i]
            self.board.add_unit(x2, 2, 1, 1, classes.board.Label, caption, color3, "", data[5])
            self.board.units[-1].font_color = self.font_color
            self.board.units[i + 2].set_outline(self.font_color, 1)
            self.draw_fractions(self.board.units[i + 2].painting, size, center, color1)
            self.board.units[i + 2].image = self.board.units[i + 2].painting.copy()
            self.expression[x2] = str(self.num_list[i])
            if i < data[4] - 1:
                self.solution_grid[x2 + 1] = 1

        signs = [" < ", " = ", " > "] * (data[4] - 1)
        if self.level.lvl > 12: signs.append(" < ")  # just for the symetry

        for i in range(len(signs)):
            if len(signs) < data[0]:
                if i == 0 and len(signs) % 2 == 0:
                    x = data[0] // 2
                    y = 3
                else:
                    x = (data[0] - len(signs)) // 2
                    y = 0
            else:
                if i < data[0]:
                    x = 0
                    y = 0
                else:
                    x = ((data[0] - (len(signs) - data[0])) // 2) - data[0]
                    y = 3

            self.board.add_unit(x + i, y, 1, 1, classes.board.Letter, signs[i], color3, "", data[5])
            self.board.ships[-1].font_color = self.font_color
            self.board.ships[i].readable = False
            self.board.ships[i].set_outline(self.font_color, 1)

        # self.outline_all(0,1)
        ind = len(self.board.units)
        for i in range(0, data[4] - 1):
            self.board.add_door(xd + i * 2 + 1, 2, 1, 1, classes.board.Door, "", self.bg_col, "")
            self.board.units[ind + i].door_outline = True
            self.board.all_sprites_list.move_to_front(self.board.units[ind + i])

        instruction = self.d["Drag lt"]
        self.board.add_unit(0, data[1] - 1, data[0], 1, classes.board.Letter, instruction, self.bg_col, "", 9)
        self.board.ships[-1].font_color = self.font_color
        self.board.ships[-1].immobilize()
        self.board.ships[-1].speaker_val = self.d["Drag lt2"]
        self.board.ships[-1].set_outline(self.font_color, 1)
        self.board.ships[-1].speaker_val_update = False

        size = self.board.units[0].grid_w * self.board.scale
        center = [size // 2, size // 2]
        for i in range(2):
            canvas = pygame.Surface([size, size - 1])
            canvas.fill(self.board.units[i].initcolor)
            self.draw_circles(numbers[i], canvas, size, center, color1a)  # data[7](data, canvas, i)
            self.board.units[i].painting = canvas.copy()
Пример #35
0
    def create_game_objects(self, level = 1):
        self.board.draw_grid = False
        s = random.randrange(30, 50)
        v = random.randrange(230, 255)
        h = random.randrange(0, 225)
        white = (255,255,255)
        card_color = ex.hsv_to_rgb(h+10,s-25,v)
        font_color = ex.hsv_to_rgb(h,255,140)
        scheme = "white"
        if self.mainloop.scheme is not None:
            if self.mainloop.scheme.dark:
                scheme = "black"

        data = [15,10]
        
        #stretch width to fit the screen size
        data[0] = self.get_x_count(data[1],even=False)
        if data[0]<15:
            data[0]=15
        self.data = data
        self.x_offset = (data[0]-9)//2
        
        self.vis_buttons = [0,0,0,0,1,0,1,0,0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0],data[1])
        scale = self.layout.scale
        self.board.level_start(data[0],data[1],scale)
        
        t_area = "½ah"
        self.shape_names = self.lang.solid_names
        
        if self.lang.lang in ["ru","he"]:
            self.shape_namesp = self.lang.dp["solid_names"]
        else:
            self.shape_namesp = self.shape_names
        #self.shape_names = ["Cube", "Square Prism","Triangular Prism", "Square Pyramid", "Triangular Pyramid",  "Sphere",    "Cylinder",    "Cone",      "Torus"]
        self.shape_areas = ["6a²",   "2a² + 4aH",   "ah + 3aH",         "a² + 2as",       "½ah + 3/2 × as",      "4πr²",      "2πr² + 2πrH", "πr² + πrs", "4π² × R × r"]
        self.shape_circ =  ["a³",    "a²H",         "½ah × H",          "⅓a² × H",        "ah/6 × H",            "4/3 × πr³", "πr²H",        "⅓πr²H",     "2π² × R × r²"]

        x = self.x_offset
        y = 0
        
        for i in range(9):
            self.board.add_unit(x,y,1,1,classes.board.Letter,self.shape_names[i],white,"",2)
            self.board.ships[-1].speaker_val = self.shape_namesp[i]
            self.board.ships[-1].speaker_val_update = False
            self.board.ships[-1].font_color=(255,255,255,0)
            x += 1

        x=(data[0]-4)//2
        y=1
        
        self.shape_count = len(self.board.ships) 
        
        #Card
        self.board.add_unit(x-2,y+1,9,2,classes.board.Letter,self.shape_names[0],card_color,"",2)

        self.board.ships[-1].speaker_val = self.shape_namesp[0]
        self.board.ships[-1].speaker_val_update = False
        
        self.board.add_unit(x+2,y+3,5,1,classes.board.Letter,self.d["surface area:"],card_color,"",3)
        self.board.add_unit(x+2,y+4,5,1,classes.board.Label,"6a"+chr(178),card_color,"",3)
        self.board.add_unit(x+2,y+5,5,1,classes.board.Letter,self.d["volume:"],card_color,"",3)
        self.board.add_unit(x+2,y+6,5,1,classes.board.Label,"a"+chr(179),card_color,"",3)

        #frame size 288 x 216        
        self.board.add_unit(x-2,y+3,4,4,classes.board.MultiImgSprite,self.shape_names[0],card_color,os.path.join("schemes",scheme,"flashcard_solids.jpg"),row_data=[9,1])
        self.board.ships[-1].speaker_val = self.shape_namesp[0]
        self.board.ships[-1].speaker_val_update = False
        
        self.board.add_door(x-2,y+1,9,6,classes.board.Door,"",card_color,"")
        
        self.board.add_door(x-2,0,9,1,classes.board.Door,"",card_color,os.path.join("schemes",scheme,"flashcard_solids_72.jpg"))
        self.board.units[2].door_outline = True
        self.board.units[2].perm_outline_color = font_color
        self.board.all_sprites_list.move_to_front(self.board.units[2])
        self.board.all_sprites_list.move_to_front(self.board.units[3])
        
        self.slide = self.board.ships[self.shape_count+3]
        self.slide.build_frame_flow(self.shape_count+3) 
        self.slide.correction = True
        self.slide.perm_outline = True
        self.slide.perm_outline_color = font_color
        
        for each in self.board.ships:
            each.immobilize()
            each.font_color = font_color
            
        for each in self.board.units:
            each.font_color = font_color
Пример #36
0
    def create_game_objects(self, level=1):
        self.vis_buttons = [0, 0, 0, 0, 1, 0, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.hand_id = 0
        self.hand_coords = [[], []]
        self.board.draw_grid = False

        if self.mainloop.scheme is not None:
            color1 = self.mainloop.scheme.color1  #bright side of short hand
            color3 = self.mainloop.scheme.color3  #inner font color
            color5 = self.mainloop.scheme.color5  #dark side of short hand
            color7 = self.mainloop.scheme.color7  #inner circle filling

            color2 = self.mainloop.scheme.color2  #bright side of long hand
            color4 = self.mainloop.scheme.color4  #ex.hsv_to_rgb(170,255,255)#outer font color
            color6 = self.mainloop.scheme.color6  #dark side of long hand
            color8 = self.mainloop.scheme.color8  #outer circle filling

            color = self.mainloop.scheme.u_color
            white = self.mainloop.scheme.u_color
            gray = (100, 100, 100)
        else:
            color1 = ex.hsv_to_rgb(225, 70, 230)
            color3 = ex.hsv_to_rgb(225, 255, 255)
            color5 = ex.hsv_to_rgb(225, 180, 240)
            color7 = ex.hsv_to_rgb(225, 10, 255)

            color2 = ex.hsv_to_rgb(170, 70, 230)
            color4 = ex.hsv_to_rgb(170, 255, 255)
            color6 = ex.hsv_to_rgb(170, 180, 240)
            color8 = ex.hsv_to_rgb(170, 10, 255)

            color = (255, 255, 255)
            white = (255, 255, 255)
            gray = (100, 100, 100)

        self.colors = [color1, color2]
        self.colors2 = [color3, color4]
        self.colors3 = [color5, color6]
        self.colors4 = [color7, color8]

        if self.mainloop.m.game_variant == 2:
            data = [
                19, 10, True, True, False, False, False, False, True, True,
                True, 15
            ]
        else:
            data = [
                19, 10, True, True, False, False, False, False, False, True,
                True, 15
            ]
        h_pool = range(1, 13)
        m_pool = range(0, 60)

        #visual display properties
        self.show_outer_ring = data[2]
        self.show_minutes = data[3]
        self.show_24h = data[4]
        self.show_only_quarters_h = data[5]
        self.show_only_quarters_m = data[6]
        self.show_only_fives_m = data[7]
        self.show_roman = data[8]
        self.show_highlight = data[9]
        self.show_hour_offset = data[10]

        #self.level.games_per_lvl = data[11]

        tt = [random.choice(h_pool), random.choice(m_pool)]
        self.time = tt
        #self.time = [6,0]
        self.tm = self.time[:]

        self.digits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
        self.roman = [
            "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI",
            "XII"
        ]

        x_count = self.get_x_count(data[1], even=False)
        if x_count > data[0]:
            data[0] = x_count

        self.font_size = 0
        self.data = data

        self.layout.update_layout(data[0], data[1])
        self.board.level_start(data[0], data[1], self.layout.scale)

        self.size = self.board.scale * 10
        ans_offset = 10 + (data[0] - 15) // 2
        self.board.add_unit(10, 0, data[0] - 10, 2, classes.board.Label,
                            self.lang.d["Set_clock_instr"], white, "", 2)
        self.board.units[-1].font_color = gray
        self.board.add_unit(ans_offset, 3, 2, 1, classes.board.Label,
                            "%02d" % self.time[0], white, "", 0)
        self.ans_h = self.board.units[-1]

        self.board.add_unit(ans_offset + 2, 3, 1, 1, classes.board.Label, ":",
                            white, "", 0)
        self.board.add_unit(ans_offset + 3, 3, 2, 1, classes.board.Label,
                            "%02d" % self.time[1], white, "", 0)
        self.ans_m = self.board.units[-1]

        self.ans_h.align = 2
        self.ans_m.align = 1

        self.ans_h.immobilize()
        self.ans_m.immobilize()

        self.ans_h.font_color = color3
        self.ans_m.font_color = color4

        self.center = [self.size // 2, self.size // 2]
        self.board.add_unit(0, 0, 10, 10, classes.board.Ship, "", white, "",
                            self.font_size)
        self.clock_canvas = self.board.ships[-1]
        self.board.active_ship = self.clock_canvas.unit_id
        self.clock_canvas.font = self.clock_canvas.board.font_sizes[2]
        self.clock_canvas.font2 = self.clock_canvas.board.font_sizes[7]
        self.clock_canvas.font3 = self.clock_canvas.board.font_sizes[26]
        self.clock_canvas.immobilize()

        self.board.add_unit(10, 4, data[0] - 10, 2, classes.board.Letter, "",
                            white, "", 2)
        self.text_time = self.board.ships[-1]
        self.text_time.immobilize()
        self.text_time.font_color = gray

        self.update_text_time()

        self.canvas = pygame.Surface([self.size, self.size - 1])
        if self.mainloop.scheme is not None:
            self.canvas.fill(self.mainloop.scheme.u_color)
        else:
            self.canvas.fill((255, 255, 255))
        self.hands_vars()
        self.draw_hands()

        self.clock_canvas.hidden_value = [2, 3]  #numbers[i]
        self.clock_canvas.font_color = color2
        self.clock_canvas.painting = self.canvas.copy()
Пример #37
0
    def create_game_objects(self, level=1):
        self.update_layout_on_start = True
        self.board.draw_grid = False
        self.show_info_btn = False
        if self.mainloop.m.badge_count == 0:
            self.mainloop.m.lang_change()

        #ver_color = (55, 0, 90)
        s = 70
        v = 230
        h = random.randrange(0, 255, 5)
        color0 = ex.hsv_to_rgb(h, 40, 230)
        color1 = color0
        font_color = ex.hsv_to_rgb(h, 255, 140)
        ver_color = (33, 121, 149)
        if self.mainloop.scheme is not None:
            if self.mainloop.scheme.dark:
                self.scheme_dir = "black"
                color = (0, 0, 0)
                ver_color = (255, 255, 0)
            else:
                self.scheme_dir = "white"
                color = (255, 255, 255)
        else:
            self.scheme_dir = "white"
            color = (255, 255, 255)

        # (234,218,225) #ex.hsv_to_rgb(225,15,235)
        self.color = color
        """lvl_data = [term_len_min, term_len_max, term_count_min, term_count_max, term_completed_count, semi_completed_count, shuffled]"""
        lvl_data = self.mainloop.xml_conn.get_level_data(
            self.mainloop.m.game_dbid, self.mainloop.config.user_age_group,
            self.level.lvl)
        self.chapters = self.mainloop.xml_conn.get_chapters(
            self.mainloop.m.game_dbid, self.mainloop.config.user_age_group)

        self.term_len = random.randint(lvl_data[0], lvl_data[1])
        self.term_count = random.randint(lvl_data[2], lvl_data[3])
        term_completed_count = lvl_data[4]
        if lvl_data[5] > 1:
            term_semi_completed_count = max(2, random.randint(2, lvl_data[5]))
        else:
            term_semi_completed_count = lvl_data[5]

        self.task_len = self.term_len * self.term_count
        self.term = self.generate_term(self.term_len)
        self.task = self.generate_task(self.term,
                                       self.term_len,
                                       self.term_count,
                                       term_completed_count,
                                       term_semi_completed_count,
                                       shuffled=lvl_data[6])

        alpha = False
        if self.mainloop.m.game_variant < 2:
            # make the backgrounds different for each letter or number

            unit_clrs = []
            font_clrs = []
            for i in range(self.term_len):
                if self.level.lvl < 3:
                    h = random.randrange(0, 100, 5)
                    gap = i * (155 // self.term_len)
                else:
                    gap = 0
                unit_clrs.append(ex.hsv_to_rgb(h + gap, 40, 230))
                font_clrs.append(ex.hsv_to_rgb(h + gap, 255, 140))
            if self.mainloop.m.game_variant == 0:
                if random.randint(0, 1) == 0:
                    self.choices = self.lang.alphabet_uc[:]
                else:
                    self.choices = self.lang.alphabet_lc[:]
            elif self.mainloop.m.game_variant == 1:
                self.choices = [str(x) for x in range(0, 9)]
        elif self.mainloop.m.game_variant == 2:
            self.choices = [x for x in range(2, 20)]

            alpha = True
            color0 = (0, 0, 0, 0)
        elif self.mainloop.m.game_variant == 3:
            self.initiate_images()
            self.choices = [x for x in range(len(self.imgs))]
        elif self.mainloop.m.game_variant == 5:
            self.initiate_shapes()
            self.choices = [x for x in range(len(self.imgs))]
            alpha = True
            color0 = (0, 0, 0, 0)
            random.shuffle(self.shape_colors)
            if self.level.lvl < 3:
                self.mixed_colours = True
            else:
                self.mixed_colours = False
        elif self.mainloop.m.game_variant == 4:
            self.func_number = random.randint(0, 3)
            #create fractions
            self.fractions = []
            full = False
            while not full:
                a = random.randint(1, 4)
                b = random.randint(a + 1, 6)
                l = [a, b]
                if l not in self.fractions:
                    self.fractions.append(l)
                if len(self.fractions) >= self.term_len:
                    full = True

            alpha = True
            color0 = (0, 0, 0, 0)
            clrs1 = []
            clrs2 = []
            for i in range(self.term_len):
                if self.level.lvl < 3:
                    h = random.randrange(0, 100, 5)
                    gap = i * (155 // self.term_len)
                else:
                    gap = 0
                clrs1.append(ex.hsv_to_rgb(h + gap, 150, 230))
                clrs2.append(ex.hsv_to_rgb(h + gap, 255, 140))
            self.choices = [x for x in range(2, 20)]

        random.shuffle(self.choices)
        self.term_values = self.choices[0:self.term_len]

        data = [self.task_len, 4]
        self.data = data

        self.vis_buttons = [0, 1, 1, 1, 1, 0, 1, 1, 1]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)
        self.board.set_animation_constraints(0, data[0], 0, data[1])
        self.layout.update_layout(data[0], data[1])
        scale = self.layout.scale
        self.board.level_start(data[0], data[1], scale)
        self.board.board_bg.initcolor = color
        self.board.board_bg.color = color
        self.board.board_bg.update_me = True

        self.left_offset = (self.data[0] - len(self.task)) // 2

        self.positions = [
            x for x in range(self.left_offset,
                             len(self.task) + self.left_offset)
        ]
        self.solution_grid = [0 for x in range(data[0])]

        random.shuffle(self.positions)
        p_ind = 0
        for i in range(len(self.task)):
            self.solution_grid[self.left_offset + i] = 1
            if self.task[i] == "?":
                #add placeholder and the items to add
                self.board.add_door(self.left_offset + i, 0, 1, 1,
                                    classes.board.Door, "", color, "")
                self.board.units[-1].door_outline = True
                if self.mainloop.m.game_variant < 2:
                    v = self.term_values[int(self.term[i % self.term_len])]
                else:
                    v = ""
                if self.mainloop.m.game_variant == 3:
                    img = "%s.jpg" % self.imgs[self.term_values[int(
                        self.term[i % self.term_len])]]
                    img_src = os.path.join('art4apps', self.category, img)
                    # self.board.add_unit(self.positions[p_ind], 2, 1, 1, classes.board.Letter, v, color0, "", 0, alpha=alpha)
                    self.board.add_unit(self.positions[p_ind], 2, 1, 1,
                                        classes.board.ImgShip, "", color0,
                                        img_src)

                elif self.mainloop.m.game_variant == 5:
                    img = "%s.png" % self.imgs[self.term_values[int(
                        self.term[i % self.term_len])]]
                    if self.mixed_colours:
                        img_src = os.path.join(
                            'shapes', self.shape_colors[int(
                                self.term[i % self.term_len])], img)
                    else:
                        img_src = os.path.join('shapes', self.shape_colors[0],
                                               img)
                    self.board.add_unit(self.positions[p_ind],
                                        2,
                                        1,
                                        1,
                                        classes.board.ImgShip,
                                        "",
                                        color0,
                                        img_src,
                                        alpha=alpha)
                elif self.mainloop.m.game_variant == 2:
                    self.board.add_unit(self.positions[p_ind],
                                        2,
                                        1,
                                        1,
                                        classes.board.Letter,
                                        v,
                                        color0,
                                        "",
                                        0,
                                        alpha=alpha)
                    splash = classes.drw.splash.Splash(
                        1, self.board.scale,
                        self.term_values[int(self.term[i % self.term_len])])
                    self.board.ships[-1].painting = splash.get_canvas().copy()
                elif self.mainloop.m.game_variant == 4:
                    self.board.add_unit(self.positions[p_ind],
                                        2,
                                        1,
                                        1,
                                        classes.board.Letter,
                                        v,
                                        color0,
                                        "",
                                        0,
                                        alpha=alpha)
                    fraction = classes.drw.fraction.Fraction(
                        1, self.board.scale,
                        clrs1[int(self.term[i % self.term_len])],
                        clrs2[int(self.term[i % self.term_len])],
                        self.fractions[int(self.term[i % self.term_len])],
                        self.func_number)
                    self.board.ships[-1].painting = fraction.get_canvas().copy(
                    )
                elif self.mainloop.m.game_variant < 2:
                    self.board.add_unit(self.positions[p_ind],
                                        2,
                                        1,
                                        1,
                                        classes.board.Letter,
                                        v,
                                        color0,
                                        "",
                                        0,
                                        alpha=alpha)
                    self.board.ships[-1].outline_highlight = True
                    self.board.ships[-1].set_outline(color=font_clrs[int(
                        self.term[i % self.term_len])],
                                                     width=1)
                    self.board.ships[-1].font_color = font_clrs[int(
                        self.term[i % self.term_len])]
                    self.board.ships[-1].set_color(unit_clrs[int(
                        self.term[i % self.term_len])])
                if self.mainloop.m.game_variant == 2 or self.mainloop.m.game_variant == 5:
                    self.board.ships[-1].outline = False

                self.board.ships[-1].pattern_value = self.term[i %
                                                               self.term_len]
                self.board.ships[-1].highlight = False
                self.board.ships[-1].readable = False
                self.board.ships[-1].checkable = True
                self.board.ships[-1].init_check_images()
                p_ind += 1
            else:
                #add pre-entered part of a pattern
                if self.mainloop.m.game_variant < 2:
                    v = self.term_values[int(self.task[i])]
                else:
                    v = ""
                if self.mainloop.m.game_variant == 3:
                    img = "%s.jpg" % self.imgs[self.term_values[int(
                        self.term[i % self.term_len])]]
                    img_src = os.path.join('art4apps', self.category, img)
                    # self.board.add_unit(self.positions[p_ind], 2, 1, 1, classes.board.Letter, v, color0, "", 0, alpha=alpha)
                    self.board.add_unit(self.left_offset + i, 0, 1, 1,
                                        classes.board.ImgShip, "", color0,
                                        img_src)
                elif self.mainloop.m.game_variant == 5:
                    img = "%s.png" % self.imgs[self.term_values[int(
                        self.term[i % self.term_len])]]
                    if self.mixed_colours:
                        img_src = os.path.join(
                            'shapes', self.shape_colors[int(
                                self.term[i % self.term_len])], img)
                    else:
                        img_src = os.path.join('shapes', self.shape_colors[0],
                                               img)
                    self.board.add_unit(self.left_offset + i,
                                        0,
                                        1,
                                        1,
                                        classes.board.ImgShip,
                                        "",
                                        color0,
                                        img_src,
                                        alpha=alpha)
                elif self.mainloop.m.game_variant == 2:
                    self.board.add_unit(self.left_offset + i,
                                        0,
                                        1,
                                        1,
                                        classes.board.Letter,
                                        v,
                                        color0,
                                        "",
                                        0,
                                        alpha=alpha)
                    splash = classes.drw.splash.Splash(
                        1, self.board.scale,
                        self.term_values[int(self.term[i % self.term_len])])
                    self.board.ships[-1].painting = splash.get_canvas().copy()
                elif self.mainloop.m.game_variant == 4:
                    self.board.add_unit(self.left_offset + i,
                                        0,
                                        1,
                                        1,
                                        classes.board.Letter,
                                        v,
                                        color0,
                                        "",
                                        0,
                                        alpha=alpha)
                    fraction = classes.drw.fraction.Fraction(
                        1, self.board.scale,
                        clrs1[int(self.term[i % self.term_len])],
                        clrs2[int(self.term[i % self.term_len])],
                        self.fractions[int(self.term[i % self.term_len])],
                        self.func_number)
                    self.board.ships[-1].painting = fraction.get_canvas().copy(
                    )
                elif self.mainloop.m.game_variant < 2:
                    self.board.add_unit(self.left_offset + i,
                                        0,
                                        1,
                                        1,
                                        classes.board.Letter,
                                        v,
                                        color0,
                                        "",
                                        0,
                                        alpha=alpha)
                    self.board.ships[-1].outline_highlight = True
                    self.board.ships[-1].set_outline(color=font_clrs[int(
                        self.term[i % self.term_len])],
                                                     width=1)
                    self.board.ships[-1].font_color = font_clrs[int(
                        self.term[i % self.term_len])]
                    self.board.ships[-1].set_color(unit_clrs[int(
                        self.term[i % self.term_len])])
                if self.mainloop.m.game_variant == 2 or self.mainloop.m.game_variant == 5:
                    self.board.ships[-1].outline = False

                self.board.ships[-1].pattern_value = self.term[i %
                                                               self.term_len]
                self.board.ships[-1].immobilize()
                self.board.ships[-1].highlight = False
                self.board.ships[-1].readable = False
                self.board.ships[-1].checkable = True
                self.board.ships[-1].init_check_images()

        #add noise
        for i in range(p_ind, len(self.positions)):
            if self.mainloop.m.game_variant < 2:
                v = self.term_values[int(self.term[i % self.term_len])]
            else:
                v = ""
            if self.mainloop.m.game_variant == 3:
                img = "%s.jpg" % self.imgs[self.term_values[int(
                    self.term[i % self.term_len])]]
                img_src = os.path.join('art4apps', self.category, img)
                # self.board.add_unit(self.positions[p_ind], 2, 1, 1, classes.board.Letter, v, color0, "", 0, alpha=alpha)
                self.board.add_unit(self.positions[i], 2, 1, 1,
                                    classes.board.ImgShip, "", color0, img_src)
            elif self.mainloop.m.game_variant == 5:
                img = "%s.png" % self.imgs[self.term_values[int(
                    self.term[i % self.term_len])]]
                if self.mixed_colours:
                    img_src = os.path.join(
                        'shapes',
                        self.shape_colors[int(self.term[i % self.term_len])],
                        img)
                else:
                    img_src = os.path.join('shapes', self.shape_colors[0], img)
                self.board.add_unit(self.positions[i],
                                    2,
                                    1,
                                    1,
                                    classes.board.ImgShip,
                                    "",
                                    color0,
                                    img_src,
                                    alpha=alpha)

            elif self.mainloop.m.game_variant == 2:
                self.board.add_unit(self.positions[i],
                                    2,
                                    1,
                                    1,
                                    classes.board.Letter,
                                    v,
                                    color0,
                                    "",
                                    0,
                                    alpha=alpha)
                splash = classes.drw.splash.Splash(
                    1, self.board.scale,
                    self.term_values[int(self.term[i % self.term_len])])
                self.board.ships[-1].painting = splash.get_canvas().copy()
            elif self.mainloop.m.game_variant == 4:
                self.board.add_unit(self.positions[i],
                                    2,
                                    1,
                                    1,
                                    classes.board.Letter,
                                    v,
                                    color0,
                                    "",
                                    0,
                                    alpha=alpha)
                fraction = classes.drw.fraction.Fraction(
                    1, self.board.scale,
                    clrs1[int(self.term[i % self.term_len])],
                    clrs2[int(self.term[i % self.term_len])],
                    self.fractions[int(self.term[i % self.term_len])],
                    self.func_number)
                self.board.ships[-1].painting = fraction.get_canvas().copy()
            elif self.mainloop.m.game_variant < 2:
                self.board.add_unit(self.positions[i],
                                    2,
                                    1,
                                    1,
                                    classes.board.Letter,
                                    v,
                                    color0,
                                    "",
                                    0,
                                    alpha=alpha)
                self.board.ships[-1].outline_highlight = True
                self.board.ships[-1].set_outline(color=font_clrs[int(
                    self.term[i % self.term_len])],
                                                 width=1)
                self.board.ships[-1].font_color = font_clrs[int(
                    self.term[i % self.term_len])]
                self.board.ships[-1].set_color(unit_clrs[int(
                    self.term[i % self.term_len])])

            if self.mainloop.m.game_variant == 2 or self.mainloop.m.game_variant == 5:
                #self.board.ships[-1].outline_highlight = False
                self.board.ships[-1].outline = False
                #self.board.ships[-1].perm_outline = False

            self.board.ships[-1].pattern_value = self.term[i % self.term_len]
            self.board.ships[-1].highlight = False
            self.board.ships[-1].readable = False
            self.board.ships[-1].checkable = True
            self.board.ships[-1].init_check_images()
        """
        self.board.add_unit(0, 4, data[0], 1, classes.board.Label, self.lang.d["Complete the pattern"], color1, "", 5)
        self.board.units[-1].font_color = font_color
        """

        for each in self.board.units:
            self.board.all_sprites_list.move_to_front(each)
Пример #38
0
    def create_game_objects(self, level=1):
        self.vis_buttons = [1, 1, 1, 1, 1, 1, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)
        # create non-movable objects
        self.board.draw_grid = False
        h = random.randrange(0, 255, 5)
        color0 = ex.hsv_to_rgb(h, 40, 230)  # highlight 1
        font_color = ex.hsv_to_rgb(h, 255, 140)
        white = (255, 255, 255)

        # data = [x_count, y_count, number of items on the list, top_quntity,font-size]
        if self.level.lvl == 1:  # images 42x42
            data = [20, 14, 3, 3, 2]
        elif self.level.lvl == 2:
            data = [20, 14, 3, 5, 2]
        elif self.level.lvl == 3:
            data = [20, 14, 3, 7, 2]
        elif self.level.lvl == 4:
            data = [20, 14, 4, 3, 2]
        elif self.level.lvl == 5:
            data = [20, 14, 4, 5, 2]
        elif self.level.lvl == 6:
            data = [20, 14, 4, 7, 2]
        elif self.level.lvl == 7:
            data = [20, 14, 5, 3, 2]
        elif self.level.lvl == 8:
            data = [20, 14, 5, 5, 2]
        elif self.level.lvl == 9:
            data = [20, 14, 6, 3, 2]
        elif self.level.lvl == 10:
            data = [20, 14, 6, 5, 2]
        self.points = data[2] - 2
        # rescale the number of squares horizontally to better match the screen width
        x_count = self.get_x_count(data[1], even=None)
        if x_count > 20:
            data[0] = x_count

        self.data = data

        self.board.set_animation_constraints(0, data[0], 0, data[1] - 1)

        self.layout.update_layout(data[0], data[1])
        self.board.level_start(data[0], data[1], self.layout.scale)

        shelf_len = 7
        # basket
        basket_w = data[0] - shelf_len - 1
        self.board.add_door(data[0] - basket_w, data[1] - 6, basket_w, 5, classes.board.Door, "", white, "")
        self.board.units[0].door_outline = True
        # basket image - 260 x 220
        img_bg_col = white
        scheme = "white"
        if self.mainloop.scheme is not None:
            if self.mainloop.scheme.dark:
                scheme = "black"
                img_bg_col = (0, 0, 0)
        img_src = os.path.join("schemes", scheme, "basket.png")
        self.board.add_door(data[0] - 6, data[1] - 6, 6, 5, classes.board.Door, "", img_bg_col, img_src)
        self.board.units[-1].is_door = False

        self.board.add_unit(data[0] - 7, 0, 7, 1, classes.board.Label, self.d["Shopping List"], white, "", data[4] + 1)
        self.board.units[-1].font_color = font_color
        f_end = ".png"
        items = ["fr_apple1", "fr_apple2", "fr_strawberry", "fr_pear", "fr_orange", "fr_onion", "fr_tomato", "fr_lemon",
                 "fr_cherry", "fr_pepper", "fr_carrot", "fr_banana", "fr_wmelon"]
        self.items = items
        self.img_captions = []
        self.singular_items = ["green apple", "red apple", "strawberry", "pear", "orange [fruit]", "onion", "tomato",
                               "lemon", "cherry", "pepper", "carrot", "banana", "watermelon"]
        for each in self.singular_items:
            caption = self.lang._n(each, 1)
            if not self.lang.ltr_text:
                caption = ex.reverse(self.lang._n(each, 1), self.lang.alpha, self.lang.lang)
                # caption = self.lang._n(each, 1)
            if caption is None:
                caption = ""
            self.img_captions.append(caption)

        if self.lang.lang in ["ru", "he"]:
            self.img_pcaptions = []
            si = self.lang.dp["fruit"]
            for each in si:
                pcaption = self.lang._n(each, 1)
                if pcaption is None:
                    pcaption = ""
                self.img_pcaptions.append(pcaption)
        else:
            self.img_pcaptions = self.img_captions

        item_indexes = [x for x in range(len(items))]
        self.chosen_items = [[], []]
        self.solution = {}
        # pick items and quantities
        for i in range(data[2]):
            index = random.randrange(0, len(item_indexes))
            self.chosen_items[0].append(item_indexes[index])
            quantity = random.randrange(1, data[3] + 1)
            self.chosen_items[1].append(quantity)
            self.solution[str(item_indexes[index])] = quantity
            del (item_indexes[index])

        if self.lang.ltr_text:
            l = [data[0] - 7, data[0] - 6, data[0] - 5]
        else:
            l = [data[0] - 1, data[0] - 2, data[0] - 7]
        # create shopping list
        for i in range(data[2]):
            ind = self.chosen_items[0][i]
            caption = self.lang._n(self.singular_items[ind], self.chosen_items[1][i])
            if not self.lang.ltr_text:
                caption = ex.reverse(caption, self.lang.alpha, self.lang.lang)
            if caption is None:
                caption = ""
            self.board.add_unit(l[0], i + 1, 1, 1, classes.board.Label, str(self.chosen_items[1][i]) + " ", white, "",
                                data[4])
            self.board.units[-1].font_color = font_color
            self.board.add_unit(l[1], i + 1, 1, 1, classes.board.ImgShip, "", (0, 0, 0, 0),
                                os.path.join("fr", items[ind] + f_end), data[4], alpha=True)
            self.board.add_unit(l[2], i + 1, 5, 1, classes.board.Label, caption, white, "", data[4])
            self.board.units[-1].font_color = font_color
            self.board.ships[i].immobilize()
            self.board.ships[i].outline = False
            if self.lang.ltr_text:
                self.board.units[-1].align = 1
            else:
                self.board.units[-1].align = 2
        # rearange z-order of red outlines (shopping list and basket)
        for i in range(2):
            self.board.all_sprites_list.move_to_front(self.board.units[i])

        # put stuff on shelves:
        for i in range(len(items)):
            image = os.path.join("fr", items[i] + f_end)

            for j in range(0, shelf_len):
                self.board.add_unit(j, i, 1, 1, classes.board.ImgShip, self.img_captions[i], (0, 0, 0, 0), image,
                                    data[4], alpha=True)
                self.board.ships[-1].audible = False
                self.board.ships[-1].speaker_val = self.img_pcaptions[i]
                self.board.ships[-1].speaker_val_update = False
                self.board.ships[-1].outline = False
        self.board.all_sprites_list.move_to_front(self.board.units[0])
        instruction = self.d["Check the shopping list"]
        self.board.add_unit(0, data[1] - 1, data[0], 1, classes.board.Letter, instruction, color0, "", 3)
        self.board.ships[-1].set_outline(0, 1)
        self.board.ships[-1].immobilize()
        self.board.ships[-1].font_color = font_color
        self.board.ships[-1].speaker_val = self.dp["Check the shopping list"]
        self.board.ships[-1].speaker_val_update = False
Пример #39
0
    def create_game_objects(self, level=1):
        self.allow_unit_animations = False
        self.active_tool = 0
        self.active_letter = "A"
        self.active_word = "Apple"
        self.var_brush = 1
        s = random.randrange(30, 80)
        v = random.randrange(200, 255)
        h = random.randrange(0, 255)
        letter_color = ex.hsv_to_rgb(h, s, v)
        font_color = ex.hsv_to_rgb(h, 255, 140)
        if self.mainloop.scheme is not None:
            self.bg_color = self.mainloop.scheme.u_color
            color = self.mainloop.scheme.u_color
        else:
            self.bg_color = [255, 255, 255]
            color = [255, 255, 255]

        llc = self.lang.alphabet_lc
        luc = self.lang.alphabet_uc
        l = len(llc)

        if l % 2 == 0:
            lh = l // 2
        else:
            lh = l // 2 + 1

        hue_step = 255 // (lh * 2)

        self.count = l * 2 + lh

        data = [35, l, 0, 8]

        font_size = 20
        self.brush_size = data[3]

        # stretch width to fit the screen size
        max_x_count = self.get_x_count(data[1], even=None)
        if max_x_count > 35:
            data[0] = max_x_count
        self.data = data

        self.vis_buttons = [0, 0, 0, 0, 1, 0, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0], data[1])
        scale = self.layout.scale
        self.board.level_start(data[0], data[1], scale)

        # canvas
        self.board.add_unit(10, 0, data[0] - 16, data[1], classes.board.Letter, "", color, "", font_size)
        self.canvas_block = self.board.ships[0]
        self.canvas_block.set_outline([0, 54, 229], 1)

        x = 0
        y = 0

        for i in range(0, l):
            self.board.add_unit(x, y, 2, 2, classes.board.Letter, luc[i], letter_color, "", 25)
            self.board.add_unit(x + 4, y, 2, 2, classes.board.Letter, llc[i], letter_color, "", 25)

            if i < lh:
                self.board.add_unit(x + 8, y, 2, 2, classes.board.Letter, str(i), letter_color, "", 25)

            y += 2

            if y >= l:
                x = 2
                y = 0

        self.board.add_door(0, 0, 2, 2, classes.board.Door, "", color, "")
        self.board.add_door(data[0] - 1, 17, 1, 1, classes.board.Door, "", color, "")
        tool_len = len(self.board.ships)

        # color pallette
        h = 0
        s = 250
        v = 70
        number_of_col_per_hue = 6
        v_num = (255 - v) // (number_of_col_per_hue)
        # greyscale
        grey_num = 6
        if grey_num > 1:
            grey_v_num = (255 // (grey_num - 1))
        else:
            grey_v_num = 0
        grey_count = 0

        for j in range(0, data[1]):
            for i in range(data[0] - 6, data[0]):
                color2 = ex.hsv_to_rgb(h, s, v)
                self.board.add_unit(i, j, 1, 1, classes.board.Ship, "", color2, "", 2)
                if h < 249:
                    if i < data[0] - 1:
                        v += v_num
                    else:
                        v = 70
                        s = 250
                        h += hue_step
                else:
                    if grey_count == 0:
                        s = 0
                        v = 0
                        grey_count += 1
                    else:
                        v += grey_v_num

        self.active_color = self.board.ships[173].initcolor
        self.size_display = self.board.units[0]
        self.tool_door = self.board.units[-2]
        self.color_door = self.board.units[-1]
        self.btn_down = False

        # points
        self.p_first = [0, 0]
        self.p_last = [0, 0]
        self.p_prev = [0, 0]
        self.p_current = [0, 0]

        self.outline_all(1, 1)

        doors = [self.tool_door, self.color_door]
        for each in doors:
            each.door_outline = True
            each.perm_outline_color = [255, 0, 0]
            self.board.all_sprites_list.move_to_front(each)

        for each in self.board.ships:
            each.outline = False
            each.font_color = font_color
            each.immobilize()

        self.canvas = pygame.Surface(
            [self.canvas_block.grid_w * self.board.scale, self.canvas_block.grid_h * self.board.scale - 1])
        self.canvas.fill(self.canvas_block.initcolor)
        self.paint_bg_letter()
        self.canvas_org = self.canvas.copy()
Пример #40
0
    def create_game_objects(self, level = 1):
        self.board.decolorable = False
        self.board.draw_grid = False

        color = ex.hsv_to_rgb(225,15,235)
        color2 = (255,255,255)
        self.col_r = (254,39,18)
        self.col_y = (254,254,51)
        self.col_b = (2,71,254)
        self.col_k = (0,0,0)
        self.col_e = (255,255,255)
        self.col_e2 = (245,245,245)
        self.col_e3 = (235,235,235)
        colorkey = (2,2,2)
        self.col_bg = (255,255,255)
        data = [30,23]
        x_count = self.get_x_count(data[1],even=True)
        if x_count > 30:
            data[0] = x_count

        self.data = data

        self.vis_buttons = [0,0,0,0,1,0,1,0,0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0],data[1])
        scale = self.layout.scale
        self.board.level_start(data[0],data[1],scale)

        self.board.board_bg.initcolor = self.col_bg
        self.board.board_bg.color = self.col_bg
        self.board.board_bg.update_me = True

        self.board.moved = self.moved

        y = data[1]-3

        self.rybke_g = [y,y,y,y,y]
        self.rybke = [0,0,0,0,0]

        self.board.add_unit(1,y,2,3,classes.board.ImgAlphaShip,"",self.col_bg,"tube_r.png")
        self.board.add_unit(4,y,2,3,classes.board.ImgAlphaShip,"",self.col_bg,"tube_y.png")
        self.board.add_unit(7,y,2,3,classes.board.ImgAlphaShip,"",self.col_bg,"tube_b.png")
        self.board.add_unit(10,y,2,3,classes.board.ImgAlphaShip,"",self.col_bg,"tube_k.png")
        self.board.add_unit(13,y,2,3,classes.board.ImgAlphaShip,"",self.col_bg,"tube_e.png")

        for each in self.board.ships:
            each.outline = False
            each.audible = False

        #add colour container
        self.board.add_unit(16,0,data[0]-16,data[1],classes.board.Label,"",self.col_e,"",0)

        self.canvas = self.board.units[0]
        self.canvas_center = [(self.canvas.grid_w*self.board.scale)//2,(self.canvas.grid_h*self.board.scale)//2]

        #adding borders between the colour tubes
        self.board.add_unit(0,0,1,data[1],classes.board.Label,"",self.col_bg,"",0)
        self.board.add_unit(3,0,1,data[1],classes.board.Label,"",self.col_bg,"",0)
        self.board.add_unit(6,0,1,data[1],classes.board.Label,"",self.col_bg,"",0)
        self.board.add_unit(9,0,1,data[1],classes.board.Label,"",self.col_bg,"",0)
        self.board.add_unit(12,0,1,data[1],classes.board.Label,"",self.col_bg,"",0)
        self.board.add_unit(15,0,1,data[1],classes.board.Label,"",self.col_bg,"",0)

        #adding colour guides
        self.board.add_door(1,0,2,data[1],classes.board.Door,"",color,"",0)
        self.board.units[-1].set_outline(self.col_r, 1)
        self.board.add_door(4,0,2,data[1],classes.board.Door,"",color,"",0)
        self.board.units[-1].set_outline(self.col_y, 1)
        self.board.add_door(7,0,2,data[1],classes.board.Door,"",color,"",0)
        self.board.units[-1].set_outline(self.col_b, 1)
        self.board.add_door(10,0,2,data[1],classes.board.Door,"",color,"",0)
        self.board.units[-1].set_outline(self.col_k, 1)
        self.board.add_door(13,0,2,data[1],classes.board.Door,"",color,"",0)
        self.board.units[-1].set_outline(self.col_e3, 1)

        #adding colour strips
        self.board.add_door(1,data[1]-1,2,1,classes.board.Door,"",self.col_r,"",0)
        self.board.add_door(4,data[1]-1,2,1,classes.board.Door,"",self.col_y,"",0)
        self.board.add_door(7,data[1]-1,2,1,classes.board.Door,"",self.col_b,"",0)
        self.board.add_door(10,data[1]-1,2,1,classes.board.Door,"",self.col_k,"",0)
        self.board.add_door(13,data[1]-1,2,1,classes.board.Door,"",self.col_e2,"",0)

        #white background
        self.board.add_door(1,0,2,data[1],classes.board.Door,"",self.col_bg,"",0)
        self.board.units[-1].image.set_colorkey(None)
        self.board.add_door(4,0,2,data[1],classes.board.Door,"",self.col_bg,"",0)
        self.board.units[-1].image.set_colorkey(None)
        self.board.add_door(7,0,2,data[1],classes.board.Door,"",self.col_bg,"",0)
        self.board.units[-1].image.set_colorkey(None)
        self.board.add_door(10,0,2,data[1],classes.board.Door,"",self.col_bg,"",0)
        self.board.units[-1].image.set_colorkey(None)
        self.board.add_door(13,0,2,data[1],classes.board.Door,"",self.col_bg,"",0)
        self.board.units[-1].image.set_colorkey(None)

        for i in range(8,24-2):
            if i>12:
                self.board.units[i].image.set_colorkey(colorkey)
                self.board.all_sprites_list.move_to_back(self.board.units[i])
            else:
                self.board.all_sprites_list.move_to_front(self.board.units[i])

        self.canvas.set_outline([255,229,127],1)
        self.canv = pygame.Surface([self.canvas.grid_w*self.board.scale, self.canvas.grid_h*self.board.scale-1])
        self.board.all_sprites_list.move_to_back(self.board.board_bg)
        self.mix()
Пример #41
0
    def create_game_objects(self, level=1):
        self.board.draw_grid = False
        self.allow_unit_animations = False
        self.allow_teleport = False
        self.vis_buttons = [1, 1, 1, 1, 1, 1, 1, 1, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)
        s = 100
        v = 255
        h = random.randrange(0, 255, 5)
        color0 = ex.hsv_to_rgb(h, 40, 230)
        font_color = ex.hsv_to_rgb(h, 255, 140)

        if self.level.lvl == 1:
            data = [11, 6, 3, 9, 2, 3]
        elif self.level.lvl == 2:
            data = [11, 6, 3, 20, 2, 5]
        elif self.level.lvl == 3:
            data = [11, 6, 3, 99, 2, 5]
        elif self.level.lvl == 4:
            data = [11, 6, 5, 9, 3, 3]
        elif self.level.lvl == 5:
            data = [11, 6, 5, 20, 3, 5]
        elif self.level.lvl == 6:
            data = [11, 6, 5, 99, 3, 5]
        elif self.level.lvl == 7:
            data = [11, 6, 7, 9, 4, 3]
        elif self.level.lvl == 8:
            data = [11, 6, 7, 20, 4, 5]
        elif self.level.lvl == 9:
            data = [11, 6, 7, 99, 4, 5]
        elif self.level.lvl == 10:
            data = [11, 6, 9, 9, 5, 3]
        elif self.level.lvl == 11:
            data = [11, 6, 9, 20, 5, 5]
        elif self.level.lvl == 12:
            data = [11, 6, 9, 99, 5, 5]
        elif self.level.lvl == 13:
            data = [11, 6, 11, 9, 6, 3]
        elif self.level.lvl == 14:
            data = [11, 6, 11, 20, 6, 5]
        elif self.level.lvl == 15:
            data = [11, 6, 11, 99, 6, 5]
        self.points = (data[4] - 1) * 2
        self.chapters = [1, 4, 7, 10, 13, 15]

        self.data = data
        self.layout.update_layout(data[0], data[1])
        self.board.level_start(data[0], data[1], self.layout.scale)

        self.num_list = []
        self.num_list2 = []

        sign = ["+", "-"]

        for i in range(data[4]):
            num1 = random.randrange(1, data[3])
            rand_sign = sign[random.randrange(2)]
            if rand_sign == "+":
                num2 = random.randrange(0, data[3])
            else:
                num2 = random.randrange(0, num1)
            expr = str(num1) + rand_sign + str(num2)
            self.num_list.append(expr)

        color = ((255, 255, 255))

        # create table to store 'binary' solution
        self.solution_grid = [0 for x in range(data[0])]
        self.expression = [" " for x in range(data[0])]
        # find position of first door square
        xd = (data[0] - data[2]) // 2

        # add objects to the board
        h = random.randrange(0, 255, 5)
        number_color = ex.hsv_to_rgb(h, s, v)  # highlight 1
        for i in range(0, data[4]):
            x2 = xd + i * 2
            caption = self.num_list[i]
            self.board.add_unit(x2, 2, 1, 1, classes.board.Label, caption, number_color, "", data[5])
            self.board.units[-1].font_color = ex.hsv_to_rgb(h, 255, 140)
            self.solution_grid[x2] = 1
            self.expression[x2] = str(self.num_list[i])
            if i < data[4] - 1:
                self.solution_grid[x2 + 1] = 1

        if h > 125:
            h = random.randrange(0, h - 25, 5)
        else:
            h = random.randrange(h + 25, 255, 5)
        number_color = ex.hsv_to_rgb(h, s, v)  # highlight 1
        indu = len(self.board.units)
        inds = len(self.board.ships)
        for i in range(0, data[4] - 1):
            self.board.add_unit(xd + i * 2 + 1, 1, 1, 3, classes.board.Letter, [">", "=", "<"], number_color, "",
                                data[5])
            self.board.ships[-1].font_color = ex.hsv_to_rgb(h, 255, 140)
            self.board.add_door(xd + i * 2 + 1, 2, 1, 1, classes.board.Door, "", color, "")
            self.board.units[indu + i].door_outline = True
            self.board.ships[inds + i].readable = False
            self.board.all_sprites_list.move_to_front(self.board.units[indu + i])

        instruction = self.d["Drag the slider"]
        self.board.add_unit(0, 5, 11, 1, classes.board.Letter, instruction, color0, "", 7)
        self.board.ships[-1].immobilize()
        self.board.ships[-1].font_color = font_color

        self.board.ships[-1].speaker_val = self.dp["Drag the slider"]
        self.board.ships[-1].speaker_val_update = False

        self.outline_all(0, 1)
Пример #42
0
    def create_game_objects(self, level = 1):
        self.board.decolorable = False
        self.vis_buttons = [1,1,1,1,1,1,1,0,0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)
        if self.mainloop.scheme is None:
            s = random.randrange(150, 225, 5)
            v = random.randrange(190, 225, 5)
            h = random.randrange(0, 255, 5)
            color0 = ex.hsv_to_rgb(h,40,230) #highlight 1
            color1 = ex.hsv_to_rgb(h,70,v) #highlight 2
            color2 = ex.hsv_to_rgb(h,s,v) #normal color
            color3 = ex.hsv_to_rgb(h,230,100)
            task_bg_color = (255,255,255)
            task_font_color = (0,0,0)
        else:
            s = 150
            v = 225
            h = 170
            color0 = ex.hsv_to_rgb(h,40,230) #highlight 1
            color1 = ex.hsv_to_rgb(h,70,v) #highlight 2
            color2 = ex.hsv_to_rgb(h,s,v) #normal color
            color3 = ex.hsv_to_rgb(h,230,100)
            task_bg_color = self.mainloop.scheme.u_color
            task_font_color = self.mainloop.scheme.u_font_color
        white = (255,255,255)

        #data = [x_count, y_count, range_from, range_to, max_sum_range, image]
        self.points = 1
        if self.level.lvl == 1:
            data = [23,9]
        elif self.level.lvl == 2:
            data = [23,9]
            color1 = color0
        elif self.level.lvl == 3:
            data = [23,9]
            color1 = color2 = color0
        elif self.level.lvl == 4:
            data = [23,9]
            color1 = color2 = color0
        elif self.level.lvl == 5:
            data = [23,9]
            color2 = color1 = color0 = (0,0,0)
            color3 = (40,40,40)
            self.points = 2
        self.data = data

        self.board.level_start(data[0],data[1],self.layout.scale)

        num1 = random.randrange(1,10)
        num2 = random.randrange(1,10)
        self.solution = [num1,num2,num1 * num2]
        self.digits = ["0","1","2","3","4","5","6","7","8","9"]

        unique = set()
        for i in range(1,10):
            for j in range(1,10):
                if i == num1 and j == num2: color=color0
                elif i == num1 or j == num2: color=color1
                elif self.level.lvl == 2 and (i == num2 or j == num1):color=color1
                else: color = color2
                mul = i*j
                unique.add(mul)
                caption = str(mul)
                self.board.add_unit(i-1,j-1,1,1,classes.board.Label,caption,color,"",2)
        self.board.add_unit(9,0,1,9,classes.board.Obstacle,"",color3)
        unique = sorted(unique)
        #draw outline with selectable numbers
        self.multi = dict()
        if self.mainloop.scheme is None:
            s = 180
        else:
            s = 80
        v = 240
        h = 7

        x = 11
        y = 0
        for i in range(9):
            x += 1
            color = ex.hsv_to_rgb(h*i,s,v)
            self.multi[str(unique[i])]=i
            caption = str(unique[i])
            self.board.add_unit(x,y,1,1,classes.board.Letter,caption,color,"",2)
            self.board.ships[-1].audible = False
            if self.lang.lang == "he":
                sv = self.lang.n2spk(unique[i])
                self.board.ships[-1].speaker_val = sv
                self.board.ships[-1].speaker_val_update = False
        x=14
        y=4
        captions = [str(num1),chr(215),"=",str(num1*num2)]
        if self.level.lvl < 4:
            color = self.board.ships[self.solution[1]-1].initcolor
        else:
            color = (255,255,255)
        for i in range(4):
            if i == 2:
                x += 1
            self.board.add_unit(x+i,y,1,1,classes.board.Label,captions[i],color,"",2)

        self.outline_all(0,1)

        self.board.add_door(16,y,1,1,classes.board.Door,"",task_bg_color,"",font_size = 2)
        self.home_square = self.board.units[86]
        self.home_square.door_outline = True
        self.home_square.font_color = task_font_color
        self.board.all_sprites_list.move_to_front(self.home_square)
Пример #43
0
    def create_game_objects(self, level=1):
        self.board.draw_grid = False
        self.board.decolorable = False
        self.vis_buttons = [1, 1, 1, 1, 1, 0, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)
        if self.mainloop.scheme is None:
            s = 100
            v = 255
            h = random.randrange(0, 255, 5)
            color0 = ex.hsv_to_rgb(h, 40, 255)  # highlight 1
            color1 = ex.hsv_to_rgb(h, 70, v)  # highlight 2
            color2 = ex.hsv_to_rgb(h, s, v)  # normal color
            color3 = ex.hsv_to_rgb(h, 230, 100)
            font_color = ex.hsv_to_rgb(h, 255, 140)
        else:
            s = 150
            v = 225
            h = 170
            color0 = ex.hsv_to_rgb(h, 40, 255)  # highlight 1
            color1 = ex.hsv_to_rgb(h, 70, v)  # highlight 2
            color2 = ex.hsv_to_rgb(h, s, v)  # normal color
            color3 = ex.hsv_to_rgb(h, 230, 100)
            font_color = self.mainloop.scheme.u_font_color

        # data = [x_count, y_count, range_from, range_to, max_sum_range, image]
        if self.level.lvl == 1:
            data = [23, 9]
        elif self.level.lvl == 2:
            data = [23, 9]
            color1 = color0
        elif self.level.lvl == 3:
            data = [23, 9]
            color1 = color2 = color0
        elif self.level.lvl == 4:
            data = [23, 9]
            color1 = color2 = color0
        elif self.level.lvl == 5:
            data = [23, 9]
            color2 = color1 = color0 = font_color
            color3 = (40, 40, 40)
        self.data = data
        self.board.set_animation_constraints(10, data[0], 0, data[1])

        self.board.level_start(data[0], data[1], self.layout.scale)

        self.unit_mouse_over = None
        self.units = []

        num1 = random.randrange(1, 10)
        num2 = random.randrange(1, 10)
        self.solution = [num1, num2, num1 * num2]
        self.digits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]

        unique = set()
        for i in range(1, 10):
            for j in range(1, 10):
                if i == num1 and j == num2:
                    color = color0
                elif i == num1 or j == num2:
                    color = color1
                elif self.level.lvl == 2 and (i == num2 or j == num1):
                    color = color1
                else:
                    color = color2
                mul = i * j
                unique.add(mul)
                caption = str(mul)
                self.board.add_unit(i - 1, j - 1, 1, 1, classes.board.Label, caption, color, "", 2)
                self.board.units[-1].font_color = font_color
        self.board.add_unit(9, 0, 1, 9, classes.board.Obstacle, "", color3)
        unique = sorted(unique)
        # draw outline with selectable numbers
        self.multi = dict()
        x = 11
        y = 0

        if self.mainloop.scheme is None:
            dc_img_src = os.path.join('unit_bg', "universal_sq_dc.png")
            door_bg_img_src = os.path.join('unit_bg', "universal_sq_door.png")
        else:
            dc_img_src = None
            door_bg_img_src = os.path.join('unit_bg', "universal_sq_door.png")
            if self.mainloop.scheme.dark:
                door_bg_img_src = os.path.join('unit_bg', "universal_sq_door_no_trans.png")

        bg_img_src = os.path.join('unit_bg', "universal_sq_bg.png")
        number_color = ex.hsv_to_rgb(h, self.mainloop.cl.bg_color_s, self.mainloop.cl.bg_color_v)
        font_color = [ex.hsv_to_rgb(h, self.mainloop.cl.font_color_s, self.mainloop.cl.font_color_v), ]
        fg_number_color = ex.hsv_to_rgb(h, self.mainloop.cl.fg_hover_s, self.mainloop.cl.fg_hover_v)

        h = 7

        for i in range(9):
            x += 1
            if self.level.lvl < 2:
                number_color = ex.hsv_to_rgb(h * i, self.mainloop.cl.bg_color_s, self.mainloop.cl.bg_color_v)
                fg_number_color = ex.hsv_to_rgb(h * i, self.mainloop.cl.fg_hover_s, self.mainloop.cl.fg_hover_v)
                font_color = [ex.hsv_to_rgb(h * i, self.mainloop.cl.font_color_s, self.mainloop.cl.font_color_v), ]
            self.multi[str(unique[i])] = i
            caption = str(unique[i])
            self.board.add_universal_unit(grid_x=x, grid_y=y, grid_w=1, grid_h=1, txt=caption,
                                          fg_img_src=bg_img_src, bg_img_src=bg_img_src, dc_img_src=dc_img_src,
                                          bg_color=(0, 0, 0, 0), border_color=None, font_color=font_color,
                                          bg_tint_color=number_color, fg_tint_color=fg_number_color,
                                          txt_align=(0, 0), font_type=2, multi_color=False, alpha=True,
                                          immobilized=False, fg_as_hover=True)
            self.units.append(self.board.ships[-1])
            self.board.ships[-1].audible = False
            if self.lang.lang == "he":
                sv = self.lang.n2spk(unique[i])
                self.board.ships[-1].speaker_val = sv
                self.board.ships[-1].speaker_val_update = False
        x = 14
        y = 4
        captions = [str(num1), chr(215), "=", str(num1 * num2)]
        if self.level.lvl < 2:
            number_color = self.board.ships[self.solution[1] - 1].bg_tint_color
            font_color = self.board.ships[self.solution[1] - 1].font_colors

        for i in range(4):
            if i == 2:
                x += 1
            self.board.add_universal_unit(grid_x=x + i, grid_y=y, grid_w=1, grid_h=1, txt=captions[i],
                                          fg_img_src=None, bg_img_src=bg_img_src, dc_img_src=dc_img_src,
                                          bg_color=(0, 0, 0, 0), border_color=None, font_color=font_color,
                                          bg_tint_color=number_color, fg_tint_color=None,
                                          txt_align=(0, 0), font_type=2, multi_color=False, alpha=True,
                                          immobilized=True, fg_as_hover=False, mode=1)
            if self.level.lvl < 2:
                self.board.units[-1].font_colors = self.board.ships[self.solution[1] - 1].font_colors

        self.outline_all(0, 1)

        self.board.add_universal_unit(grid_x=16, grid_y=y, grid_w=1, grid_h=1, txt="",
                                      fg_img_src=None, bg_img_src=door_bg_img_src, dc_img_src=None,
                                      bg_color=(0, 0, 0, 0), border_color=None, font_color=None,
                                      bg_tint_color=number_color, fg_tint_color=None,
                                      txt_align=(0, 0), font_type=2, multi_color=False, alpha=True,
                                      immobilized=True, fg_as_hover=False, mode=2)

        self.home_square = self.board.units[86]
        self.home_square.checkable = True
        self.home_square.init_check_images()
        self.home_square.door_outline = True
        if self.level.lvl < 2:
            self.home_square.font_colors = self.board.ships[self.solution[1] - 1].font_colors

        self.board.all_sprites_list.move_to_front(self.home_square)
Пример #44
0
    def create_game_objects(self, level=1):
        self.board.draw_grid = False
        self.vis_buttons = [1, 1, 1, 1, 1, 1, 1, 1, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)
        s = 100  # random.randrange(150, 190, 5)
        v = 255  # random.randrange(230, 255, 5)
        h = random.randrange(0, 255, 5)
        color0 = ex.hsv_to_rgb(h, 40, 230)  # highlight 1
        font_color = ex.hsv_to_rgb(h, 255, 140)

        # data = [x_count, y_count, number_count, top_limit, ordered]
        if self.level.lvl == 1:
            data = [11, 6, 3, 9, True, 1]
        elif self.level.lvl == 2:
            data = [11, 6, 3, 9, False, 1]
        elif self.level.lvl == 3:
            data = [11, 6, 5, 15, True, 2]
        elif self.level.lvl == 4:
            data = [11, 6, 5, 15, False, 2]
        elif self.level.lvl == 5:
            data = [11, 6, 7, 20, True, 2]
        elif self.level.lvl == 6:
            data = [11, 6, 7, 20, False, 2]
        elif self.level.lvl == 7:
            data = [11, 6, 9, 99, True, 2]
        elif self.level.lvl == 8:
            data = [11, 6, 9, 99, False, 2]
        elif self.level.lvl == 9:
            data = [11, 6, 11, 99, True, 2]
        elif self.level.lvl == 10:
            data = [11, 6, 11, 99, False, 2]
        self.chapters = [1, 3, 5, 7, 9, 10]

        self.points = (data[2] + 2) // 3 + self.level.lvl // 4

        self.data = data

        self.board.set_animation_constraints(0, data[0], 0, data[1] - 1)
        self.layout.update_layout(data[0], data[1])
        self.board.level_start(data[0], data[1], self.layout.scale)

        self.num_list = []

        if data[4] == True:
            choice_list = [x for x in range(data[3] - data[2])]
            index = random.randrange(0, len(choice_list))
            n = 0
            for i in range(data[2]):
                self.num_list.append(choice_list[index] + n)
                n += 1
        else:
            choice_list = [x for x in range(data[3])]
            for i in range(data[2]):
                index = random.randrange(0, len(choice_list))
                self.num_list.append(choice_list[index])
                del (choice_list[index])

        shuffled = self.num_list[:]
        random.shuffle(shuffled)

        color = ((255, 255, 255))

        # create table to store 'binary' solution
        self.solution_grid = [0 for x in range(data[0])]

        # find position of first door square
        x = (data[0] - data[2]) // 2

        # add objects to the board
        for i in range(data[2]):
            self.board.add_door(x + i, 0, 1, 1, classes.board.Door, "", color, "")
            self.board.units[i].door_outline = True
            h = random.randrange(0, 255, 5)
            y = random.randrange(1, 5)
            number_color = ex.hsv_to_rgb(h, s, v)  # highlight 1
            caption = str(shuffled[i])
            self.board.add_unit(x + i, y, 1, 1, classes.board.Letter, caption, number_color, "", data[5])
            self.board.ships[-1].font_color = ex.hsv_to_rgb(h, 255, 140)
            self.solution_grid[x + i] = 1
            self.board.ships[-1].readable = False

        for each in self.board.units:
            self.board.all_sprites_list.move_to_front(each)

        instruction = self.d["Re-arrange ascending"]
        self.board.add_unit(0, 5, 11, 1, classes.board.Letter, instruction, color0, "", 7)
        self.board.ships[-1].immobilize()
        self.board.ships[-1].font_color = font_color
        self.board.ships[-1].speaker_val = self.dp["Re-arrange ascending"]
        self.board.ships[-1].speaker_val_update = False
        self.outline_all(0, 1)
Пример #45
0
    def create_game_objects(self, level=1):
        self.board.draw_grid = False
        self.vis_buttons = [0, 1, 1, 1, 1, 1, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)
        self.allow_unit_animations = False
        self.change_count = 0
        self.allow_teleport = False
        s = random.randrange(150, 205, 5)
        v = random.randrange(150, 205, 5)
        h = random.randrange(0, 255, 5)
        letter_bg = (255, 255, 255)
        letter_font_color = ex.hsv_to_rgb(h, 255, 140)
        # data = [0:x_count, 1:y_count, 2:games_per_level, 3:bug_img, 4:level_maps]
        bug_img = "bug_32.png"
        if self.mainloop.scheme is not None:
            if self.mainloop.scheme.dark:
                bug_img = "bug_32b.png"
                letter_bg = (0, 0, 0)
                s = 100
                v = 50
            h = 40
            letter_font_color = self.mainloop.scheme.u_font_color

        color = ex.hsv_to_rgb(h, s, v)
        color1 = ex.hsv_to_rgb(h, 40, 230)  # label
        color2 = ex.hsv_to_rgb(h, 150, 230)  # completed
        color3 = ex.hsv_to_rgb(h, 255, 150)  # current
        self.font_color = ex.hsv_to_rgb(h, 255, 140)
        self.font_color_current = ex.hsv_to_rgb(h, 155, 255)
        self.clr = [color1, color2, color3]

        if self.level.lvl == 1:  # img_ 32x32
            data = [27, 19, 10, bug_img, 2, gl.lvl1]
        elif self.level.lvl == 2:  # img_ 32x32
            data = [27, 19, 10, bug_img, 3, gl.lvl1]
        elif self.level.lvl == 3:  # img_ 32x32
            data = [27, 19, 10, bug_img, 4, gl.lvl1]
        elif self.level.lvl == 4:  # img_ 32x32
            data = [27, 19, 10, bug_img, 5, gl.lvl1]
        elif self.level.lvl == 5:  # img_ 32x32
            data = [27, 19, 10, bug_img, 6, gl.lvl1]
        self.points = data[4]
        self.data = data

        self.layout.update_layout(data[0], data[1])
        self.board.level_start(data[0], data[1], self.layout.scale)
        self.solution = [data[0] - 2, data[1] - 2]

        letter_table = []
        letter_table.extend(self.lang.alphabet_lc)
        letter_table.extend(self.lang.accents_lc)
        letter_table.extend(self.lang.alphabet_uc)
        letter_table.extend(self.lang.accents_uc)

        self.word = self.lang.di[data[4]][random.randrange(1, self.lang.di[data[4]][0])]
        if sys.version_info < (3, 0):
            self.wordu = unicode(self.word, "utf-8")
            word_len = len(self.wordu)
            self.word_l = []
            # dirty way of replacing the word with letters from alphabet
            for each in self.wordu:
                for i in range(len(letter_table)):
                    if each == unicode(letter_table[i], "utf-8"):
                        self.word_l.append(letter_table[i])
            self.word = self.word_l
            self.s_word = ''.join(self.word_l)
        else:
            word_len = len(self.word)
            self.word_l = self.word
            self.s_word = self.word
            self.word = list(self.word)

        self.word_len = word_len

        self.remaining = self.word_len + 0
        shuffled = self.word[:]
        self.searched_letter = self.word[0]

        board_number = random.randrange(1, data[5][0][0] + 1)

        w = self.word_len
        x = (data[0] - w) // 2
        x2 = data[0] // 2
        midscreen = data[1] // 2
        for i in range(self.word_len):
            if i == 0:
                colr = color3
                fc = self.font_color_current
            else:
                colr = color1
                fc = self.font_color
            self.board.add_unit(x + i, midscreen, 1, 1, classes.board.Label, self.word[i], colr, "", 1)
            self.board.units[i].set_outline(0, 3)
            self.board.units[i].font_color = fc

        avail = [[[], []], [[], []]]
        for j in range(data[1]):
            for i in range(data[0]):
                if data[5][board_number][j][i] == 1:
                    self.board.add_unit(i, j, 1, 1, classes.board.Obstacle, "", color)
                # create availability table:
                else:
                    if (1 < i < data[0] - 2) and ((1 < j < midscreen - 2) or (midscreen + 2 < j < data[1] - 2)):
                        if i % 4 == 0:
                            # create table 1
                            if j < midscreen - 2:
                                avail[0][0].append([i, j])
                            else:
                                avail[0][1].append([i, j])
                        elif (i + 2) % 4 == 0:
                            # create table 2
                            if j < midscreen - 2:
                                avail[1][0].append([i, j])
                            else:
                                avail[1][1].append([i, j])
        # select positions:
        self.letter_pos = []
        col = [[], []]
        ln = [[len(avail[0][0]), len(avail[0][1])], [len(avail[1][0]), len(avail[1][1])]]
        av1 = random.randrange(0, 2)
        av2 = 0
        for i in range(self.word_len):
            if i > self.word_len // 2: av2 = 1
            not_in = True
            while not_in:
                pos = avail[av1][av2][random.randrange(0, ln[av1][av2])]
                if pos[0] not in col[av2]:
                    not_in = False
                    col[av2].append(pos[0])
                    self.letter_pos.append(pos)
                    self.board.add_door(pos[0], pos[1], 1, 1, classes.board.PickUp, shuffled[i], letter_bg)
                    self.board.units[-1].font_color = letter_font_color
        self.letter_pos2 = self.letter_pos[:]

        # add the bug
        self.board.add_unit(x2, midscreen - 1, 1, 1, classes.board.ImgShipRota, self.s_word, letter_bg, data[3])
        self.board.ships[0].audible = False
        self.board.ships[0].outline = False
        self.board.ships[0].draggable = True
        self.board.all_sprites_list.move_to_front(self.board.ships[0])

        self.ships_count = len(self.board.ships)

        self.board.active_ship = 0
        self.ship_id = 0
        self.units_len = len(self.board.units)
        self.board.moved = self.walk_through
        self.drag = False
Пример #46
0
    def create_game_objects(self, level=1):
        self.board.decolorable = False
        self.vis_buttons = [0, 1, 1, 1, 1, 0, 1, 0, 1]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)
        self.board.draw_grid = False
        if self.mainloop.scheme is None:
            h = random.randrange(0, 255, 5)
            white = (255, 255, 255)
            self.bg_col = white
            self.color2 = ex.hsv_to_rgb(h, 255, 170)  # contours & borders
            self.font_color = ex.hsv_to_rgb(h, 255, 100)
        else:
            self.font_color = self.mainloop.scheme.u_font_color  # ex.hsv_to_rgb(h,255,100)
            if self.mainloop.scheme.dark:
                self.bg_col = (0, 0, 1)
                self.color2 = (0, 0, 200)
            else:
                self.bg_col = (254, 254, 255)
                self.color2 = (0, 0, 200)

        if self.mainloop.scheme is not None:
            h1 = 170
            h2 = 40
            color1 = ex.hsv_to_rgb(h1, 255, 255)
            color2 = ex.hsv_to_rgb(h2, 75, 255)
            bd_color1 = ex.hsv_to_rgb(h1, 127, 155)
            bd_color2 = ex.hsv_to_rgb(h2, 127, 155)
        else:
            h1 = h
            h2 = h1
            color1 = ex.hsv_to_rgb(h1, 150, 255)
            color2 = ex.hsv_to_rgb(h2, 30, 255)
            bd_color1 = ex.hsv_to_rgb(h1, 187, 200)
            bd_color2 = ex.hsv_to_rgb(h2, 150, 225)

        data = [13, 5, 3]
        data.extend(
            self.mainloop.xml_conn.get_level_data(
                self.mainloop.m.game_dbid, self.mainloop.config.user_age_group,
                self.level.lvl))
        data.append(5)
        self.chapters = self.mainloop.xml_conn.get_chapters(
            self.mainloop.m.game_dbid, self.mainloop.config.user_age_group)
        self.data = data
        self.layout.update_layout(data[0], data[1])
        self.board.set_animation_constraints(5, data[0] - 5, 0, data[1])
        self.board.level_start(data[0], data[1], self.layout.scale)

        self.unit_mouse_over = None
        self.units = []

        self.num_list = []
        self.num_list2 = []
        sign = "/"
        numbers = []
        for i in range(2):
            num1 = random.randrange(1, data[3])
            num2 = random.randrange(num1 + 1, data[3] + 1)
            numbers.append([num1, num2])
            expr = str(float(num1)) + sign + str(float(num2))
            disp = ["", str(num1), str(num2), ""]
            self.num_list.append(expr)
            self.num_list2.append(disp)

        # create table to store 'binary' solution
        self.solution_grid = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        self.expression = [" " for x in range(data[0])]
        # find position of first door square
        xd = (data[0] - data[2]) // 2

        # add objects to the board
        self.board.add_unit(0, 0, 5, 5, classes.board.Label, "", self.bg_col,
                            "", data[4])
        self.board.add_unit(8, 0, 5, 5, classes.board.Label, "", self.bg_col,
                            "", data[4])

        size = self.board.scale
        center = [size // 2, size // 2]

        if self.mainloop.scheme is None:
            dc_img_src = os.path.join('unit_bg', "universal_sq_dc.png")
        else:
            dc_img_src = None

        bg_img_src = os.path.join('unit_bg', "universal_sq_bg.png")
        bg_door_img_src = os.path.join('unit_bg', "universal_sq_door.png")

        number_color = ex.hsv_to_rgb(h, self.mainloop.cl.bg_color_s,
                                     self.mainloop.cl.bg_color_v)
        font_color = [
            ex.hsv_to_rgb(h, self.mainloop.cl.font_color_s,
                          self.mainloop.cl.font_color_v),
        ]
        door_color = ex.hsv_to_rgb(0, self.mainloop.cl.door_bg_tint_s,
                                   self.mainloop.cl.door_bg_tint_v)
        fg_number_color = ex.hsv_to_rgb(h, self.mainloop.cl.fg_hover_s,
                                        self.mainloop.cl.fg_hover_v)

        for i in range(0, 2):
            x2 = xd + i * 2
            caption = self.num_list2[i]
            self.board.add_universal_unit(grid_x=x2,
                                          grid_y=2,
                                          grid_w=1,
                                          grid_h=1,
                                          txt=caption,
                                          fg_img_src=None,
                                          bg_img_src=bg_img_src,
                                          dc_img_src=dc_img_src,
                                          bg_color=(0, 0, 0, 0),
                                          border_color=None,
                                          font_color=font_color,
                                          bg_tint_color=number_color,
                                          fg_tint_color=None,
                                          txt_align=(0, 0),
                                          font_type=data[4],
                                          multi_color=False,
                                          alpha=True,
                                          mode=1,
                                          immobilized=True)
            self.board.units[i + 2].init_m_painting()
            self.draw_fractions(self.board.units[i + 2].manual_painting, size,
                                center, font_color[0])
            self.board.units[i + 2].update_me = True

            self.expression[x2] = str(self.num_list[i])
            if i < 1:
                self.solution_grid[x2 + 1] = 1

        signs = [" < ", " = ", " > "]

        for i in range(len(signs)):
            if len(signs) < data[0]:
                if i == 0 and len(signs) % 2 == 0:
                    x = data[0] // 2
                    y = 2
                else:
                    x = (data[0] - len(signs)) // 2
                    y = 0

            self.board.add_universal_unit(grid_x=x + i,
                                          grid_y=y,
                                          grid_w=1,
                                          grid_h=1,
                                          txt=signs[i],
                                          fg_img_src=bg_img_src,
                                          bg_img_src=bg_img_src,
                                          dc_img_src=dc_img_src,
                                          bg_color=(0, 0, 0, 0),
                                          border_color=None,
                                          font_color=font_color,
                                          bg_tint_color=number_color,
                                          fg_tint_color=fg_number_color,
                                          txt_align=(0, 0),
                                          font_type=data[4],
                                          multi_color=False,
                                          alpha=True,
                                          immobilized=False,
                                          fg_as_hover=True)
            self.units.append(self.board.ships[-1])

            self.board.ships[-1].checkable = True
            self.board.ships[-1].init_check_images()
            self.board.ships[i].readable = False

        ind = len(self.board.units)
        self.board.add_universal_unit(grid_x=xd + 1,
                                      grid_y=2,
                                      grid_w=1,
                                      grid_h=1,
                                      txt=None,
                                      fg_img_src=None,
                                      bg_img_src=bg_door_img_src,
                                      dc_img_src=None,
                                      bg_color=(0, 0, 0, 0),
                                      border_color=None,
                                      font_color=None,
                                      bg_tint_color=door_color,
                                      fg_tint_color=None,
                                      txt_align=(0, 0),
                                      font_type=10,
                                      multi_color=False,
                                      alpha=True,
                                      immobilized=True,
                                      mode=2)

        self.board.all_sprites_list.move_to_front(self.board.units[ind])

        for i in range(2):
            self.fraction = classes.drw.fraction_hq.Fraction(
                1, self.board.scale * self.board.units[i].grid_w, color1,
                color2, bd_color1, bd_color2, numbers[i], 1)
            self.board.units[i].painting = self.fraction.get_canvas().copy()
Пример #47
0
    def create_game_objects(self, level=1):
        self.allow_unit_animations = False
        self.allow_teleport = False
        self.board.decolorable = False
        self.vis_buttons = [4, 1, 1, 1, 1, 1, 1, 1, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.board.draw_grid = False

        s = random.randrange(150, 190, 5)
        v = random.randrange(230, 255, 5)
        h = random.randrange(0, 255, 5)
        white = (255, 255, 255)
        if self.mainloop.scheme is None:
            color0 = ex.hsv_to_rgb(h, 40, 230)  # highlight 1
        else:
            color0 = self.mainloop.scheme.u_color
            if self.mainloop.scheme.dark:
                white = (0, 0, 0)
        outline_color = (150, 150, 150)
        # setting level variable
        # data = [x_count, y_count, number_count, top_limit, ordered]
        if self.level.lvl == 1:
            data = [13, 7, 5, 3, 2]
        elif self.level.lvl == 2:
            data = [13, 7, 8, 3, 3]
        elif self.level.lvl == 3:
            data = [12, 7, 7, 4, 2]
        elif self.level.lvl == 4:
            data = [12, 7, 11, 4, 3]
        elif self.level.lvl == 5:
            data = [12, 7, 15, 4, 4]
        elif self.level.lvl == 6:
            data = [13, 7, 9, 5, 2]
        elif self.level.lvl == 7:
            data = [13, 7, 14, 5, 3]
        elif self.level.lvl == 8:
            data = [13, 7, 19, 5, 4]
        elif self.level.lvl == 9:
            data = [12, 7, 11, 6, 2]
        elif self.level.lvl == 10:
            data = [12, 7, 17, 6, 3]

        self.chapters = [1, 5, 10]
        self.points = (data[3] * data[4]) // 2

        # rescale the number of squares horizontally to better match the screen width
        m = data[0] % 2
        if m == 0:
            x_count = self.get_x_count(data[1], even=True)
        else:
            x_count = self.get_x_count(data[1], even=False)

        if x_count > data[0]:
            data[0] = x_count

        self.data = data
        self.layout.update_layout(data[0], data[1])
        self.board.level_start(data[0], data[1], self.layout.scale)

        image_src = [os.path.join('memory', "n_img%da.png" % (i)) for i in range(1, 22)]
        self.choice_list = [x for x in range(1, data[2] + 1)]
        self.shuffled = self.choice_list[:]
        random.shuffle(self.shuffled)

        inversions = ex.inversions(self.shuffled)
        if inversions % 2 != 0:  # if number of inversions is odd it is unsolvable
            # in unsolvable combinations swapping 2 squares will make it solvable
            temp = self.shuffled[0]
            self.shuffled[0] = self.shuffled[1]
            self.shuffled[1] = temp

        color = ((255, 255, 255))

        h1 = (data[1] - data[4]) // 2  # height of the top margin
        h2 = data[1] - h1 - data[4] - 1  # height of the bottom margin minus 1 (game label)
        w2 = (data[0] - data[3]) // 2  # side margin width
        self.check = [h1, h2, w2]

        self.board.add_door(w2, h1, data[3], data[4], classes.board.Door, "", color, "")
        # create table to store 'binary' solution
        # find position of first door square
        x = w2
        y = h1
        self.mini_grid = []
        # add objects to the board
        line = []
        h_start = random.randrange(0, 155, 5)
        h_step = 100 // (data[2])
        for i in range(data[2]):
            h = (h_start + (self.shuffled[i] - 1) * h_step)
            number_color = ex.hsv_to_rgb(h, s, v)  # highlight 1
            caption = str(self.shuffled[i])
            self.board.add_unit(x, y, 1, 1, classes.board.ImgShip, caption, white, image_src[self.shuffled[i]])
            self.board.ships[-1].readable = False
            line.append(i)
            x += 1
            if x >= w2 + data[3] or i == data[2] - 1:
                x = w2
                y += 1
                self.mini_grid.append(line)
                line = []
        self.outline_all(outline_color, 1)
        instruction = self.d["Re-arrange right"]
        self.board.add_unit(0, data[1] - 1, data[0], 1, classes.board.Letter, instruction, color0, "", 8)  # bottom 2
        self.board.ships[-1].immobilize()
        if self.mainloop.scheme is not None:
            self.board.ships[-1].font_color = self.mainloop.scheme.u_font_color
        self.board.ships[-1].speaker_val = self.dp["Re-arrange right"]
        self.board.ships[-1].speaker_val_update = False

        # horizontal
        self.board.add_unit(0, 0, data[0], h1, classes.board.Obstacle, "", white, "", 7)  # top
        self.board.add_unit(0, h1 + data[4], data[0], h2, classes.board.Obstacle, "", white, "", 7)  # bottom 1
        # side obstacles
        self.board.add_unit(0, h1, w2, data[4], classes.board.Obstacle, "", white, "", 7)  # left
        self.board.add_unit(w2 + data[3], h1, w2, data[4], classes.board.Obstacle, "", white, "", 7)  # right

        self.board.all_sprites_list.move_to_front(self.board.units[0])
Пример #48
0
    def create_game_objects(self, level = 1):
        self.vis_buttons = [1,1,1,1,1,1,1,0,0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.ai_enabled = True
        self.ai_speed = 18
        self.correct = False
        self.board.draw_grid = False
        if self.mainloop.scheme is not None:
            color1 = self.mainloop.scheme.color1 #bright side of short hand
            color3 = self.mainloop.scheme.color3 #inner font color
            color5 = self.mainloop.scheme.color5 #dark side of short hand
            color7 = self.mainloop.scheme.color7 #inner circle filling

            color2 = self.mainloop.scheme.color2 #bright side of long hand
            color4 = self.mainloop.scheme.color4 #ex.hsv_to_rgb(170,255,255)#outer font color
            color6 = self.mainloop.scheme.color6 #dark side of long hand
            color8 = self.mainloop.scheme.color8 #outer circle filling

            white = self.mainloop.scheme.u_color
            gray = (100,100,100)
        else:
            color1 = ex.hsv_to_rgb(225,70,230)
            color3 = ex.hsv_to_rgb(225,255,255)
            color5 = ex.hsv_to_rgb(225,180,240)
            color7 = ex.hsv_to_rgb(225,10,255)

            color2 = ex.hsv_to_rgb(170,70,230)
            color4 = ex.hsv_to_rgb(170,255,255)
            color6 = ex.hsv_to_rgb(170,180,240)
            color8 = ex.hsv_to_rgb(170,10,255)

            white = (255,255,255)
            gray = (100,100,100)

        if self.level.lvl == 1:
            data = [19,10,True,True,False,False,True,False,False,True,True,15]
            h_pool = range(1,13)
            m_pool = [0]
        elif self.level.lvl == 2:
            data = [19,10,True,True,False,False,True,False,False,True,True,15]
            h_pool = range(1,13)
            m_pool = range(0,60,15)
        elif self.level.lvl == 3:
            data = [19,10,True,True,False,False,False,True,False,True,True,15]
            h_pool = range(1,13)
            m_pool = range(0,60,5)
        elif self.level.lvl == 4:
            data = [19,10,True,True,False,False,False,True,False,True,True,15]
            h_pool = range(1,13)
            m_pool = range(0,60,5)
        elif self.level.lvl == 5:
            data = [19,10,True,True,False,False,False,False,False,True,True,25]
            h_pool = range(1,13)
            m_pool = range(0,60)
        elif self.level.lvl == 6:
            data = [19,10,True,True,True,False,True,False,False,True,True,15]
            h_pool = range(13,24)
            m_pool = [0]
        elif self.level.lvl == 7:
            data = [19,10,True,True,True,False,False,True,False,True,True,15]
            h_pool = range(13,24)
            h_pool.append(0)
            m_pool = range(0,60,5)
        elif self.level.lvl == 8:
            data = [19,10,True,True,True,False,False,False,False,True,True,25]
            h_pool = range(0,24)
            m_pool = range(0,60)
        elif self.level.lvl == 9:
            data = [19,10,True,True,False,False,False,False,False,False,True,25]
            h_pool = range(1,13)
            m_pool = range(0,60)
        elif self.level.lvl == 10:
            data = [19,10,True,True,False,False,False,True,False,False,True,25]
            h_pool = range(1,13)
            m_pool = range(0,60)
        elif self.level.lvl == 11:
            data = [19,10,True,True,False,False,True,False,False,False,True,25]
            h_pool = range(1,13)
            m_pool = range(0,60)
        elif self.level.lvl == 12:
            data = [19,10,True,False,False,False,False,False,False,False,True,25]
            h_pool = range(1,13)
            m_pool = range(0,60)
        elif self.level.lvl == 13:
            data = [19,10,True,False,False,True,False,False,False,False,True,25]
            h_pool = range(1,13)
            m_pool = range(0,60)
        self.points = self.level.lvl // 2 + 1

        #visual display properties
        self.show_outer_ring = data[2]
        self.show_minutes = data[3]
        self.show_24h = data[4]
        self.show_only_quarters_h = data[5]
        self.show_only_quarters_m = data[6]
        self.show_only_fives_m = data[7]
        self.show_only_spare_variable = data[8]
        self.show_highlight = data[9]
        self.show_hour_offset = data[10]

        self.level.games_per_lvl = data[11]

        self.digits = ["0","1","2","3","4","5","6","7","8","9"]

        x_count = self.get_x_count(data[1],even=False)
        if x_count > data[0]:
            data[0] = x_count

        self.font_size = 0
        self.data = data

        self.layout.update_layout(data[0],data[1])
        scale = self.layout.scale
        self.board.level_start(data[0],data[1],self.layout.scale)

        size = self.board.scale*10
        ans_offset = 10+(data[0]-15)//2
        self.board.add_unit(10,0,data[0]-10,2,classes.board.Label,self.lang.d["What time"],white,"",2)
        self.board.units[-1].font_color = gray
        self.board.add_unit(ans_offset,2,2,2,classes.board.Letter,"00",white,"",0)
        self.ans_h = self.board.ships[-1]
        self.board.active_ship = self.ans_h.unit_id
        self.home_square = self.ans_h

        self.board.add_unit(ans_offset+2,2,1,2,classes.board.Label,":",white,"",0)
        self.board.add_unit(ans_offset+3,2,2,2,classes.board.Letter,"00",white,"",0)
        self.ans_m = self.board.ships[-1]
        self.ans_h.set_outline(color3, 5)
        self.ans_m.set_outline(color4, 5)

        self.ans_h.immobilize()
        self.ans_m.immobilize()

        self.ans_h.font_color = color3
        self.ans_m.font_color = color4

        center = [size//2,size//2]
        self.board.add_unit(0,0,10,10,classes.board.Ship,"",white,"",self.font_size)
        self.clock_canvas = self.board.ships[-1]
        self.clock_canvas.font = self.clock_canvas.board.font_sizes[2]
        self.clock_canvas.font2 = self.clock_canvas.board.font_sizes[7]
        self.clock_canvas.font3 = self.clock_canvas.board.font_sizes[26]
        self.clock_canvas.immobilize()
        canvas = pygame.Surface([size, size-1])
        if self.mainloop.scheme is not None:
            canvas.fill(self.mainloop.scheme.u_color)
        else:
            canvas.fill((255,255,255))
        self.time = [random.choice(h_pool), random.choice(m_pool)]#[random.randrange(0,23),random.randrange(0,60)]

        self.draw_hands(self.time,canvas,size,center,[color1,color2],[color3,color4],[color5,color6],[color7,color8])#data[7](data, canvas, i)

        self.clock_canvas.hidden_value = [2,3]#numbers[i]
        self.clock_canvas.font_color = color2
        self.clock_canvas.painting = canvas.copy()
Пример #49
0
    def create_game_objects(self, level=1):
        self.vis_buttons = [1, 1, 1, 1, 1, 1, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)
        #s = random.randrange(30, 80)
        #v = random.randrange(200, 255)
        h = 230  #random.randrange(0, 255)
        color1 = (255, 255, 255)
        #color2 = ex.hsv_to_rgb(h,150,v)
        color3 = ex.hsv_to_rgb(h, 150, 75)

        self.correct = False
        self.digits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]

        #data = [0-x_count, 1-y_count, 2-bottom_range1, 3-top_range1, 4-bottom_range2, 5-top_range2, 6-operator, 7-font_size]

        if self.mainloop.m.game_variant == 0:
            self.points = self.level.lvl
            self.level.lvl_count = 11
            if self.level.lvl == 1:  #addition - ch0
                data = [20, 14, 1, 5, 1, 5, "+", 2]
            elif self.level.lvl == 2:
                data = [20, 14, 3, 9, 1, 5, "+", 2]
            elif self.level.lvl == 3:
                data = [20, 14, 5, 15, 3, 9, "+", 2]
            elif self.level.lvl == 4:
                data = [20, 14, 5, 15, 5, 15, "+", 2]
            elif self.level.lvl == 5:
                data = [20, 14, 15, 55, 5, 35, "+", 2]
            elif self.level.lvl == 6:
                data = [20, 14, 35, 75, 15, 25, "+", 2]
            elif self.level.lvl == 7:
                data = [20, 14, 55, 99, 55, 99, "+", 2]
            elif self.level.lvl == 8:
                data = [20, 14, 100, 250, 100, 250, "+", 4]
            elif self.level.lvl == 9:
                data = [20, 14, 300, 500, 250, 499, "+", 4]
            elif self.level.lvl == 10:
                data = [20, 14, 400, 650, 150, 349, "+", 4]
            elif self.level.lvl == 11:
                data = [20, 14, 500, 850, 100, 149, "+", 4]
        elif self.mainloop.m.game_variant == 1:
            self.points = self.level.lvl
            self.level.lvl_count = 11
            if self.level.lvl == 1:  #subtraction  - ch1
                data = [20, 14, 3, 10, 1, 0, "-", 2]
            elif self.level.lvl == 2:
                data = [20, 14, 5, 10, 3, 0, "-", 2]
            elif self.level.lvl == 3:
                data = [20, 14, 10, 15, 3, 0, "-", 2]
            elif self.level.lvl == 4:
                data = [20, 14, 15, 20, 5, 0, "-", 2]
            elif self.level.lvl == 5:
                data = [20, 14, 20, 49, 9, 0, "-", 2]
            elif self.level.lvl == 6:
                data = [20, 14, 49, 99, 9, 0, "-", 2]
            elif self.level.lvl == 7:
                data = [20, 14, 100, 250, 30, 0, "-", 4]
            elif self.level.lvl == 8:
                data = [20, 14, 100, 250, 30, 0, "-", 4]
            elif self.level.lvl == 9:
                data = [20, 14, 100, 250, 30, 0, "-", 4]
            elif self.level.lvl == 10:
                data = [20, 14, 250, 499, 50, 0, "-", 4]
            elif self.level.lvl == 11:
                data = [20, 14, 499, 999, 99, 0, "-", 4]
        elif self.mainloop.m.game_variant == 2:
            self.points = self.level.lvl * 2
            self.level.lvl_count = 7
            if self.level.lvl > 7:
                self.level.lvl = 7
            if self.level.lvl == 1:  #multiplication  - ch2
                data = [20, 14, 1, 3, 1, 3, "*", 2]
            elif self.level.lvl == 2:
                data = [20, 14, 1, 9, 1, 2, "*", 2]
            elif self.level.lvl == 3:
                data = [20, 14, 2, 6, 2, 6, "*", 2]
            elif self.level.lvl == 4:
                data = [20, 14, 2, 7, 3, 7, "*", 2]
            elif self.level.lvl == 5:
                data = [20, 14, 2, 9, 2, 9, "*", 2]
            elif self.level.lvl == 6:
                data = [20, 14, 2, 15, 2, 15, "*", 4]
            elif self.level.lvl == 7:
                data = [20, 14, 2, 20, 2, 20, "*", 4]
        elif self.mainloop.m.game_variant == 3:
            self.points = self.level.lvl * 2
            self.level.lvl_count = 7
            if self.level.lvl > 7:
                self.level.lvl = 7
            if self.level.lvl == 1:  #division - ch3
                data = [20, 14, 1, 3, 1, 3, "/", 2]
            elif self.level.lvl == 2:
                data = [20, 14, 1, 9, 1, 2, "/", 2]
            elif self.level.lvl == 3:
                data = [20, 14, 2, 6, 2, 6, "/", 2]
            elif self.level.lvl == 4:
                data = [20, 14, 2, 7, 3, 7, "/", 2]
            elif self.level.lvl == 5:
                data = [20, 14, 2, 9, 2, 9, "/", 2]
            elif self.level.lvl == 6:
                data = [20, 14, 2, 15, 2, 15, "/", 4]
            elif self.level.lvl == 7:
                data = [20, 14, 2, 20, 2, 20, "/", 4]
        #stretch width to fit the screen size
        data[0] = self.get_x_count(data[1], even=True)
        if data[0] < 20:
            data[0] = 20
        self.data = data

        self.layout.update_layout(data[0], data[1])
        scale = self.layout.scale
        self.board.level_start(data[0], data[1], scale)

        self.num_list = []
        self.num_list2 = []
        #self.solution = []

        #for i in range(1):
        if data[6] == "+":
            first_num = random.randrange(data[2], data[3] + 1)
            second_num = random.randrange(data[4], data[5] + 1)
            self.solution = first_num + second_num

        elif data[6] == "-":
            first_num = random.randrange(data[2], data[3] + 1)
            second_num = random.randrange(data[4], first_num - 1)
            self.solution = first_num - second_num

        elif data[6] == "*":
            first_num = random.randrange(data[2], data[3] + 1)
            second_num = random.randrange(data[4], data[5] + 1)
            self.solution = first_num * second_num

        elif data[
                6] == "/":  #reversed multiplication - looking for the first factor
            first = random.randrange(data[2], data[3] + 1)
            second_num = random.randrange(data[4], data[5] + 1)
            first_num = first * second_num
            self.solution = first

        self.num_list.append(first_num)
        self.num_list2.append(second_num)

        #self.shuffled = self.solution[:]
        #random.shuffle(self.shuffled)

        #create objects
        if data[6] == "*":
            operator = chr(215)
        elif data[6] == "/":
            operator = chr(247)
        else:
            operator = data[6]

        x = (data[0] - 12) // 2
        y = 1
        i = 0

        scheme = "white"
        if self.mainloop.scheme is not None:
            if self.mainloop.scheme.dark:
                scheme = "black"
                img_bg_col = (0, 0, 0)
        img_src0 = os.path.join("schemes", scheme, "robot0.png")
        img_src1 = os.path.join("schemes", scheme, "robot1.png")

        self.board.add_unit(x, y, 5, 5, classes.board.Label,
                            str(self.num_list[i]), color1, "", 21)
        self.board.add_unit(x + 5, y, 2, 5, classes.board.Label, operator,
                            color1, "", 21)
        self.board.add_unit(x + 7, y, 5, 5, classes.board.Label,
                            str(self.num_list2[i]), color1, "", 21)

        self.board.add_unit(x - 4, y, 4, 5, classes.board.ImgShip, "", color1,
                            img_src0)
        self.board.add_unit(x + 7 + 5, y, 4, 5, classes.board.ImgShip, "",
                            color1, img_src1)

        #adding the edit field for the asnwer
        self.board.add_unit(x + 3, y + 6, 6, 2, classes.board.Letter, "",
                            color1, "", 21)
        self.home_square = self.board.ships[-1]
        self.home_square.immobilize()
        self.home_square.set_outline(color3, 5)
        """
        #adding possible answers
        if self.solution < 7:
            answers = [i for i in range(7)]
        else:
            shift = random.randrange(0,7)
            answers = [i for i in range(self.solution-shift,self.solution-shift+7)]
        for i in range(7):
            self.board.add_unit(x-1+i*2,y+5,2,2,classes.board.Letter,str(answers[i]),color1,"",0)
            self.board.ships[-1].immobilize()
        """
        #self.board.add_unit(x+2,y,1,1,classes.board.Label,"=",color1,"",data[7])
        #self.board.add_door(x+3,y,1,1,classes.board.Door,"",color1,"")
        #self.board.units[-1].door_outline = True
        #self.board.add_unit(x+5,y,1,1,classes.board.Letter,str(self.shuffled[i]),color2,"",data[7])
        #self.board.ships[-1].audible = False
        #self.board.ships[-1].readable = False
        #self.outline_all(1,1)
        """
        #calculating positions for lights around the task
        fx1 = [x+5 - i for i in range(0,6)] + [x-1 for i in range(5)] + [x + i for i in range(0,6)]
        fx2 = [x+i for i in range(6,12)] + [x+12 for i in range(5)] + [x+12 - i for i in range(1,7)]
        fy0 = [y-1 for i in range(7)] + [y + i for i in range(0,3)] + [y+3 for i in range(7)] 
        #fh0 = [85 - i for i in range(0,85,5)]
        fh0 = [68 - i for i in range(0,68,4)]
        #adding the lights
        for i in range(17):
            bg_color = ex.hsv_to_rgb(fh0[i],255,255)
            self.board.add_unit(fx1[i],fy0[i],1,1,classes.board.Label,"",bg_color,"",2)
            self.board.units[-1].decolorable = False
            self.board.units[-1].bg_color = bg_color
            
        for i in range(17):
            bg_color = ex.hsv_to_rgb(fh0[i],255,255)
            self.board.add_unit(fx2[i],fy0[i],1,1,classes.board.Label,"",bg_color,"",2)
            self.board.units[-1].decolorable = False
            self.board.units[-1].bg_color = bg_color
        """
        #y += 1

        #for i in range(2,15,3):
        #    self.board.all_sprites_list.move_to_front(self.board.units[i])
        for each in self.board.units:
            each.font_color = color3
        for each in self.board.ships:
            each.font_color = color3
Пример #50
0
    def create_game_objects(self, level=1):
        self.allow_unit_animations = False
        self.allow_teleport = False
        self.board.decolorable = False
        self.vis_buttons = [1, 1, 1, 1, 1, 1, 1, 1, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.board.draw_grid = False
        s = 100
        v = 255
        h = random.randrange(0, 255, 5)
        white = (255, 255, 255)
        if self.mainloop.scheme is None:
            color0 = ex.hsv_to_rgb(h, 40, 230)  # highlight 1
            instr_font_col = ex.hsv_to_rgb(h, 255, 140)
            font_col = (0, 0, 0)
        else:
            font_col = self.mainloop.scheme.u_font_color
            if self.mainloop.scheme.dark:
                white = (0, 0, 0)
                color0 = (0, 0, 10)
            else:
                color0 = (254, 254, 255)
            instr_font_col = font_col
        # setting level variable
        # data = [x_count, y_count, number_count, top_limit, ordered]
        if self.level.lvl == 1:
            data = [13, 9, 5, 3, 2]
        elif self.level.lvl == 2:
            data = [13, 9, 8, 3, 3]
        elif self.level.lvl == 3:
            data = [12, 9, 7, 4, 2]
        elif self.level.lvl == 4:
            data = [12, 9, 11, 4, 3]
        elif self.level.lvl == 5:
            data = [12, 9, 15, 4, 4]
        elif self.level.lvl == 6:
            data = [13, 9, 9, 5, 2]
        elif self.level.lvl == 7:
            data = [13, 9, 14, 5, 3]
        elif self.level.lvl == 8:
            data = [13, 9, 19, 5, 4]
        elif self.level.lvl == 9:
            data = [13, 9, 24, 5, 5]
        elif self.level.lvl == 10:
            data = [12, 9, 11, 6, 2]
        elif self.level.lvl == 11:
            data = [12, 9, 17, 6, 3]
        elif self.level.lvl == 12:
            data = [12, 9, 23, 6, 4]
        elif self.level.lvl == 13:
            data = [12, 9, 29, 6, 5]
        elif self.level.lvl == 14:
            data = [12, 9, 35, 6, 6]

        self.points = (data[3] * data[4]) // 2
        self.chapters = [1, 3, 6, 10, 14]
        # rescale the number of squares horizontally to better match the screen width
        m = data[0] % 2
        if m == 0:
            data[0] = self.get_x_count(data[1], even=True)
        else:
            data[0] = self.get_x_count(data[1], even=False)

        self.data = data
        self.layout.update_layout(data[0], data[1])
        self.board.level_start(data[0], data[1], self.layout.scale)

        self.choice_list = [x for x in range(1, data[2] + 1)]
        self.shuffled = self.choice_list[:]
        random.shuffle(self.shuffled)
        """
        If the grid size is odd, then the number of inversions in a solvable situation are even.
        If the grid size is even, and the blank is on an odd row (first, third etc), then the number of inversions in a solvable situation are odd.
        If the grid size is even, and the blank is on an even row (second, fourth etc), then the number of inversions in a solvable situation are even. 
        """
        inversions = ex.inversions(self.shuffled)
        if inversions % 2 != 0:  # if number of inversions is odd it is unsolvable
            # in unsolvable combinations swapping 2 squares will make it solvable
            temp = self.shuffled[0]
            self.shuffled[0] = self.shuffled[1]
            self.shuffled[1] = temp

        h1 = (data[1] - data[4]) // 2  # height of the top margin
        h2 = data[1] - h1 - data[4] - 1  # height of the bottom margin minus 1 (game label)
        w2 = (data[0] - data[3]) // 2  # side margin width
        self.check = [h1, h2, w2]

        self.board.add_door(w2, h1, data[3], data[4], classes.board.Door, "", white, "")
        # create table to store 'binary' solution
        # find position of first door square
        x = w2
        y = h1
        self.mini_grid = []
        # add objects to the board
        line = []
        h_start = random.randrange(0, 155, 5)
        h_step = 100 // (data[2])
        for i in range(data[2]):
            if self.mainloop.scheme is None:
                h = (h_start + (self.shuffled[i] - 1) * h_step)
                number_color = ex.hsv_to_rgb(h, s, v)  # highlight 1
            else:
                number_color = color0
            caption = str(self.shuffled[i])
            self.board.add_unit(x, y, 1, 1, classes.board.Letter, caption, number_color, "", 2)

            self.board.ships[-1].readable = False
            if self.mainloop.scheme is None:
                self.board.ships[-1].font_color = ex.hsv_to_rgb(h, 255, 140)
            else:
                self.board.ships[-1].font_color = font_col

            line.append(i)
            x += 1
            if x >= w2 + data[3] or i == data[2] - 1:
                x = w2
                y += 1
                self.mini_grid.append(line)
                line = []
        if self.mainloop.scheme is not None:
            self.outline_all(font_col, 1)
        instruction = self.d["Re-arrange right"]
        self.board.add_unit(0, data[1] - 1, data[0], 1, classes.board.Letter, instruction, color0, "", 5)  # bottom 2
        self.board.ships[-1].font_color = instr_font_col
        self.board.ships[-1].immobilize()
        # if self.mainloop.scheme is not None:
        #    self.board.ships[-1].font_color = self.mainloop.scheme.u_font_color

        self.board.ships[-1].speaker_val = self.dp["Re-arrange right"]
        self.board.ships[-1].speaker_val_update = False
        if self.mainloop.scheme is None:
            self.outline_all(0, 1)
        # horizontal
        self.board.add_unit(0, 0, data[0], h1, classes.board.Obstacle, "", white, "", 7)  # top
        self.board.add_unit(0, h1 + data[4], data[0], h2, classes.board.Obstacle, "", white, "", 7)  # bottom 1
        # side obstacles
        self.board.add_unit(0, h1, w2, data[4], classes.board.Obstacle, "", white, "", 7)  # left
        self.board.add_unit(w2 + data[3], h1, w2, data[4], classes.board.Obstacle, "", white, "", 7)  # right

        self.board.all_sprites_list.move_to_front(self.board.units[0])
Пример #51
0
    def create_game_objects(self, level=1):
        self.board.draw_grid = False
        self.board.decolorable = False
        self.vis_buttons = [1, 1, 1, 1, 1, 0, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)
        if self.mainloop.scheme is None:
            s = 100
            v = 255
            h = random.randrange(0, 255, 5)
            color0 = ex.hsv_to_rgb(h, 40, 255)  # highlight 1
            color1 = ex.hsv_to_rgb(h, 70, v)  # highlight 2
            color2 = ex.hsv_to_rgb(h, s, v)  # normal color
            color3 = ex.hsv_to_rgb(h, 230, 100)
            task_bg_color = (255, 255, 255)
            font_color = ex.hsv_to_rgb(h, 255, 140)
            task_font_color = (0, 0, 0)
        else:
            s = 150
            v = 225
            h = 170
            color0 = ex.hsv_to_rgb(h, 40, 255)  # highlight 1
            color1 = ex.hsv_to_rgb(h, 70, v)  # highlight 2
            color2 = ex.hsv_to_rgb(h, s, v)  # normal color
            color3 = ex.hsv_to_rgb(h, 230, 100)
            task_bg_color = self.mainloop.scheme.u_color
            task_font_color = self.mainloop.scheme.u_font_color
            font_color = self.mainloop.scheme.u_font_color
        white = (255, 255, 255)

        # data = [x_count, y_count, range_from, range_to, max_sum_range, image]
        self.points = 1
        if self.level.lvl == 1:
            data = [23, 9]
        elif self.level.lvl == 2:
            data = [23, 9]
            color1 = color0
        elif self.level.lvl == 3:
            data = [23, 9]
            color1 = color2 = color0
        elif self.level.lvl == 4:
            data = [23, 9]
            color1 = color2 = color0
        elif self.level.lvl == 5:
            data = [23, 9]
            color0 = font_color
            self.points = 2
        elif self.level.lvl == 6:
            data = [23, 9]
            color2 = color1 = color0 = font_color
            color3 = (40, 40, 40)
            self.points = 3
        self.data = data

        self.board.set_animation_constraints(10, data[0], 0, data[1])
        self.board.level_start(data[0], data[1], self.layout.scale)

        num1 = random.randrange(1, 10)
        num2 = random.randrange(1, 10)
        self.solution = [num1, num2, num1 * num2]
        self.digits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
        unique = set()
        for i in range(1, 10):
            for j in range(1, 10):
                if self.level.lvl == 1 and (i == num1 and j == num2):
                    color = color0
                elif self.level.lvl == 1 and (j == num1 and i == num2):
                    color = color2
                elif (i == num1 and j == num2) or (j == num1 and i == num2):
                    color = color0
                elif i == num1 or j == num2:
                    color = color1
                elif (self.level.lvl == 2
                      or self.level.lvl == 5) and (i == num2 or j == num1):
                    color = color1
                else:
                    color = color2
                mul = i * j
                unique.add(mul)
                caption = str(mul)
                self.board.add_unit(i - 1, j - 1, 1, 1, classes.board.Label,
                                    caption, color, "", 2)
                self.board.units[-1].font_color = font_color

        self.board.add_unit(9, 0, 1, 9, classes.board.Obstacle, "", color3)
        unique = sorted(unique)
        # draw outline with selectable numbers
        self.multi = dict()
        if self.mainloop.scheme is None:
            s = 140
        else:
            s = 80
        v = 255
        h = 7
        x = 11
        y = 0
        for i in range(36):
            if i < 9:
                x += 1
            elif i == 9:
                x = 22
            elif i < 18:
                y += 1
            elif i == 18:
                x = 20
            elif i < 27:
                x -= 1
            elif i == 27:
                x = 10
            elif i <= 36:
                y -= 1
            color = ex.hsv_to_rgb(h * i, s, v)
            self.multi[str(unique[i])] = i
            caption = str(unique[i])
            self.board.add_unit(x, y, 1, 1, classes.board.Letter, caption,
                                color, "", 2)
            self.board.ships[-1].font_color = ex.hsv_to_rgb(h * i, 255, 140)
            self.board.ships[-1].audible = False
            if self.lang.lang == "he":
                sv = self.lang.n2spk(unique[i])
                self.board.ships[-1].speaker_val = sv
                self.board.ships[-1].speaker_val_update = False
        x = 14
        y = 4
        captions = [str(num1), chr(215), str(num2), "="]
        if self.level.lvl < 4:
            color = self.board.ships[self.multi[str(
                self.solution[2])]].initcolor
        else:
            color = (255, 255, 255)  # color4
        for i in range(4):
            self.board.add_unit(x + i, y, 1, 1, classes.board.Label,
                                captions[i], color, "", 2)
            if self.level.lvl < 4:
                self.board.units[-1].font_color = self.board.ships[self.multi[
                    str(self.solution[2])]].font_color

        self.outline_all(0, 1)

        self.board.add_door(18,
                            y,
                            1,
                            1,
                            classes.board.Door,
                            "",
                            task_bg_color,
                            "",
                            font_size=2)
        self.home_square = self.board.units[86]
        self.home_square.checkable = True
        self.home_square.init_check_images()
        self.home_square.door_outline = True
        if self.level.lvl < 4:
            self.home_square.font_color = self.board.ships[self.multi[str(
                self.solution[2])]].font_color
        else:
            self.home_square.font_color = task_font_color

        self.board.all_sprites_list.move_to_front(self.home_square)
Пример #52
0
    def create_game_objects(self, level = 1):
        self.active_tool = 0
        self.active_letter = "Α"
        self.active_word = "Άλογο"
        self.var_brush = 1
        s = random.randrange(30, 80)
        v = random.randrange(200, 255)
        h = random.randrange(0, 255)
        letter_color = ex.hsv_to_rgb(h,s,v)
        if self.mainloop.scheme is not None:
            self.bg_color = self.mainloop.scheme.u_color
            color = self.mainloop.scheme.u_color
        else:
            self.bg_color = [255,255,255]
            color = [255,255,255]

        data = [35,24,0,6]

        font_size = 13
        font_size2 = 14
        self.brush_size = data[3]

        #stretch width to fit the screen size
        max_x_count = self.get_x_count(data[1],even=None)
        if max_x_count > 35:
            data[0] = max_x_count
        self.data = data

        self.vis_buttons = [0,0,0,0,1,0,1,0,0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0],data[1])
        scale = self.layout.scale
        self.board.level_start(data[0],data[1],scale)

        #canvas
        self.board.add_unit(10,0,data[0]-16,data[1],classes.board.Letter,"",color,"",font_size)
        self.canvas_block = self.board.ships[0]
        self.canvas_block.set_outline([0,54,229],1)

        self.canvas_block.font3 = self.board.font_sizes[font_size2]

        images = ["paint_pencil.png","paint_brush.png","paint_wide_brush.png","paint_rect.png","paint_circle.png","paint_eraser.png","paint_bucket.png"]
        x=0
        y=0
        i_chr = 65
        alphabet = self.lang.alphabet_uc[:]
        alphabet.extend(self.lang.alphabet_lc)

        for i in range(0,60):
            if i < 48:
                caption = alphabet[i]
            else:
                caption = str(i-47)
            self.board.add_unit(x,y,2,2,classes.board.Letter,caption,letter_color,"",0)
            y += 2
            i_chr += 1
            if y > 23:
                y = 0
                x += 2
        self.board.add_door(0,0,2,2,classes.board.Door,"",color,"")
        self.board.add_door(data[0]-1,15,1,1,classes.board.Door,"",color,"")
        tool_len = len(self.board.ships)

        h = 0
        s = 250
        v = 70
        number_of_col_per_hue = 6#number_of_colors // number_of_hues
        #if number_of_col_per_hue > 3:
        v_num = (255-v)//(number_of_col_per_hue)
        #greyscale
        grey_num = 6 #number_of_colors+2 - number_of_hues * number_of_col_per_hue
        if grey_num > 1:
            grey_v_num = (255 // (grey_num-1))
        else:
            grey_v_num = 0
        grey_count = 0
        for j in range(0,data[1]):
            for i in range(data[0]-6, data[0]):
                color2 = ex.hsv_to_rgb(h,s,v)
                self.board.add_unit(i,j,1,1,classes.board.Ship,"",color2,"",2)
                if h < 249:
                    if i < data[0]-1:
                        v += v_num
                    else:
                        v = 70
                        s = 250
                        h += 11
                if h > 248:
                    if grey_count == 0:
                        s = 0
                        v = 0
                        grey_count += 1
                    else:
                        v += grey_v_num

        self.active_color = self.board.ships[161].initcolor
        self.size_display = self.board.units[0]
        self.tool_door = self.board.units[-2]
        self.color_door = self.board.units[-1]
        self.btn_down = False

        #points
        self.p_first = [0,0]
        self.p_last = [0,0]
        self.p_prev = [0,0]
        self.p_current = [0,0]
        self.outline_all(1,1)
        doors = [self.tool_door,self.color_door]
        for each in doors:
            each.door_outline = True
            each.perm_outline_color = [255,0,0]
            self.board.all_sprites_list.move_to_front(each)

        for each in self.board.ships:
            each.outline = False
            each.immobilize()

        self.canvas = pygame.Surface([self.canvas_block.grid_w*self.board.scale, self.canvas_block.grid_h*self.board.scale-1])
        self.canvas.fill(self.canvas_block.initcolor)
        self.paint_bg_letter()
        self.canvas_org = self.canvas.copy() #pygame.Surface([self.canvas_block.grid_w*self.board.scale, self.canvas_block.grid_h*self.board.scale-1])
Пример #53
0
    def create_game_objects(self, level=1):
        #create non-movable objects
        self.active_tool = 0
        self.active_letter = "А"
        self.active_word = ""
        self.var_brush = 1
        s = random.randrange(30, 80)
        v = random.randrange(200, 255)
        h = random.randrange(0, 255)
        letter_color = ex.hsv_to_rgb(h, s, v)
        if self.mainloop.scheme is not None:
            self.bg_color = self.mainloop.scheme.u_color
            color = self.mainloop.scheme.u_color
        else:
            self.bg_color = [255, 255, 255]
            color = [255, 255, 255]

        data = [35, 22, 0, 8]

        font_size = 13
        font_size2 = 14
        self.brush_size = data[3]

        #stretch width to fit the screen size
        max_x_count = self.get_x_count(data[1], even=None)
        if max_x_count > 35:
            data[0] = max_x_count
        self.data = data

        self.vis_buttons = [0, 0, 0, 0, 1, 0, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0], data[1])
        scale = self.layout.scale
        self.board.level_start(data[0], data[1], scale)

        #canvas
        self.board.add_unit(12, 0, data[0] - 18, data[1], classes.board.Letter,
                            "", color, "", font_size)
        self.canvas_block = self.board.ships[0]
        self.canvas_block.set_outline([0, 54, 229], 1)

        self.canvas_block.font3 = self.board.font_sizes[font_size2]

        x = 0
        y = 0
        i_chr = 65
        alphabet = self.lang.alphabet_uc[:]
        alphabet.extend(self.lang.alphabet_lc)

        for i in range(0, 66):
            caption = alphabet[i]
            self.board.add_unit(x, y, 2, 2, classes.board.Letter, caption,
                                letter_color, "", 0)
            y += 2
            i_chr += 1
            if y > 20:
                y = 0
                x += 2
        self.board.add_door(0, 0, 2, 2, classes.board.Door, "", color, "")
        self.board.add_door(data[0] - 1, 15, 1, 1, classes.board.Door, "",
                            color, "")
        tool_len = len(self.board.ships)

        self.word_list = [
            'Арбуз', 'Банки', 'Вода', 'Горы', 'Дом', 'Еда', 'Ёлка', 'Жук',
            'Зебра', 'Игра', 'Йога', 'Коза', 'Лист', 'Муха', 'Нить', 'Орех',
            'Пять', 'Рука', 'Собака', 'Танк', 'Утка', 'Флаг', 'Хлеб', 'Цвет',
            'Чай', 'Шар', 'Щека', '', '', '', 'Экран', 'Юбка', 'Яма', 'арбуз',
            'банки', 'вода', 'горы', 'дом', 'еда', 'ёлка', 'жук', 'зебра',
            'игра', 'йога', 'коза', 'лист', 'муха', 'нить', 'орех', 'пять',
            'рука', 'собака', 'танк', 'утка', 'флаг', 'хлеб', 'цвет', 'чай',
            'шар', 'щека', 'объём', 'горы', 'соль', 'экран', 'юбка', 'яма'
        ]

        self.active_word = self.word_list[0]
        h = 0
        s = 250
        v = 70
        number_of_col_per_hue = 6
        v_num = (255 - v) // (number_of_col_per_hue)
        #greyscale
        grey_num = 6
        if grey_num > 1:
            grey_v_num = (255 // (grey_num - 1))
        else:
            grey_v_num = 0
        grey_count = 0
        for j in range(0, data[1]):
            for i in range(data[0] - 6, data[0]):
                color2 = ex.hsv_to_rgb(h, s, v)
                self.board.add_unit(i, j, 1, 1, classes.board.Ship, "", color2,
                                    "", 2)
                if h < 249:
                    if i < data[0] - 1:
                        v += v_num
                    else:
                        v = 70
                        s = 250
                        h += 12
                if h > 248:
                    if grey_count == 0:
                        s = 0
                        v = 0
                        grey_count += 1
                    else:
                        v += grey_v_num

        self.active_color = self.board.ships[161].initcolor
        self.size_display = self.board.units[0]
        self.tool_door = self.board.units[-2]
        self.color_door = self.board.units[-1]
        self.btn_down = False

        #points
        self.p_first = [0, 0]
        self.p_last = [0, 0]
        self.p_prev = [0, 0]
        self.p_current = [0, 0]
        self.outline_all(1, 1)
        doors = [self.tool_door, self.color_door]
        for each in doors:
            each.door_outline = True
            each.perm_outline_color = [255, 0, 0]
            self.board.all_sprites_list.move_to_front(each)

        for each in self.board.ships:
            each.outline = False
            each.immobilize()

        self.canvas = pygame.Surface([
            self.canvas_block.grid_w * self.board.scale,
            self.canvas_block.grid_h * self.board.scale - 1
        ])
        self.canvas.fill(self.canvas_block.initcolor)
        self.paint_bg_letter()
        self.canvas_org = self.canvas.copy()
Пример #54
0
    def create_game_objects(self, level=1):
        # create non-movable objects
        self.board.draw_grid = False
        s = random.randrange(30, 80)
        v = random.randrange(200, 255)
        h = random.randrange(0, 225)
        self.letter_color = ex.hsv_to_rgb(h, s, v)
        font_color = ex.hsv_to_rgb(h, s, 75)
        font_colors = ((200, 0, 0), (20, 20, 20))
        outline_color = ex.hsv_to_rgb(h, s + 50, v - 50)

        if self.mainloop.scheme is not None:
            card_color = self.mainloop.scheme.u_color  # (0,0,0)#(255,255,255)#ex.hsv_to_rgb(h+10,s-25,v)
            if self.mainloop.scheme.dark:
                font_colors = ((200, 0, 0), (255, 255, 255))
        else:
            card_color = (255, 230, 255)

        if self.mainloop.m.game_variant == 0:
            phonics_seq = ["/a/", "/ae/", "/air/", "/ar/", "/e/", "/ee/", "/eer/", "/er/", "/i/", "/ie/", "/o/", "/oa/",
                           "/oi/", "/oo/ (short)", "/oo/ (long)", "/ou/", "/or/", "/u/", "/ue/", "/uh/", "/ur/"]
            phonics_words = [
                ["<1>sh<2>ip", "<1>sh<2>oe", "<2>je<3>lly<4>fi<1>sh", "<1>sh<2>rimp", "<1>sh<2>ark", "<1>sh<2>ore"],
                ["chimp", "church"], ["foot", "boot", "food"]]
            phonics_imgs = [
                [("transport", "ship.jpg"), ("clothes_n_accessories", "shoe.jpg"), ("animals", "jellyfish.jpg"),
                 ("animals", "shrimp.jpg"), ("animals", "shark.jpg"), ("nature", "shore.jpg")],
                [("clothes_n_accessories", "shoe.jpg"), ("clothes_n_accessories", "shoe.jpg")],
                [("clothes_n_accessories", "shoe.jpg"), ("clothes_n_accessories", "shoe.jpg"),
                 ("clothes_n_accessories", "shoe.jpg")]]
        elif self.mainloop.m.game_variant == 1:
            phonics_seq = ["/b/", "/c/, /k/", "/ch/", "/d/", "/f/", "/g/", "/h/", "/j/", "/ks/", "/l/", "/m/", "/n/",
                           "/ng/", "/p/", "/r/", "/s/", "/sh/", "/t/", "/th/", "/th/", "/v/", "/w/", "/y/", "/z/",
                           "/gz/", "/zh/"]
            phonics_words = [
                ["<1>sh<2>ip", "<1>sh<2>oe", "<2>je<3>lly<4>fi<1>sh", "<1>sh<2>rimp", "<1>sh<2>ark", "<1>sh<2>ore"],
                ["chimp", "church"], ["foot", "boot", "food"]]
            phonics_imgs = [
                [("transport", "ship.jpg"), ("clothes_n_accessories", "shoe.jpg"), ("animals", "jellyfish.jpg"),
                 ("animals", "shrimp.jpg"), ("animals", "shark.jpg"), ("nature", "shore.jpg")],
                [("clothes_n_accessories", "shoe.jpg"), ("clothes_n_accessories", "shoe.jpg")],
                [("clothes_n_accessories", "shoe.jpg"), ("clothes_n_accessories", "shoe.jpg"),
                 ("clothes_n_accessories", "shoe.jpg")]]

        self.abc_len = len(phonics_seq)
        if self.abc_len < 14:
            h = 13
            dv = 1
        elif self.abc_len < 27:
            h = 13
            dv = 2
        elif self.abc_len < 39:
            h = 13
            dv = 3
        else:
            h = int(math.ceil(self.abc_len / 3.0))
            dv = 3

        data = [16, h]
        # stretch width to fit the screen size
        x_count = self.get_x_count(data[1], even=True)
        if x_count < 16:
            data[0] = 16
        else:
            data[0] = x_count

        self.data = data

        self.vis_buttons = [0, 0, 0, 0, 1, 0, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0], data[1])
        scale = self.layout.scale
        self.board.level_start(data[0], data[1], scale)
        # self.prev_item = None
        # self.base26 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
        self.font_size = 17

        if self.lang.lang == "el":
            self.font_size = 16
        if self.lang.ltr_text:
            x = 0
        else:
            x = data[0] - 3
        y = 0

        for i in range(self.abc_len):
            caption = phonics_seq[i]
            self.board.add_unit(x, y, 3, 1, classes.board.Letter, caption, self.letter_color, "", 2)
            self.board.ships[i].readable = False
            self.board.ships[i].set_outline(outline_color, 1)
            y += 1
            if y >= data[1]:
                if i > 3 * data[1] - 3:
                    if self.lang.ltr_text:
                        x = 4
                    else:
                        x = data[0] - 6
                    y = 0
                else:
                    if self.lang.ltr_text:
                        x = 3
                    else:
                        x = data[0] - 4
                    y = 0
        if self.lang.ltr_text:
            x = (data[0] - 4 + 3 + 3) // 2
        else:
            x = (data[0] - 10) // 2

        y = 1
        ln = len(phonics_words[0])

        max_w = data[0] - (dv * 3 + 3 + 1)
        l = dv * 3 + 1
        if max_w > 7:
            w = 7
            # l = l + (max_w - w) // 2
        else:
            w = max_w
        self.board.add_unit(l, 0, data[0] - l - 1, 1, classes.board.Label, "/sh/", card_color, "", 0)
        for i in range(6):
            if i < ln:
                word = phonics_words[0][i]
                img_src = os.path.join('art4apps', phonics_imgs[0][i][0], phonics_imgs[0][i][1])
            # self.board.add_unit(l,y+i*2,2,2,classes.board.Label,img_src,card_color,"",2)
            self.board.add_unit(l + 2, y + i * 2, w, 2, classes.board.MultiColorLetters, word, card_color, "", 0)
            self.board.ships[-1].align = 1
            self.board.ships[-1].set_font_colors(font_colors[0], font_colors[1])
            self.board.add_unit(l, y + i * 2, 2, 2, classes.board.ImgShip, self.board.ships[-1].value, card_color,
                                img_src)

        for each in self.board.ships:
            each.immobilize()
            each.font_color = font_color
        for each in self.board.units:
            each.font_color = font_color

        self.active_item = self.board.ships[0]
        self.active_item.color = (255, 255, 255)
        self.prev_item = self.active_item
Пример #55
0
    def create_game_objects(self, level=1):
        self.vis_buttons = [1, 1, 1, 1, 1, 0, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.hand_id = 0
        self.hand_coords = [[], []]
        self.board.draw_grid = False

        if self.mainloop.scheme is not None:
            color1 = self.mainloop.scheme.color1  # bright side of short hand
            color3 = self.mainloop.scheme.color3  # inner font color
            color5 = self.mainloop.scheme.color5  # dark side of short hand
            color7 = self.mainloop.scheme.color7  # inner circle filling

            color2 = self.mainloop.scheme.color2  # bright side of long hand
            color4 = self.mainloop.scheme.color4  # ex.hsv_to_rgb(170,255,255)#outer font color
            color6 = self.mainloop.scheme.color6  # dark side of long hand
            color8 = self.mainloop.scheme.color8  # outer circle filling

            self.h_col = color5
            self.m_col = color6

            white = self.mainloop.scheme.u_color
            gray = (100, 100, 100)
        else:
            color1 = ex.hsv_to_rgb(225, 70, 230)
            color3 = ex.hsv_to_rgb(225, 255, 255)
            color5 = ex.hsv_to_rgb(225, 180, 240)
            color7 = ex.hsv_to_rgb(225, 10, 255)

            color2 = ex.hsv_to_rgb(170, 70, 230)
            color4 = ex.hsv_to_rgb(170, 255, 255)
            color6 = ex.hsv_to_rgb(170, 180, 240)
            color8 = ex.hsv_to_rgb(170, 10, 255)

            self.h_col = ex.hsv_to_rgb(225, 190, 220)
            self.m_col = ex.hsv_to_rgb(170, 190, 220)

            white = (255, 255, 255)
            gray = (100, 100, 100)

        transp = (0, 0, 0, 0)

        self.color3 = color3
        self.color4 = color4

        self.colors = [color1, color2]
        self.colors2 = [color3, color4]
        self.colors3 = [color5, color6]
        self.colors4 = [color7, color8]
        if self.level.lvl == 1:
            data = [
                19, 10, True, True, False, False, True, False, False, True,
                True, 15
            ]
            h_pool = range(1, 13)
            m_pool = range(0, 60, 15)
        elif self.level.lvl == 2:
            data = [
                19, 10, True, True, False, False, False, True, False, True,
                True, 15
            ]
            h_pool = range(1, 13)
            m_pool = range(0, 60, 5)
        elif self.level.lvl == 3:
            data = [
                19, 10, True, True, False, False, False, False, False, True,
                True, 15
            ]
            h_pool = range(1, 13)
            m_pool = range(0, 60)
        elif self.level.lvl == 4:
            data = [
                19, 10, True, True, False, False, False, False, False, False,
                True, 20
            ]
            h_pool = range(1, 13)
            m_pool = range(0, 60)
        elif self.level.lvl == 5:
            data = [
                19, 10, True, True, False, False, False, True, False, False,
                True, 20
            ]
            h_pool = range(1, 13)
            m_pool = range(0, 60)
        elif self.level.lvl == 6:
            data = [
                19, 10, True, True, False, False, True, False, False, False,
                True, 20
            ]
            h_pool = range(1, 13)
            m_pool = range(0, 60)
        elif self.level.lvl == 7:
            data = [
                19, 10, True, False, False, False, False, False, False, False,
                True, 25
            ]
            h_pool = range(1, 13)
            m_pool = range(0, 60)
        elif self.level.lvl == 8:
            data = [
                19, 10, True, False, False, True, False, False, False, False,
                True, 25
            ]
            h_pool = range(1, 13)
            m_pool = range(0, 60)

        # visual display properties
        self.show_outer_ring = data[2]
        self.show_minutes = data[3]
        self.show_24h = data[4]
        self.show_only_quarters_h = data[5]
        self.show_only_quarters_m = data[6]
        self.show_only_fives_m = data[7]
        self.show_roman = False
        self.show_only_spare_variable = data[8]
        self.show_highlight = data[9]
        self.show_hour_offset = data[10]

        self.level.games_per_lvl = data[11]

        tt = [random.choice(h_pool), random.choice(m_pool)]
        self.target_time = tt
        if self.mainloop.m.game_var2 == 0:
            self.text_string = self.lang.time2str(tt[0], tt[1])
        else:
            if self.lang.lang == "ru":
                self.text_string = self.lang.time2str_short(tt[0], tt[1])
            else:
                self.text_string = self.lang.time2str_short(tt[0], tt[1])
        self.time = [6, 0]
        self.tm = self.time[:]

        self.digits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]

        x_count = self.get_x_count(data[1], even=False)
        if x_count > data[0]:
            data[0] = x_count

        self.font_size = 0
        self.data = data

        self.layout.update_layout(data[0], data[1])
        self.board.level_start(data[0], data[1], self.layout.scale)

        gv = self.mainloop.m.game_variant

        self.size = self.board.scale * 10
        ans_offset = 10 + (data[0] - 15) // 2
        self.board.add_unit(10, 0, data[0] - 10, 2, classes.board.Label,
                            self.lang.d["Set_clock"], white, "", 2)
        self.board.units[-1].font_color = gray
        self.board.add_unit(10, 8, data[0] - 10, 2, classes.board.Label,
                            self.lang.d["Set_clock_instr"], white, "", 4)
        self.board.units[-1].font_color = gray

        self.center = [self.size // 2, self.size // 2]
        self.board.add_unit(0, 0, 10, 10, classes.board.Ship, "", white, "",
                            self.font_size)
        self.clock_canvas = self.board.ships[-1]
        self.board.active_ship = self.clock_canvas.unit_id
        self.clock_canvas.font = self.clock_canvas.board.font_sizes[2]
        self.clock_canvas.font2 = self.clock_canvas.board.font_sizes[7]
        self.clock_canvas.font3 = self.clock_canvas.board.font_sizes[26]
        self.clock_canvas.immobilize()

        self.canvas = pygame.Surface((self.size, self.size - 1))
        if self.mainloop.scheme is not None:
            self.canvas.fill(self.mainloop.scheme.u_color)
        else:
            self.canvas.fill((255, 255, 255))

        tint_h = self.colors3[0]
        tint_m = self.colors3[1]

        shrink = 0.72
        self.whs = int(self.size * shrink)
        self.hand_h = self.scalled_img(
            pygame.image.load(os.path.join('res', 'images',
                                           "clock_h.png")).convert_alpha(),
            self.whs, self.whs)
        self.hand_h.fill(tint_h, special_flags=pygame.BLEND_ADD)

        self.hand_m = self.scalled_img(
            pygame.image.load(os.path.join('res', 'images',
                                           "clock_m.png")).convert_alpha(),
            self.whs, self.whs)
        self.hand_m.fill(tint_m, special_flags=pygame.BLEND_ADD)
        self.pivot = [self.whs // 2, self.whs // 2]
        self.hands = [self.hand_h, self.hand_m]

        self.hands_vars()
        self.draw_hands()

        self.clock_canvas.hidden_value = [2, 3]  # numbers[i]
        self.clock_canvas.font_color = color2
        self.clock_canvas.painting = self.canvas.copy()

        # if gv < 3:
        top = 5
        top_offset = 1
        h = "??"
        m = "??"
        if self.lang.lang == "gr":
            h = ";;"
            m = ";;"
        if gv == 0:
            h = "%02d" % self.target_time[0]
            m = "%02d" % self.target_time[1]
        elif gv == 2:
            self.mainloop.sb.toggle_espeak(True)
            top = 6
            top_offset = 2
        self.board.add_unit(ans_offset + 1, top, 1, 1, classes.board.Label, h,
                            white, "", 0)
        self.ans_h = self.board.units[-1]
        self.ans_h.checkable = True
        self.ans_h.init_check_images()

        self.board.add_unit(ans_offset + 2, top, 1, 1, classes.board.Label,
                            ":", white, "", 0)
        self.board.add_unit(ans_offset + 3, top, 1, 1, classes.board.Label, m,
                            white, "", 0)
        self.ans_m = self.board.units[-1]
        self.ans_m.checkable = True
        self.ans_m.init_check_images()

        self.ans_h.immobilize()
        self.ans_m.immobilize()

        self.ans_h.font_color = color3
        self.ans_m.font_color = color4

        self.board.add_unit(ans_offset + 1,
                            top_offset + 3,
                            1,
                            1,
                            classes.board.ImgCenteredShip,
                            "",
                            transp,
                            img_src='nav_u_mts.png',
                            alpha=True)
        self.board.ships[-1].set_tint_color(self.h_col)
        self.h_plus = self.board.ships[-1]
        self.board.add_unit(ans_offset + 3,
                            top_offset + 3,
                            1,
                            1,
                            classes.board.ImgCenteredShip,
                            "",
                            transp,
                            img_src='nav_u_mts.png',
                            alpha=True)
        self.board.ships[-1].set_tint_color(self.m_col)
        self.m_plus = self.board.ships[-1]
        self.board.add_unit(ans_offset + 1,
                            top_offset + 5,
                            1,
                            1,
                            classes.board.ImgCenteredShip,
                            "",
                            transp,
                            img_src='nav_d_mts.png',
                            alpha=True)
        self.board.ships[-1].set_tint_color(self.h_col)
        self.h_min = self.board.ships[-1]
        self.board.add_unit(ans_offset + 3,
                            top_offset + 5,
                            1,
                            1,
                            classes.board.ImgCenteredShip,
                            "",
                            transp,
                            img_src='nav_d_mts.png',
                            alpha=True)
        self.board.ships[-1].set_tint_color(self.m_col)
        self.m_min = self.board.ships[-1]

        lst = [self.h_plus, self.h_min, self.m_plus, self.m_min]
        for each in lst:
            each.immobilize()
        if gv < 2:
            self.board.add_unit(10, 2, data[0] - 10, 2, classes.board.Letter,
                                self.text_string, white, "", 2)
            self.board.ships[-1].immobilize()
            self.board.ships[-1].font_color = gray
        if gv == 2:
            img_src = "speaker_icon.png"
            self.board.add_unit(ans_offset + 1,
                                2,
                                3,
                                3,
                                classes.board.ImgShip,
                                self.text_string,
                                white,
                                img_src,
                                alpha=True)
            self.board.ships[-1].immobilize()
            self.board.ships[-1].highlight = False
            self.board.ships[-1].outline_highlight = False
            self.board.ships[-1].animable = False
            self.board.ships[-1].outline = False

        if self.lang.lang in ["ru", "he"]:
            if self.lang.lang == "ru" and self.mainloop.m.game_var2 == 1:
                spk_txt = self.lang.time2spk_short(tt[0], tt[1])
            else:
                spk_txt = self.lang.time2spk(tt[0], tt[1])
            self.board.ships[-1].speaker_val = spk_txt
            self.board.ships[-1].speaker_val_update = False
Пример #56
0
    def create_game_objects(self, level = 1):
        self.vis_buttons = [0,1,1,1,1,1,1,0,0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.ai_enabled = False
        self.board.draw_grid = False
        s = random.randrange(100, 150, 5)
        v = random.randrange(230, 255, 5)
        h = random.randrange(0, 255, 5)
        bg_col = (255,255,255)
        if self.mainloop.scheme is not None:
            if self.mainloop.scheme.dark:
                bg_col = (0,0,0)
        color0 = ex.hsv_to_rgb(h,40,230) #highlight 1
        self.color2 = ex.hsv_to_rgb(h,255,170) #contours & borders
        self.font_color = self.color2

        white = (255,255,255)

        self.disp_counter = 0
        self.disp_len = 1
        lvl = 0

        if self.mainloop.m.game_variant == 0:
            self.level.lvl_count = 6

        if self.level.lvl > self.level.lvl_count:
            self.level.lvl = self.level.lvl_count
        self.points = 4
        if self.level.lvl == 1:
            data = [12,5,3,2,3]
            self.points = 2
        elif self.level.lvl == 2:
            data = [12,6,3,2,4]
            self.points = 3
        elif self.level.lvl == 3:
            data = [12,7,3,2,5]
        elif self.level.lvl == 4:
            data = [12,7,3,2,5]
        elif self.level.lvl == 5:
            data = [12,7,3,2,5]
        elif self.level.lvl == 6:
            data = [12,7,3,2,5]

        #rescale the number of squares horizontally to better match the screen width
        m = data[0] % 2
        if m == 0:
            x = self.get_x_count(data[1],even=True)
        else:
            x = self.get_x_count(data[1],even=False)

        if x > data[0]:
            data[0] = x

        self.data = data

        self.found = 0
        self.clicks = 0

        self.squares = self.data[3]*self.data[4]

        self.square_count = self.squares * 2 #self.data[3]*self.data[4]
        self.history = [None,None]

        self.layout.update_layout(data[0],data[1])
        self.board.level_start(data[0],data[1],self.layout.scale)
        texts1 = []
        texts2 = []

        if self.mainloop.m.game_variant == 0:
            if self.level.lvl == 1:#addition
                draw_data = [1,10,1,5,8]
            elif self.level.lvl == 2:
                draw_data = [1,15,1,5,8]
            elif self.level.lvl == 3:
                draw_data = [1,20,3,9,8]
            elif self.level.lvl == 4:
                draw_data = [20,50,3,9,8]
            elif self.level.lvl == 5:
                draw_data = [20,75,3,9,8]
            elif self.level.lvl == 6:
                draw_data = [1,99,3,9,8]

            while len(texts1) < self.square_count//2:
                num = random.randrange(draw_data[0],draw_data[1]+1)

                if str(num) not in texts1:
                    ns = self.lang.n2txt(num)
                    texts1.append(str(num))
                    if len(ns) < 20:
                        texts2.append(ns)
                    else:
                        texts2.append(self.lang.n2txt(num, twoliner = True))

        if self.mainloop.m.game_variant == 1:
            if self.level.lvl == 1:#addition
                draw_data = [1,5,1,5,6]
            elif self.level.lvl == 2:
                draw_data = [3,9,1,5,6]
            elif self.level.lvl == 3:
                draw_data = [5,15,3,9,7]
            elif self.level.lvl == 4:
                draw_data = [5,15,5,15,8]
            elif self.level.lvl == 5:
                draw_data = [15,55,5,35,9]
            elif self.level.lvl == 6:
                draw_data = [35,75,15,25,9]
            elif self.level.lvl == 7:
                draw_data = [55,99,55,99,9]
            while len(texts1) < self.square_count//2:
                first_num = random.randrange(draw_data[0],draw_data[1]+1)
                second_num = random.randrange(draw_data[2],draw_data[3]+1)
                my_sum = str(first_num + second_num)
                if my_sum not in texts1:
                    texts1.append(str(my_sum))
                    texts2.append("%d + %d" % (first_num, second_num))

        self.completed_mode = False
        if self.mainloop.m.game_variant in [4,5]:
            choice = [x for x in range(0,21)]
        else:
            choice = [x for x in range(0,self.square_count//2)]
        shuffled = choice[:]
        random.shuffle(shuffled)
        self.chosen = shuffled[0:self.square_count//2]
        self.chosen = self.chosen * 2

        h1=(data[1]-data[4])//2 #height of the top margin
        h2=data[1]-h1-data[4]#-1 #height of the bottom margin minus 1 (game label)
        w2=(data[0]-data[3]*4)//2 - 1 #side margin width

        x = w2
        y = h1
        small_slots = []
        for j in range(h1,data[1]-h2):
            for i in range(w2,w2+data[3]):
                small_slots.append([i,j])
        random.shuffle(small_slots)

        wide_slots = []
        for j in range(h1,data[1]-h2):
            for i in range(w2+data[3],data[0]-w2,4):
                wide_slots.append([i,j])
        random.shuffle(wide_slots)
        switch = self.square_count // 2
        for i in range(self.square_count):
            if self.mainloop.m.game_variant in [4,5]:
                if i < switch:
                    src = image_src1[self.chosen[i]]
                else:
                    src = image_src2[self.chosen[i-switch]]
                self.board.add_unit(slots[i][0],slots[i][1],1,1,classes.board.ImgShip,"",white,src)
            else:
                if i < switch:
                    caption = texts1[self.chosen[i]]
                    position_list = small_slots
                    pos = i
                    xw = 1
                else:
                    caption = texts2[self.chosen[i-switch]]
                    position_list = wide_slots
                    pos = i-switch
                    xw = 4
                self.board.add_unit(position_list[pos][0],position_list[pos][1],xw,1,classes.board.Letter,caption,color0,"",draw_data[4])
                self.board.ships[-1].font_color=self.font_color

            self.board.ships[i].immobilize()
            self.board.ships[i].readable = False
            self.board.ships[i].perm_outline = True
            self.board.ships[i].uncovered = False
        self.outline_all(self.color2,1)

        self.board.add_door(0,data[1]-1,data[0],1,classes.board.Door,"0/0",bg_col,"",font_size=3)
        self.counter = self.board.units[-1]
        self.counter.font_color = (80,80,80)
Пример #57
0
    def create_game_objects(self, level=1):
        self.allow_unit_animations = False
        self.allow_teleport = False
        s = random.randrange(150, 205, 5)
        v = random.randrange(150, 205, 5)
        h = random.randrange(0, 255, 5)
        color = ex.hsv_to_rgb(h, s, v)
        scheme = "white"
        if self.mainloop.scheme is not None:
            if self.mainloop.scheme.dark:
                scheme = "black"
        # data = [0:x_count, 1:y_count, 2:games_per_level, 3:bug_img, 4:level_maps]
        img1 = os.path.join("schemes", scheme, "mouse_77.png")
        img2 = os.path.join("schemes", scheme, "cheese_77.png")

        if self.level.lvl == 1:  # img_ 77x77
            data = [11, 7, 10]
        elif self.level.lvl == 2:
            data = [13, 9, 10]
        elif self.level.lvl == 3:
            data = [17, 11, 10]
        elif self.level.lvl == 4:
            data = [19, 13, 10]
        elif self.level.lvl == 5:
            data = [23, 15, 10]
        elif self.level.lvl == 6:
            data = [25, 17, 10]
        elif self.level.lvl == 7:
            data = [27, 19, 10]
        self.auto_checking = True

        # rescale the number of squares horizontally to better match the screen width
        x_count = self.get_x_count(data[1], even=False)
        if x_count > data[0]:
            data[0] = x_count

        self.data = data
        self.points = (data[0] + data[1]) // 5
        self.vis_buttons = [0, 1, 1, 1, 1, 1, 1, 0, 0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0], data[1])
        scale = self.layout.scale
        self.board.level_start(data[0], data[1], scale)

        self.mylaby = classes.laby.laby((data[0] + 1) // 2, (data[1] + 1) // 2, 0, 0, scale)
        self.mylaby.generate_laby()
        laby_grid = self.mylaby.labi_to_array()
        self.solution = [data[0] - 1, data[1] - 1]
        self.board.add_door(self.solution[0], self.solution[1], 1, 1, classes.board.Door, "", (255, 255, 255), img2)
        self.board.units[0].outline = False

        x = 0
        y = 0

        for j in range(data[1]):
            for i in range(data[0]):
                if laby_grid[j][i] == 1:
                    self.board.add_unit(i, j, 1, 1, classes.board.Obstacle, "", color)
        self.ships_count = len(self.board.ships)
        self.board.add_unit(x, y, 1, 1, classes.board.ImgShipRota, "", (255, 255, 255), img1)
        self.board.ships[0].outline = False
        self.board.ships[0].draggable = True
        self.board.ships[0].audible = False
        self.board.all_sprites_list.move_to_front(self.board.ships[0])
        self.board.active_ship = 0
        self.ship_id = 0
        self.board.moved = self.check_result
        self.drag = False
Пример #58
0
    def create_game_objects(self, level = 1):
        self.board.decolorable = False
        self.board.draw_grid = False

        color = (234,218,225)
        self.color = color
        self.grey = (200,200,200)
        self.font_hl = (100,0,250)

        self.task_str_color = ex.hsv_to_rgb(200,200,230)
        self.activated_col = self.font_hl
        white = (255,255,255)
        self.bg_col = white
        self.top_line = 3#self.board.scale//2
        if self.mainloop.scheme is not None:
            if self.mainloop.scheme.dark:
                self.bg_col = (0,0,0)
        self.level.games_per_lvl = 5
        if self.level.lvl == 1:
            rngs = [20,50,10,19]
            self.level.games_per_lvl = 3
        elif self.level.lvl == 2:
            rngs = [50,100,20,49]
            self.level.games_per_lvl = 3
        elif self.level.lvl == 3:
            rngs = [100,250,50,99]
            self.level.games_per_lvl = 3
        elif self.level.lvl == 4:
            rngs = [250,500,100,249]
        elif self.level.lvl == 5:
            rngs = [500,1000,100,499]
        elif self.level.lvl == 6:
            rngs = [700,1500,250,699]
        elif self.level.lvl == 7:
            rngs = [1500,2500,500,1499]
        elif self.level.lvl == 8:
            rngs = [2500,5000,1500,2499]
        elif self.level.lvl == 9:
            rngs = [5000,10000,2500,4999]
        elif self.level.lvl == 10:
            rngs = [10000,84999,5000,9999]
        data = [39,18]
        self.points = self.level.lvl
        #stretch width to fit the screen size
        x_count = self.get_x_count(data[1],even=None)
        if x_count > 39:
            data[0] = x_count

        self.data = data

        self.vis_buttons = [1,1,1,1,1,1,1,0,0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0],data[1])
        scale = self.layout.scale
        self.board.level_start(data[0],data[1],scale)
        self.n1 = random.randrange(rngs[0],rngs[1])
        self.n2 = random.randrange(rngs[2],rngs[3])
        self.sumn1n2 = self.n1-self.n2
        self.n1s = str(self.n1)
        self.n2s = str(self.n2)
        self.sumn1n2s = str(self.sumn1n2)
        self.n1sl = len(self.n1s)
        self.n2sl = len(self.n2s)
        self.sumn1n2sl =len(self.sumn1n2s)
        self.cursor_pos = 0
        self.correct = False
        self.carry1l = []
        self.carry10l = []
        self.resultl = []
        self.nums1l = []
        self.nums2l = []
        self.ship_id = 0
        self.digits = ["0","1","2","3","4","5","6","7","8","9"]

        if self.lang.lang == 'el':
            qm = ";"
        else:
            qm = "?"

        question = self.n1s + " - " + self.n2s + " = " + qm
        self.board.add_unit(1,0,data[0]-3-(max(self.n1sl,self.n2sl))*3 ,3,classes.board.Label,question,self.bg_col,"",21)
        self.board.units[-1].align = 1

        #borrow 1
        for i in range(self.n1sl - 1):
            self.board.add_unit(data[0]-6-i*3,0,1,1,classes.board.Label,"-",self.bg_col,"",0)
            self.board.add_unit(data[0]-5-i*3,0,1,1,classes.board.Letter,"",self.bg_col,"",1)
            self.carry1l.append(self.board.ships[-1])
            self.carry1l[-1].set_outline(self.grey, 2)
            self.carry1l[-1].pos_id = i
            self.board.units[-1].align = 2

        #add 10
        for i in range(self.n1sl - 1):
            self.board.add_unit(data[0]-3-i*3,1,1,1,classes.board.Label,"+",self.bg_col,"",0)
            self.board.add_unit(data[0]-2-i*3,1,1,1,classes.board.Letter,"",self.bg_col,"",1)
            self.carry10l.append(self.board.ships[-1])
            self.carry10l[-1].set_outline(self.grey, 2)
            self.carry10l[-1].pos_id = i
            self.board.units[-1].align = 2

        self.board.add_unit(data[0]-2-self.n1sl*3,0,2,1,classes.board.Label,"-1",self.bg_col,"",0)
        self.board.add_unit(data[0]-2-self.n1sl*3,1,2,1,classes.board.Label,"+10",self.bg_col,"",0)

        #first number
        for i in range(self.n1sl):
            self.board.add_unit(data[0]-3-i*3,2,3,3,classes.board.Label,self.n1s[-(i+1)],self.bg_col,"",21)
            self.nums1l.append(self.board.units[-1])
            self.nums1l[-1].font_color = self.grey
            self.nums1l[-1].pos_id = i
        #second number
        i = 0
        for i in range(self.n2sl):
            self.board.add_unit(data[0]-3-i*3,5,3,3,classes.board.Label,self.n2s[-(i+1)],self.bg_col,"",21)
            self.nums2l.append(self.board.units[-1])
            self.nums2l[-1].pos_id = i
        i += 1
        self.board.add_unit(data[0]-3-i*3,5,3,3,classes.board.Label,"-",self.bg_col,"",21)
        self.plus_label = self.board.units[-1]
        #line
        #line = "―" * (self.sumn1n2sl*2)
        self.board.add_unit(data[0]-self.sumn1n2sl*3,8,self.sumn1n2sl*3,1,classes.board.Label,"",self.bg_col,"",21)
        self.draw_hori_line(self.board.units[-1])
        #self.board.units[-1].text_wrap = False

        #result
        for i in range(self.sumn1n2sl):
            self.board.add_unit(data[0]-3-i*3,9,3,3,classes.board.Letter,"",self.bg_col,"",21)
            self.resultl.append(self.board.ships[-1])
            self.resultl[-1].set_outline(self.grey, 2)
            self.resultl[-1].pos_id = i

        self.resultl[0].set_outline(self.activated_col, 3)
        self.home_square = self.resultl[0]
        self.board.active_ship = self.home_square.unit_id

        self.activable_count = len(self.board.ships)
        for each in self.board.ships:
            each.immobilize()
        self.deactivate_colors()
        self.reactivate_colors()
Пример #59
0
    def create_game_objects(self, level=1):
        self.max_size = 99
        self.board.draw_grid = False

        if self.mainloop.scheme is not None:
            white = self.mainloop.scheme.u_color
            line_color = self.mainloop.scheme.u_font_color

            h1 = 170
            h2 = 40
            color1 = ex.hsv_to_rgb(h1, 255, 255)
            color2 = ex.hsv_to_rgb(h2, 75, 255)
            bd_color1 = ex.hsv_to_rgb(h1, 127, 155)
            bd_color2 = ex.hsv_to_rgb(h2, 127, 155)
        else:
            white = (255, 255, 255)
            line_color = (0, 0, 0)

            h1 = random.randrange(0, 255)
            h2 = (h1 + 128) % 255

            color1 = ex.hsv_to_rgb(h1, 150, 255)
            color2 = ex.hsv_to_rgb(h2, 40, 255)

            bd_color1 = ex.hsv_to_rgb(h1, 187, 200)
            bd_color2 = ex.hsv_to_rgb(h2, 100, 200)
        bd_color3 = ex.hsv_to_rgb((abs(h2 - h1)) // 2, 255, 150)

        ins_font_color = ex.hsv_to_rgb(h1, 255, 140)

        data = [24, 16]
        f_size = 12
        self.data = data

        #self.vis_buttons = [1, 0, 0, 0, 1, 1, 1, 0, 0]
        #self.vis_buttons = [1, 1, 1, 1, 1, 0, 1, 0, 1]
        self.vis_buttons = [0, 0, 0, 0, 1, 1, 1, 0, 1]

        self.mainloop.info.hide_buttonsa(self.vis_buttons)

        self.layout.update_layout(data[0], data[1])
        scale = self.layout.scale
        self.board.level_start(data[0], data[1], scale)
        # self.board.board_bg.initcolor = color
        # self.board.board_bg.color = color
        self.board.board_bg.update_me = True

        self.board.board_bg.line_color = (20, 20, 20)

        self.multiplier = 2
        num2 = random.randint(2, 10)
        num1 = random.randint(1, num2 - 1)
        self.numbers = [num1, num2]
        self.numbers2 = [num1 * self.multiplier, num2 * self.multiplier]
        #self.numbers_disp = [num1, num2]
        self.max_num = 11

        # add first fraction
        self.board.add_unit(0, 0, f_size, f_size, classes.board.Label, "",
                            white, "", 0)
        self.fraction_canvas = self.board.units[-1]
        self.fraction = classes.drw.fraction_hq.Fraction(
            1, self.board.scale * f_size, color1, color2, bd_color1, bd_color2,
            self.numbers, 2)
        # self.fraction.set_offset(15, 10)
        self.fraction.set_offset(0, 0)
        self.fraction_canvas.painting = self.fraction.get_canvas().copy()

        self.board.add_unit(3, f_size, 2, 2, classes.board.Letter, "    -",
                            white, "", 31)
        self.board.ships[-1].font_color = bd_color1
        self.board.add_unit(5, f_size, 2, 2, classes.board.Label,
                            str(self.numbers[0]), white, "", 31)
        self.nm1 = self.board.units[-1]
        #self.nm1.set_outline(color=[255, 0, 0], width=2)
        self.nm1.checkable = True
        self.nm1.init_check_images()
        self.nm1.set_fraction_lines(top=False, bottom=True, color=line_color)
        self.nm1.font_color = bd_color1
        self.board.add_unit(7, f_size, 2, 2, classes.board.Letter, "+    ",
                            white, "", 31)
        self.board.ships[-1].font_color = bd_color1
        self.board.add_unit(3, f_size + 2, 2, 2, classes.board.Letter, "    -",
                            white, "", 31)
        self.board.ships[-1].font_color = bd_color2
        self.board.add_unit(5, f_size + 2, 2, 2, classes.board.Label,
                            str(self.numbers[1]), white, "", 31)
        self.nm2 = self.board.units[-1]
        #self.nm2.set_outline(color=[255, 0, 0], width=2)
        self.nm2.checkable = True
        self.nm2.init_check_images()
        # self.nm2.set_fraction_lines(top=True, bottom=False, color=bd_color2)
        self.nm2.font_color = bd_color2
        self.board.add_unit(7, f_size + 2, 2, 2, classes.board.Letter, "+    ",
                            white, "", 31)
        self.board.ships[-1].font_color = bd_color2

        # add second fraction
        self.board.add_unit(f_size, 0, f_size, f_size, classes.board.Label, "",
                            white, "", 0)
        self.fraction2_canvas = self.board.units[-1]
        self.fraction2 = classes.drw.fraction_hq.Fraction(
            1, self.board.scale * f_size, color1, color2, bd_color1, bd_color2,
            self.numbers2, 2)
        # self.fraction2.set_offset(10, 5)
        self.fraction2.set_offset(0, 0)
        self.fraction2_canvas.painting = self.fraction2.get_canvas().copy()
        self.board.add_unit(f_size + 5, f_size, 2, 2, classes.board.Label,
                            str(self.numbers2[0]), white, "", 31)
        self.nm1a = self.board.units[-1]
        self.nm1a.checkable = True
        self.nm1a.init_check_images()
        self.nm1a.set_fraction_lines(top=False, bottom=True, color=line_color)
        self.nm1a.font_color = bd_color1

        self.board.add_unit(f_size + 5, f_size + 2, 2, 2, classes.board.Label,
                            str(self.numbers2[1]), white, "", 31)
        self.nm2a = self.board.units[-1]
        self.nm2a.checkable = True
        self.nm2a.init_check_images()
        self.nm2a.font_color = bd_color2

        #add multiplier
        self.board.add_unit(f_size + 1, f_size, 2, 4, classes.board.Letter,
                            "+    ", white, "", 31)
        self.board.ships[-1].font_color = bd_color3
        self.board.add_unit(f_size - 1, f_size, 2, 2, classes.board.Label,
                            chr(215) + str(self.multiplier), white, "", 31)
        self.nm3 = self.board.units[-1]
        # self.nm2.set_outline(color=[255, 0, 0], width=2)
        self.nm3.checkable = True
        self.nm3.init_check_images()
        self.nm3.set_fraction_lines(top=False, bottom=True, color=line_color)
        # self.nm2.set_fraction_lines(top=True, bottom=False, color=bd_color2)
        self.nm3.font_color = bd_color3

        self.board.add_unit(f_size - 1, f_size + 2, 2, 2, classes.board.Label,
                            chr(215) + str(self.multiplier), white, "", 31)
        self.nm3a = self.board.units[-1]
        # self.nm2.set_outline(color=[255, 0, 0], width=2)
        self.nm3a.checkable = True
        self.nm3a.init_check_images()
        # self.nm2.set_fraction_lines(top=True, bottom=False, color=bd_color2)
        self.nm3a.font_color = bd_color3

        self.board.add_unit(f_size - 3, f_size, 2, 4, classes.board.Letter,
                            "    -", white, "", 31)
        self.board.ships[-1].font_color = bd_color3

        for each in self.board.ships:
            each.readable = False
            each.immobilize()
Пример #60
0
    def create_game_objects(self, level = 1):
        self.vis_buttons = [1,1,1,1,1,1,1,1,0]
        self.mainloop.info.hide_buttonsa(self.vis_buttons)
        #data = [x_count, y_count, square_num, canvas_height, non_vertical, color_difference, games_per_level, mess_drawing_function]

        #setting up game flow / level dificulty
        if self.level.lvl == 1:
            data = [11,9,3,6,2,50,2,self.straight_lines]
        elif self.level.lvl == 2:
            data = [11,9,5,6,2,35,2,self.straight_lines]
        elif self.level.lvl == 3:
            data = [11,9,7,6,2,25,2,self.straight_lines]
        elif self.level.lvl == 4:
            data = [11,9,9,6,2,20,2,self.straight_lines]
        elif self.level.lvl == 5:
            data = [11,9,3,6,2,50,3,self.bezier_lines]
        elif self.level.lvl == 6:
            data = [11,9,5,6,2,35,3,self.bezier_lines]
        elif self.level.lvl == 7:
            data = [11,9,7,6,2,25,3,self.bezier_lines]
        elif self.level.lvl == 8:
            data = [11,9,9,6,2,20,3,self.bezier_lines]
        elif self.level.lvl == 9:
            data = [11,9,3,6,2,50,4,self.bezier2x_lines]
        elif self.level.lvl == 10:
            data = [11,9,5,6,2,35,4,self.bezier2x_lines]
        elif self.level.lvl == 11:
            data = [11,9,7,6,2,25,4,self.bezier2x_lines]
        elif self.level.lvl == 12:
            data = [11,9,9,6,1,20,4,self.bezier2x_lines]
        elif self.level.lvl == 13:
            data = [11,9,3,6,2,50,4,self.bezier3x_simplified]   
        elif self.level.lvl == 14:
            data = [11,9,5,6,2,35,4,self.bezier3x_simplified]
        elif self.level.lvl == 15:
            data = [11,9,9,6,1,20,4,self.random_lines]

        self.chapters = [1,5,9,13,15]
        self.points = self.level.lvl // 2 + 1
        #rescale the number of squares horizontally to better match the screen width
        x_count = self.get_x_count(data[1],even=False)
        if x_count > data[0]:
            data[0] = x_count
        
        self.data = data
        self.colors = []
        self.level.games_per_lvl = data[6]
        self.layout.update_layout(data[0],data[1])
        self.board.level_start(data[0],data[1],self.layout.scale)
        
        s = random.randrange(5, 20)
        v = random.randrange(240, 250)
        h = random.randrange(0, 255)
        self.line_col = (0,0,0)
        if self.mainloop.scheme is None:
            color = ex.hsv_to_rgb(h,s,v)
        else:
            color = self.mainloop.scheme.u_color
            if self.mainloop.scheme.dark:
                self.line_col = self.mainloop.scheme.u_font_color
        
        self.board.add_unit(0,1,data[0],data[3],classes.board.Obstacle,"",color)
        self.top_colors = []
        
        h = random.randrange(0, 75, 1)
        start_from = (data[0]-data[2])//2
        end_at = start_from+data[2]
        j=1
        for i in range(start_from, end_at):
            s = random.randrange(180, 250, 5)
            v = random.randrange(180, 250, 5)
            color = ex.hsv_to_rgb(h+(i-start_from)*data[5],s,v)
            self.colors.append(color)
            self.board.add_unit(i,0,1,1,classes.board.Label,str(j),color,"",3)
            self.board.add_unit(i,data[1]-1,1,1,classes.board.Letter,str(j),color,"",3)
            self.board.ships[-1].highlight = False
            self.board.ships[-1].outline_highlight = True
            
            j += 1
        self.colors_completed = self.colors[:]
        self.outline_all(0,1)
        
        self.draw_the_mess(data,start_from,end_at)
        
        for i in range(data[0]):
            if self.solution_positions[i] == 1:
                self.board.add_door(i,data[1]-2,1,1,classes.board.Door,"",color,"")
                self.board.units[-1].door_outline = True