def game_exit(): console.clear() map1.draw() player1.draw() console.move_cursor(0, 24) pass
def draw_need_camera(self, camera: Camera): will_x = int(self.x) - int(camera.look_x) + int( console.get_max_width() / 2) will_y = int(self.y) - int(camera.look_y) + int( console.get_max_height() / 2) console.move_cursor(int(will_x), int(will_y)) print(self._style)
def game_clear(): console.move_cursor(0, 0) i = 0 while i < console.get_max_height(): print( " " ) i += 1
def display(self): """ Nicely formatted display of the location history, with current location highlighted. If a clean display is present on the screen, this overwrites it to perform an 'update'. """ buffer_size = get_buffer_size() if self.shown and self.disp_size == buffer_size: # We just need to update the previous display, so we # go back to the original display start point move_cursor(0, buffer_size[1] - self.offset_from_bottom) else: # We need to redisplay, so remember the start point for # future updates self.disp_size = buffer_size self.offset_from_bottom = buffer_size[1] - get_cursor()[1] stdout.write('\n') lines_written = 2 stdout.write(color.Fore.DEFAULT + color.Back.DEFAULT) for i in range(len(self.locations)): location = self.locations[i] if i < 9: prefix = ' +%d ' % (i + 1) else: prefix = ' %d ' % (i + 1) lines_written += (len(prefix + location) / buffer_size[0] + 1) if i != self.index: # Non-selected entry, simply print stdout.write(prefix + location + '\n') else: # Currently selected entry, print with highlight stdout.write(appearance.colors.dir_history_selection + prefix + location + color.Fore.DEFAULT + color.Back.DEFAULT) stdout.write(' ' * (buffer_size[0] - get_cursor()[0])) # Check whether we have overflown the buffer if lines_written > self.offset_from_bottom: self.offset_from_bottom = lines_written # Mark a clean display of the history self.shown = True
def display(self): """ Nicely formatted display of the location history, with current location highlighted. If a clean display is present on the screen, this overwrites it to perform an 'update'. """ buffer_size = get_buffer_size() if self.shown and self.disp_size == buffer_size: # We just need to update the previous display, so we # go back to the original display start point move_cursor(0, buffer_size[1] - self.offset_from_bottom) else: # We need to redisplay, so remember the start point for # future updates self.disp_size = buffer_size self.offset_from_bottom = buffer_size[1] - get_cursor()[1] stdout.write('\n') lines_written = 2 stdout.write(color.Fore.DEFAULT + color.Back.DEFAULT) for i in range(len(self.locations)): location = self.locations[i] prefix = ' %d ' % (i + 1) lines_written += (len(prefix + location) / buffer_size[0] + 1) if i != self.index: # Non-selected entry, simply print stdout.write(prefix + location + '\n') else: # Currently selected entry, print with highlight stdout.write(appearance.colors.dir_history_selection + prefix + location + color.Fore.DEFAULT + color.Back.DEFAULT) stdout.write(' ' * (buffer_size[0] - get_cursor()[0])) # Check whether we have overflown the buffer if lines_written > self.offset_from_bottom: self.offset_from_bottom = lines_written # Mark a clean display of the history self.shown = True
def draw(self): if int(self.x) >= 0 and int(self.y) >= 0 and int( self.x) < console.get_max_width() and int( self.y) < console.get_max_height() - 1: console.move_cursor(int(self.x), int(self.y)) print(self.style)
if len(suggestions) % num_columns != 0: num_lines += 1 num_screens = 1.0 * num_lines / (get_viewport()[3] - get_viewport()[1]) if num_screens >= 0.9: # We ask for confirmation before displaying many completions (c_x, c_y) = get_cursor() offset_from_bottom = console.get_buffer_size( )[1] - c_y message = ' Scroll ' + str(int( round(num_screens))) + ' screens? [Tab] ' stdout.write('\n' + message) rec = read_input() move_cursor( c_x, console.get_buffer_size()[1] - offset_from_bottom) stdout.write('\n' + ' ' * len(message)) move_cursor( c_x, console.get_buffer_size()[1] - offset_from_bottom) if rec.Char != '\t': if not ord(rec.Char) in [0, 8, 13, 27]: state.handle(ActionCode.ACTION_INSERT, rec.Char) continue stdout.write('\n') for line in range(0, num_lines): # Print one line
def draw(self): console.move_cursor(self.x, self.y) print("@")
else: # We print a single column for clarity num_columns = 1 num_lines = len(suggestions) / num_columns if len(suggestions) % num_columns != 0: num_lines += 1 num_screens = 1.0 * num_lines / (get_viewport()[3] - get_viewport()[1]) if num_screens >= 0.9: # We ask for confirmation before displaying many completions (c_x, c_y) = get_cursor() offset_from_bottom = console.get_buffer_size()[1] - c_y message = ' Scroll ' + str(int(round(num_screens))) + ' screens? [Tab] ' stdout.write('\n' + message) rec = read_input() move_cursor(c_x, console.get_buffer_size()[1] - offset_from_bottom) stdout.write('\n' + ' ' * len(message)) move_cursor(c_x, console.get_buffer_size()[1] - offset_from_bottom) if rec.Char != '\t': continue stdout.write('\n') num_col_could_choose = num_lines # num_lines > 0 num_item_could_choose = len(string.lowercase) while num_col_could_choose < num_item_could_choose : num_col_could_choose = num_col_could_choose + num_lines num_col_could_choose = (num_col_could_choose + num_lines - 1) / num_lines for line in range(0, num_lines):
def draw(self): console.move_cursor(int(self.x), int(self.y)) print(self._style)