def do_init(self, db): self.btn_exit = self.text_button(0, 0, 150, 40, "Exit") # self.btn_exit.set_color("lightblue", "black") self.btn_new_game = self.text_button(self.WIN_WIDTH - 150, 0, 150, 40, "Neues Spiel") x = 0 w = 200 self.players = [] for i, opt in enumerate([self.SETTING_PLAYER1, self.SETTING_PLAYER2]): profile_image = get_next_icon_filename(None) profile_image = self.get_setting(opt, profile_image) y = 100 name = self.text_button(x, y, w, 40, "") name.set_font(self.STATUS_FONT) y += 60 icon = get_icon(profile_image) btn = ImageButton(self.canvas, x, y, w, 150, icon) btn.set_color("black", "black") y += 150 now_lbl = self.text_button(x, y, w, 60, "0") now_lbl.set_font(self.STATUS_FONT) now_lbl.set_color("green", "black") y += 60 all_lbl = self.text_button(x, y, w, 60, "0") all_lbl.set_color("gray", "black") player = { "name": name, "profile": btn, "profile_image": profile_image, "now_lbl": now_lbl, "all_lbl": all_lbl, "all_cnt": 0, "now_cnt": 0, } self.players.append(player) x = self.WIN_WIDTH - w # explicitly set player profile images for player in self.players: self.__set_player_profile(player, player["profile_image"]) left = (self.WIN_WIDTH - Memory.SIZE * self.BTN_SIZE) / 2 self.buttons = [] x = left y = (self.WIN_HEIGHT - Memory.SIZE * self.BTN_SIZE) / 2 for i in range(Memory.SIZE ** 2): btn = ImageButton(self.canvas, x, y, self.BTN_SIZE, self.BTN_SIZE) btn.set_font(self.BIG_BUTTON_FONT) btn.set_color("gray", "#336699") self.buttons.append(btn) x += self.BTN_SIZE if ((i+1) % Memory.SIZE) == 0: x = left y += self.BTN_SIZE self.do_reset(None)
def do_init(self, db): self.player_started_game = 'X' self.btn_exit = self.text_button(0, 0, 150, 40, "Exit") # self.btn_exit.set_color("lightblue", "black") self.btn_new_game = self.text_button(self.WIN_WIDTH - 150, 0, 150, 40, "Neues Spiel") self.btn_opponent = self.text_button(self.WIN_WIDTH-40, self.WIN_HEIGHT-40, 40, 40, "M") x = 10 w = 200 self.players = {} for i, name in enumerate(["X", "O"]): profile_image = get_next_icon_filename(None) y = 100 name_lbl = self.text_button(x, y, w, 40, name) name_lbl.set_font(self.STATUS_FONT) y += 60 profile = ImageButton(self.canvas, x, y, w, 150) profile.set_color("black", "black") y += 150 cnt_lbl = self.text_button(x, y, w, 60, "0") cnt_lbl.set_font(self.STATUS_FONT) cnt_lbl.set_color("green", "black") self.players[name] = { "name": name_lbl, "cnt": 0, "cnt_lbl": cnt_lbl, "profile": profile, "profile_image": profile_image, "human_image": profile_image, "computer_image": "player_Computer.png", } x = self.WIN_WIDTH - w - 10 # explicitly set player profile images self.players["X"]["profile_image"] = self.get_setting(self.SETTING_PLAYER_X, self.players["X"]["profile_image"]) self.players["O"]["profile_image"] = self.get_setting(self.SETTING_PLAYER_O, self.players["O"]["profile_image"]) for _, player in self.players.items(): if player["profile_image"] is not None: self.__set_player_profile(player, player["profile_image"], True) # remis remis_cnt_lbl = self.text_button(self.WIN_WIDTH/2-w/2, self.WIN_HEIGHT - 50, w, 40, "0") remis_cnt_lbl.set_color("green", "black") remis_name_lbl = self.text_button(self.WIN_WIDTH/2-w/2, self.WIN_HEIGHT - 90, w, 40, "Unentschieden") self.players["U"] = { "cnt": 0, "cnt_lbl": remis_cnt_lbl, "name": remis_name_lbl, } left = (self.WIN_WIDTH - 3 * self.BTN_SIZE) / 2 self.lbl_status = self.text_button(self.WIN_WIDTH/2-150, 0, 300, 60, "") self.lbl_status.set_color("red", "black") self.lbl_status.set_font(self.STATUS_FONT) self.buttons = [] x = left y = (self.WIN_HEIGHT - 3 * self.BTN_SIZE) / 2 for i in range(1, 10): btn = self.text_button(x, y, self.BTN_SIZE, self.BTN_SIZE, "") btn.set_font(self.BIG_BUTTON_FONT) self.buttons.append(btn) x += self.BTN_SIZE if (i % 3) == 0: x = left y += self.BTN_SIZE