def print_legend(): sorted_player_names = list(get_current_resource().players_registry.keys()) sorted_player_names.sort() for player_name in sorted_player_names: print(" {} : {}".format( get_player_char( get_current_resource().players_registry[player_name]), player_name))
def is_partially_over(self, displayed_element): rel_x, rel_y, rel_size = self.get_relative_coordinates( displayed_element) rel_x = round(rel_x, 2) rel_y = round(rel_y, 2) rel_size = round(rel_size, 2) #2 pixels de marge d'erreur x_eps = 2 / get_current_resource().x_res y_eps = 2 / get_current_resource().y_res result = (not displayed_element.hidden and rel_x < 1 and rel_x + rel_size > 0 and rel_y < 1 and rel_y + (rel_size / self.get_width_on_height()) > 0) return result
def move_down(self): grid = self.get_top_grid() min_distance = grid.num_box_line max_line = 0 for child in self.children: child_abs_line, child_abs_col, child_abs_size = grid.to_line_and_cols( *child.get_absolute_coordinates()) max_line = max(max_line, child_abs_line) for player in get_current_resource().players_registry.values(): if (player.parent != self and not player.hidden): player_line, player_col, player_size = grid.to_line_and_cols( *player.get_absolute_coordinates()) if (player_col == child_abs_col and player_line > child_abs_line): min_distance = min( min_distance, player_line - (child_abs_line + child_abs_size)) if (min_distance == grid.num_box_line): min_distance = grid.num_box_line - (max_line) self_abs_x, self_abs_y, self_abs_size = self.get_absolute_coordinates() move_down_time = min_distance / MOVE_SPEED abs_distance = min_distance / grid.num_box_line self.inside(grid).prop_move(self_abs_y + abs_distance, self_abs_x, self_abs_size, move_down_time) incr_clock(move_down_time)
def get_player_char(player): if (player == None): return " " else: sorted_player_names = list( get_current_resource().players_registry.keys()) sorted_player_names.sort() return letters[sorted_player_names.index(player.name)]
def __init__(self): self.rel_x = 0 self.rel_y = 0 self.rel_size = 1 self.width_on_height = 1 self.parent = None self.inside(get_current_resource().grid) self.hidden = False self.previous_move_times = [] self.previous_coordinates = []
def __init__(self, num_of_lines, num_of_cols, children_names_or_obj=[]): self.player_registry = get_current_resource().players_registry self.num_box_line = num_of_lines self.num_box_col = num_of_cols self.children = [] self.tag_map = {} for child_name_or_obj in children_names_or_obj: if type(child_name_or_obj) == str: child = self.player_registry[child_name_or_obj] else: child = child_name_or_obj child.inside(self)
def spectrum(columns, lines, rate, duration): cols = [] mus = get_current_resource().players_registry grid = get_current_resource().grid remaining_players = list(mus.values()) for col_num in range(columns): col = SepctrumCol([], lines) remaining_players = col.fill(remaining_players) col.inside(grid).goto(2, col_num + 1) cols.append(col) col.inside(grid).goto(3, col_num + 1) audio_data = get_audio_data(columns, rate, duration) #print(audio_data.shape) #print(grid) for index in range(audio_data.shape[0]): print(audio_data[index, :]) for col_index in range(columns): cols[col_index].set_level(audio_data[index, col_index]) incr_clock(rate)
def hide_all(to_hide=None): if (to_hide == None): to_hide = list(get_current_resource().players_registry.values()) for player in to_hide: player.hide()
def get_player_name_from_char(char): sorted_player_names = list(get_current_resource().players_registry.keys()) sorted_player_names.sort() return get_short_name(sorted_player_names[letters.index(char)])
from totoro.utils import get_current_resource resource = get_current_resource() instru_map = resource.instru_map mus = resource.players_registry all_players = list(resource.players_registry.values()) def get_all_players(): players_with_bonus = list(resource.players_registry.values()) result = [ player for player in players_with_bonus if player not in bonux.all ] result.remove(JeanJacques_chef_lacheprise) result.remove(JeanJacques_chef) return result JeanSeb_percu = mus["Jean-Seb_percu_totoro"] JeanJacques_chef = mus["Jean-Jacques_chef_totoro"] JeanJacques_percu = mus["Jean-Jacques_percu_totoro"] JeanJacques_chef_lacheprise = mus["Jean-Jacques_chef_laché prise"] Alizee_piano = mus["Alizee_piano_totoro"] Flore_piano = mus["Flore_piano_totoro"] Bidou_euphonium = mus["Bidou_euphonium_totoro"] Serge_euphonium = mus["Serge_euphonium_totoro"] Cecile_clarinette = mus["Cecile_clarinette_totoro_recadre"] Amelie_clarinette_recadre = mus["Amélie_clarinette_recadre"] Nelly_clarinette = mus["Nelly_clarinette_totoro"]