def print_region_icons(self, screen: Screen): while True: y_index = 0 for i in self.world: x_index = 0 for j in i: screen.print_at(f'{j.icon}', x_index * 2, y_index) x_index += 1 y_index += 1 ev = screen.get_key() if ev in (ord('Q'), ord('q')): return screen.refresh()
def disp_audio(screen: Screen) -> None: while True: screen.clear() b = ch.buff sw = len(b)//bw b = np.asarray([np.average(b[i:i+sw]) for i in range(0, len(b), sw)]) for i, v in enumerate(b): screen.move((w-bw)//2+i, int(h//2-bh*v*scale)) screen.draw((w-bw)//2+i, h//2, char=char, colour=1 if np.max(b) > .2 else 7) e = screen.get_key() if e in (ord('Q'), ord('q')): break screen.refresh() time.sleep(.01)
def run_emu(screen: Screen, render_method=render_halfchars) -> None: """ Asciimatics runner function to wrap, render the screen """ path = clean_path(sys.argv[1]) try: vm = load_rom_to_vm(path) except IOError as e: exit_with_error(f"Could not read {path!r} : {e!r}") except IndexError as e: exit_with_error(f"Rom size appears incorrect: {e!r}") paused = False # load keymap in an ugly but functional way # later versions of this should be a function that # takes a converter function to map between keys and # their frontend-specific representation. this will # make loading generic while still retaining compatibility # with various frontends. final_keymap = build_hexkey_mapping() while True: ev = screen.get_key() if ev in (ord('H'), ord('h')): return if ev == ord('p'): paused = not paused if not paused: if ev in final_keymap: vm.press(final_keymap[ev]) for i in range(vm.ticks_per_frame): vm.tick() if ev in final_keymap: vm.release(final_keymap[ev]) render_method(screen, vm) screen.refresh()
def print_world_tile_types(self, screen: Screen): while True: y_index = 0 for i in self.world: x_index = 0 for j in i: if j.type == 'Land': color = Screen.COLOUR_GREEN else: color = Screen.COLOUR_BLUE screen.print_at(f'{j.height}', x_index * 2, y_index, color) x_index += 1 y_index += 1 ev = screen.get_key() if ev in (ord('Q'), ord('q')): return screen.refresh()
def print_world_heights(self, screen: Screen): for c in self.continents: c.set_tile_icons_to_continent_icon() forest_colors = [23, 29, 22, 28, 34, 40, 46, 83, 85] ocean_colors = [17, 18, 19, 20, 21, 33, 45, 201, 201, 201] mountain_colors = [201, 201, 201, 233, 235, 237, 241, 248, 252, 255] desert_colors = [ 3, 186, 190, 226, 227, 228, 229, 230, 252, 255 ] # [130, 136, 172, 178, 220, 226, 228, 230, 252, 255] color_table = [201, 201, 201, 201, 201, 201, 201, 201, 201] while True: y_index = 0 for i in self.world: x_index = 0 for j in i: if j.type is not 'Land': color_table = ocean_colors elif j.terrain is 'Desert': color_table = desert_colors elif j.height < 6: color_table = forest_colors elif j.height >= 6: color_table = mountain_colors color = color_table[j.height] screen.print_at(f'{j.height}{j.icon}', x_index * 2, y_index, colour=16, bg=color) x_index += 1 y_index += 1 ev = screen.get_key() if ev in (ord('Q'), ord('q')): # for c in self.continents: # c.set_tile_icons_to_region_icon() return screen.refresh()
def print_continent_icons(self, screen: Screen): for c in self.continents: c.set_tile_icons_to_continent_icon() while True: y_index = 0 for i in self.world: x_index = 0 for j in i: screen.print_at(f'{j.icon}', x_index * 2, y_index) x_index += 1 y_index += 1 ev = screen.get_key() if ev in (ord('Q'), ord('q')): for c in self.continents: c.set_tile_icons_to_region_icon() return screen.refresh()