def animate(self, current_map, animations, camera, config, animation_data): # Scale color based on ticks left. terminal.font("main") color = animation_data['attack']['color_fg']['attacked'][:] color[0] += (self.ticks*5) # Put an indicator around attacker. terminal.color(terminal.color_from_argb(*animation_data['attack']['color_fg']['attacker'])) dx, dy = camera.to_camera_coords(self.actor.x, self.actor.y) terminal.put(dx*config['tile_spacing_x'], dy*config['tile_spacing_y'], animation_data['attack']['image']['attacker']) # Put an indicator around attacked target, fades based on amount of ticks left. terminal.color(terminal.color_from_argb(*color)) dx, dy = camera.to_camera_coords(self.target.x, self.target.y) terminal.put(dx*config['tile_spacing_x'], dy*config['tile_spacing_y'], animation_data['attack']['image']['attacked']) # Make sure background stays the default color. terminal.bkcolor(terminal.color_from_argb(0, 0, 0, 0)) # Remove animation once its maximum ticks are reached. if self.ticks <= 0: animations.remove(self) self.ticks -= 1
def render_entities_camera(): start = time.perf_counter() current_map = World.fetch('current_map') min_x, max_x, min_y, max_y = get_screen_bounds() map_width = current_map.width map_height = current_map.height subjects = World.get_components(PositionComponent, RenderableComponent) for entity, (position, renderable) in subjects: hidden = World.get_entity_component(entity, HiddenComponent) idx = current_map.xy_idx(position.x, position.y) terminal.layer(renderable.render_order.value) if current_map.visible_tiles[idx] and not hidden: entity_screen_x = position.x - min_x entity_screen_y = position.y - min_y if 0 <= entity_screen_x <= map_width and 0 <= entity_screen_y <= map_height: if Interface.mode == GraphicalModes.ASCII: terminal.printf( entity_screen_x * Interface.zoom, entity_screen_y * Interface.zoom, f'[color={renderable.fg}]{renderable.glyph}[/color]') elif Interface.mode == GraphicalModes.TILES: terminal.color(f'{renderable.fg}') terminal.put(entity_screen_x * Interface.zoom, entity_screen_y * Interface.zoom, Interface.get_code(renderable.sprite)) else: print( f'render camera: graphical mode {Interface.mode} not implemented.' ) raise NotImplementedError delta_time = (time.perf_counter() - start) * 1000 print(f'delta time: for render entities : {delta_time}')
def draw_background(dest, x, y, color, flag=libtcod.BKGND_SET): # LIBTCOD # libtcod.console_set_char_background(dest, x, y, color, flag) # BEARLIB color = Utils.convert_color(color) terminal.bkcolor(color) terminal.put(x, y, terminal.pick(x, y, 0))
def terminal_update(self): global i global j terminal.put(j, 0, str(i)) i = (i + 1) % 10 j = (j + 1) % 11 return not self.should_exit
def render_bar(x, y, width, name, value, max_value, color_fg, color_bg, color_text): # Calculate current bar width. bar_width = int(float(value) / max_value * width) # Make sure there is always some bar showing even if value is super low. if bar_width < 1 and bar_width > 0: bar_width = 1 # Draw background of the bar to the width given. terminal.color(terminal.color_from_argb(*color_bg)) terminal.font('bar') for i in range(width): terminal.put(x + i, y, '▄') # Draw the foreground to the width calculated earlier. terminal.color(terminal.color_from_argb(*color_fg)) for i in range(bar_width): terminal.put(x + i, y, '▄') # Draw text in the center of the bar. terminal.font('text') terminal.color(terminal.color_from_argb(*color_text)) bar_text = name + ': %s/%s' % (value, max_value) center_x = int(x + (width / 2 - len(bar_text))) terminal.printf(center_x, y + 4, bar_text) # Reset font back to normal. terminal.font('main')
def draw(self, xy: vec, layer: int = 0) -> None: blt.layer(layer) blt.color(self.fg_colour.blt_colour()) if self.bg_colour is not None: blt.bkcolor(self.bg_colour.blt_colour()) xy = xy + self.xy blt.put(xy.x, xy.y, self.char)
def draw(self): """Draws self onto the terminal""" global visible_tiles if (self.x, self.y) in visible_tiles: set_colour(self.rgb, 255) t.put(self.x, self.y, self.char)
def render(self): if splash: t.layer(0) set_colour(colours.white, 100) t.put(0, 0, 0x5E) #show the game's title, and some credits! title = 'Death and Axes' center = (SCREEN_WIDTH - len(title)) // 2 t.layer(UI_LAYER) set_colour(colours.dark_azure, 150) t.puts(center - 1, SCREEN_HEIGHT//2 - 5, BLOCK_CHAR * (len(title) + 2) * 3, len(title) + 2, 3) t.layer(UI_TEXT_LAYER) set_colour(colours.light_yellow) t.puts(center, SCREEN_HEIGHT//2-4, title) title = 'By Cerepol' center = (SCREEN_WIDTH - len(title)) // 2 t.layer(UI_LAYER) set_colour(colours.dark_azure, 150) t.puts(center - 1, SCREEN_HEIGHT - 3, BLOCK_CHAR * (len(title) + 2) * 3, len(title) + 2, 3) t.layer(UI_TEXT_LAYER) set_colour(colours.light_yellow) t.puts(center, SCREEN_HEIGHT-2, title) t.refresh() t.delay(2000) t.layer(0) splash = False
def clear_view(self): for i in range(len(RenderLayer)): blt.layer(i) blt.clear_area(0, 0, self.width * 2, self.height * 2) blt.layer(RenderLayer.ACTOR.value) blt.put(self.center.x, self.center.y, " ")
def render_map_con(entities, players, game_map, width, height, ox=0, oy=0) -> None: terminal.layer(0) for player in players: for y in range(game_map.height): for x in range(game_map.width): #Show if it's visible if (x,y) in player.fighter.fov_visible: terminal.color('light amber') terminal.put(x+ox, y+oy, 0x2588) if (x,y) in player.fighter.fov_wall: terminal.color('dark gray') terminal.put(x+ox, y+oy, 0x2588) #Not visible but explored elif (x,y) in player.fighter.fov_explored: if (x,y) in player.fighter.fov_wall: terminal.color('darker gray') terminal.put(x+ox, y+oy, 0x2588) else: terminal.color('darker amber') terminal.put(x+ox, y+oy, 0x2588) #Not explored else: terminal.color('dark gray') terminal.put(x+ox, y+oy, 0x2588) print_entities(entities, ox, oy)
def test_layers(): blt.set("window.title='Omni: layers'") pixel = c_uint32(blt.color_from_name("dark gray")) blt.set("U+E000: %d, raw-size=1x1, resize=48x48, resize-filter=nearest" % addressof(pixel)) blt.clear() blt.color("white") blt.puts(2, 1, "[color=orange]1.[/color] Without layers:") blt.put(7, 3, 0xE000) blt.puts(5, 4, "[color=dark green]abcdefghij") blt.puts(2, 8, "[color=orange]2.[/color] With layers:") blt.layer(1) blt.put(7, 10, 0xE000) blt.layer(0) blt.puts(5, 11, "[color=dark green]abcdefghij") blt.refresh() key = None while key not in (blt.TK_CLOSE, blt.TK_ESCAPE): key = blt.read() blt.set("U+E000: none")
def render_map(self): if self.map: y = 0 while y < self.h: x = 0 while x < self.w: # need the x/y coordinates for the tile relative to the players dungeon location # not where the tile will be placed y_index = self.player["dy"] - (self.h // 2) + (y // settings.DUNGEON_TILE_SIZE) x_index = self.player["dx"] - (self.w // 2) + (x // settings.DUNGEON_TILE_SIZE) # create a tuple to compare with the map coord = x_index, y_index # check that there is a tile to be rendered within the bounds of the map object # this prevents the rendering of the same map showing multiple times recursively if coord in self.map: terminal.composition(terminal.TK_ON) for tile in self.map[coord]: if tile: terminal.put(x, y, tile) terminal.composition(terminal.TK_OFF) x += settings.DUNGEON_TILE_SIZE y += settings.DUNGEON_TILE_SIZE
def draw(self, camera): x, y = camera.to_camera_coordinates(self.x, self.y) if self.projectile: terminal.put_ext(x * 4, y * 2, self.projectile.x_offset, self.projectile.y_offset, self.icon) else: terminal.put(x * 4, y * 2, self.icon)
def draw_map(game_map): if game_map: terminal.layer(Layers.MAP) terminal.color(terminal.color_from_name("white")) for point, tile in game_map: terminal.put(point.x, point.y, tile.char)
def draw_light_sources(self): player = self.owner.player light_map = player.player.lightmap game_map = self.owner.levels.current_map game_camera = self.owner.game_camera for light in self.light_sources: light_fov = np.where(light.fov_map.fov) center = np.array([light.owner.y, light.owner.x]) for i in range(light_fov[0].size): y, x = int(light_fov[0][i]), int(light_fov[1][i]) if player.light_source.fov_map.fov[y, x]: v = np.array([y, x]) dist = float(cityblock(center, v)) light_level = game_map.tiles[x][y].natural_light_level * \ (1.0 / (0.2 + 0.1 * dist + 0.025 * dist * dist)) if light_map[y][x] < light_level: light_map[y][x] = light_level player_fov = np.where(player.light_source.fov_map.fov) for j in range(player_fov[0].size): y, x = int(player_fov[0][j]), int(player_fov[1][j]) cam_x, cam_y = game_camera.get_coordinates(x, y) blt.layer(0) c = blt.color_from_name(game_map.tiles[x][y].color) argb = argb_from_color(c) flicker = random.uniform( 0.95, 1.05) if self.owner.options.flicker is True else 1 a = argb[0] r = min(int(argb[1] * light_map[y][x] * flicker), 255) g = min(int(argb[2] * light_map[y][x] * flicker), 255) b = min(int(argb[3] * light_map[y][x] * flicker), 255) blt.color(blt.color_from_argb(a, r, g, b)) blt.put(cam_x * self.owner.options.tile_offset_x, cam_y * self.owner.options.tile_offset_y, game_map.tiles[x][y].char) if len(game_map.tiles[x][y].layers) > 0: i = 1 for tile in game_map.tiles[x][y].layers: blt.layer(i) c = blt.color_from_name(tile[1]) argb = argb_from_color(c) a = argb[0] r = min(int(argb[1] * light_map[y][x] * flicker), 255) g = min(int(argb[2] * light_map[y][x] * flicker), 255) b = min(int(argb[3] * light_map[y][x] * flicker), 255) blt.color(blt.color_from_argb(a, r, g, b)) blt.put(cam_x * self.owner.options.tile_offset_x, cam_y * self.owner.options.tile_offset_y, tile[0]) i += 1 if len(game_map.tiles[x][y].entities_on_tile) > 0: for entity in game_map.tiles[x][y].entities_on_tile: if not entity.cursor: self.clear(entity, cam_x, cam_y) self.draw(entity, cam_x, cam_y)
def draw_status(self): """Отображение состояния игрока.""" nutration_max = int(self.nutrition // 10 + 1) hp_max = int(self.hp // 10 + 1) if hp_max > 10: hp_max = 10 if nutration_max > 10: nutration_max = 10 terminal.clear_area(2, 3, 10, 1) for x in range(hp_max): terminal.color(color["healf"]) terminal.put(x + 2, 3, chars["block"]) terminal.clear_area(2, 5, 10, 1) for x in range(nutration_max): terminal.color(color["nutrition"]) terminal.put(x + 2, 5, chars["block"]) terminal.color(color["white"]) terminal.clear_area(1, 7, 14, 1) terminal.printf( 1, 7, "Вес: " + str(self.inventory.sum_weight) + "/" + str(self.inventory.weight)) terminal.color(color["white"])
def update_widget(self, widget, refresh=False): """ Actually draw widget chars on screen. If ``widget.chars`` or ``widget.colors`` have changed, this method will make these changes visible. It is also called by ``self.add_widget()`` and other methods that have a ``refresh`` argument. :param widget: A widget to be updated. """ if widget not in self.widget_locations: raise BearException('Cannot update non-added Widgets') pos = self.widget_locations[widget].pos layer = self.widget_locations[widget].layer terminal.layer(layer) terminal.clear_area(*self.widget_locations[widget].pos, widget.width, widget.height) running_color = self.default_color for y in range(widget.height): for x in range(widget.width): # Widget can have None as color for its empty cells if widget.colors[y][x] and widget.colors[y][x] != running_color: running_color = widget.colors[y][x] terminal.color(running_color) terminal.put(pos[0] + x, pos[1] + y, widget.chars[y][x]) self._widget_pointers[layer][pos[0] + x][pos[1] + y] = widget if running_color != self.default_color: terminal.color(self.default_color) if refresh: self.refresh()
def draw_background(dest, x, y, color, flag=libtcod.BKGND_SET): # LIBTCOD # libtcod.console_set_char_background(dest, x, y, color, flag) # BEARLIB color = Utils.convert_color(color) terminal.bkcolor(color) terminal.put(x, y, terminal.pick(x,y, 0))
def draw(self): """Draws self onto the terminal""" global visible_tiles if (self.x, self.y) in visible_tiles or \ (self.always_visible and gmap.is_explored(self.x, self.y)): set_colour(self.rgb, 255) t.put(self.x, self.y, self.char)
def draw(self): """Рисует существо.""" self.bkcolor = terminal.pick_bkcolor(self.x, self.y) terminal.bkcolor(self.bkcolor) terminal.layer(self.layer_draw) terminal.put(self.x, self.y, self.char) terminal.layer(0) terminal.bkcolor(color["black"])
def render(self): self.frame += 1 if self.frame % 5 == 0: self.animate() term.layer(1) term.color(term.color_from_argb(255, *COLOR['WHITE'])) term.put(self.center[X], self.center[Y], self.picture) super(MenuPanel, self).render()
def print_charset(point): terminal.printf(10, 10, "test") height = int(terminal_size[1]) width = int(terminal_size[0]) for y in range(0, height): for x in range(0, width): terminal.put(x, y, point) point += 1
def put(self, x: int, y: int, code: int, fg: str = None, bg: str = None): if fg: terminal.color(fg) if bg: terminal.bkcolor(bg) terminal.put(x + self.x, y + self.y, code) terminal.color("white") terminal.bkcolor("black")
def draw(self, cell, panelPos): i = 0 for color, tile in zip(cell.color, cell.stack): if tile is not None: term.layer(i) term.color(term.color_from_argb(255, *color)) term.put(panelPos[X], panelPos[Y], tile) i += 1
def draw_map(): blt.color("white") for y in range(y0, y0 + view_height): for x in range(x0, x0 + view_width): code = map_[y][x] if code in palette: s = palette[code] blt.put((x - x0) * 4, (y - y0) * 2, 0xE000 + s.tile)
def draw_entities(self): for _, (player, player_position) in self.world.get_components( Player, Position): # Set player offset relative to display x_offset = 16 - player_position.x y_offset = 10 - player_position.y # Set the bounding box for filtering out entities x_min = player_position.x - 16 x_max = player_position.x + 16 y_min = player_position.y - 10 y_max = player_position.y + 10 entity_pairs = self.world.get_components(Display, LastKnownPosition) if not entity_pairs: return entity_pairs.sort(key=lambda pair: pair[1][0].draw_order) for entity, (display, position) in entity_pairs: if not x_min <= position.x <= x_max or not y_min <= position.y <= y_max: continue if self.world.has_component(entity, Visible): bkcolor = 0xFF100800 color = display.color bkcolor = filter_color(bkcolor, player) color = filter_color(color, player) else: bkcolor = 0xFF000000 color = 0xFF666666 if self.world.has_component(entity, Blinded): bkcolor = 0xFFFFFFFF color = 0xFF000000 bkcolor = filter_color(bkcolor, player) color = filter_color(color, player) terminal.bkcolor(bkcolor) terminal.color(color) # Render assassins as underscores until they are in range if self.world.has_component( entity, Assassin) and not self.world.has_component( entity, Adjacent): code = 0x005F else: code = display.code terminal.put( position.x + x_offset, position.y + y_offset, code, )
def test_auto_generated(): blt.set("window.title='Omni: auto-generated tileset'") hoffset = 40 cell_width = blt.state(blt.TK_CELL_WIDTH) cell_height = blt.state(blt.TK_CELL_HEIGHT) def setup_cellsize(): blt.set("window.cellsize=%dx%d" % (cell_width, cell_height)) while True: blt.clear() blt.color("white") blt.puts( 2, 1, "[color=orange]Cell size:[/color] %dx%d" % (cell_width, cell_height)) blt.puts( 2, 3, "[color=orange]TIP:[/color] Use arrow keys\nto change cell size") for j in range(16): blt.puts(hoffset + 6 + j * 2, 1, "[color=orange]%X" % j) y = 0 for code in range(0x2500, 0x259F + 1): if code % 16 == 0: blt.puts(hoffset, 2 + y * 1, " [color=orange]%04X" % code) blt.put(hoffset + 6 + (code % 16) * 2, 2 + y * 1, code) if (code + 1) % 16 == 0: y += 1 blt.puts( 2, 6, u"┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐\n" u"│Z││A││ ││W││A││R││U││D││O│\n" u"└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘└─┘\n") blt.refresh() key = blt.read() if key in (blt.TK_CLOSE, blt.TK_ESCAPE): break elif key == blt.TK_LEFT and cell_width > 4: cell_width -= 1 setup_cellsize() elif key == blt.TK_RIGHT and cell_width < 24: cell_width += 1 setup_cellsize() elif key == blt.TK_DOWN and cell_height < 24: cell_height += 1 setup_cellsize() elif key == blt.TK_UP and cell_height > 4: cell_height -= 1 setup_cellsize() blt.set("window.cellsize=auto")
def draw(self, x, y, bgUnderItem, spacing_x, spacing_y): terminal.color(terminal.color_from_argb(*self.color_fg)) terminal.bkcolor(terminal.color_from_argb(*bgUnderItem)) terminal.put(x*spacing_x, y*spacing_y, self.image) # Draw highlight rectangle if needed. if self.highlight: terminal.color(terminal.color_from_argb(*self.highlight)) terminal.put(x*spacing_x, y*spacing_y, '\u2610')
def draw_window(self): x = self.x y = self.y w = self.w h = self.h header_len = 0 #Draw border for dx in range(x, x+w): for dy in range(y, y+h): terminal.layer(1) terminal.color('darker gray') terminal.put(dx, dy, 0x2593) if dx == x and dy == y: terminal.puts(dx, dy,'[color='+self.color+']'+'╔') elif dx == x+w-1 and dy == y+h-1: terminal.puts(dx, dy,'[color='+self.color+']'+'╝') elif dx == x and dy == y+h-1: terminal.puts(dx, dy,'[color='+self.color+']'+'╚') elif dx == x+w-1 and dy == y: terminal.puts(dx, dy,'[color='+self.color+']'+'╗') elif dx == x or dx == x+w-1: terminal.puts(dx, dy,'[color='+self.color+']'+'║') elif dy == y or dy == (y+h-1): terminal.puts(dx, dy,'[color='+self.color+']'+'═') if self.header is not None: header_len = len(self.header) for h in self.header: terminal.layer(2) terminal.printf(x+1, y+1+(self.header.index(h)), '[color=white][font=big]'+h) terminal.print_(x+1, y+1+header_len, '\n') if self.options is not None: letter_index = ord('a') for option in self.options: opt_index = self.options.index(option) wrapped_option = textwrap.wrap(option, self.w-4) if opt_index < 26: letter_index = ord('a') + opt_index else: letter_index = ord('0') + opt_index - 26 terminal.layer(2) if len(wrapped_option) == 1: text = '[font=big](' + chr(letter_index) + ') ' + option terminal.printf(x+1, y+1+header_len+1+(self.options.index(option)), '[color=white]'+ text) else: for o in wrapped_option: if wrapped_option.index(o) == 0: text = '[font=big](' + chr(letter_index) + ') ' + o terminal.printf(x+1, y+1+header_len+1+(self.options.index(option)), '[color=white]'+ text) else: text = '[font=big] ' + o terminal.printf(x+1, y+1+header_len+1+(self.options.index(option)+wrapped_option.index(o)), '[color=white]'+ text)
def draw_entity(entity: Entity, game_map: GameMap, camera_view: dict): if game_map.in_fov(entity.position): # set layer to draw on terminal.layer(Layers.PLAYER) # change color color = terminal.color_from_name(entity.color) terminal.color(color) view_x, view_y = camera_view[entity.position] terminal.put(view_x, view_y, entity.char)
def main_menu(screen_width, screen_height): blt.put(0, 0, 0xE000) blt.color('red') blt.puts(int(screen_width / 2), int(screen_height / 2) - 4, 'Pirate Rogue') blt.color('white') blt.puts(int(screen_width / 2), int(screen_height - 2), 'By Denrur') menu('', ['Play a new game', 'Continue last game', 'Quit'], 24, screen_width, screen_height)
def draw_background(dest, x, y, color, flag=libtcod.BKGND_SET, verbose=False): # LIBTCOD # libtcod.console_set_char_background(dest, x, y, color, flag) # BEARLIB # TODO: Replace / Obsolete? #color = Utils.convert_color(color) if verbose: print color.getRGB() terminal.bkcolor(color) terminal.put(x, y, terminal.pick(x,y, 0))
def draw_char(dest, x, y, char, color=None, flag=None): # LIBTCOD # libtcod.console_put_char_ex(dest, x, y, char, color, flag) #BEARLIB terminal.layer(dest) # TODO: CONVERT COLORS ON THEME IMPORT, INSTEAD OF INLINE (all render func) if color is not None: color = Utils.convert_color(color) terminal.color(color) terminal.put(x, y, char)
def draw_char(dest, x, y, char, color=None, flag=None, alpha=255, verbose=False): # LIBTCOD # libtcod.console_put_char_ex(dest, x, y, char, color, flag) #BEARLIB terminal.layer(dest) # TODO: CONVERT COLORS ON THEME IMPORT, INSTEAD OF INLINE (all render func) if color is not None: if verbose: print color print int(color) print color.getRGB() #color = Utils.convert_color(color, alpha) #print "Color: {0}".format(color) #print "In DrawChar Color: {0}".format(color) terminal.color(color) terminal.put(x, y, char)
def test_basic_output(): blt.set("window.title='Omni: basic output'") blt.clear() blt.color("white") # Wide color range n = blt.print_(2, 1, "[color=orange]1.[/color] Wide color range: ") long_word = "antidisestablishmentarianism." long_word_length = len(long_word) for i in range(long_word_length): factor = i / long_word_length red = int((1 - factor) * 255) green = int(factor * 255) blt.color(blt.color_from_argb(255, red, green, 0)) blt.put(2 + n + i, 1, long_word[i]) blt.color("white") blt.print_(2, 3, "[color=orange]2.[/color] Backgrounds: [color=black][bkcolor=gray] grey [/bkcolor] [bkcolor=red] red ") blt.print_(2, 5, "[color=orange]3.[/color] Unicode support: Кириллица Ελληνικά α=β²±2°") blt.print_(2, 7, "[color=orange]4.[/color] Tile composition: @ + [color=red]|[/color] = @[+][color=red]|[/color], a vs. ¨ a[+][color=red]¨[/color]") blt.printf(2, 9, "[color=orange]5.[/color] Box drawing symbols:") blt.print_(5, 11, " ┌────────┐ \n" " │!......s└─┐\n" "┌──┘........s.│\n" "│............>│\n" "│...........┌─┘\n" "│<.@..┌─────┘ \n" "└─────┘ ■█┘╙ \n" ) blt.refresh() key = None while key not in (blt.TK_CLOSE, blt.TK_ESCAPE): key = blt.read()
def test_tilesets(): blt.set("window.title='Omni: tilesets'") blt.composition(True) # Load tilesets blt.set("U+E100: ./Images/Runic.png, size=8x16") blt.set("U+E200: ./Images/Tiles.png, size=32x32, align=top-left") blt.set("U+E400: ./Images/test_tiles.png, size=16x16, align=top-left") blt.set("U+E300: ./Fonts/fontawesome-webfont.ttf, size=24x24, spacing=3x2, codepage=./Fonts/fontawesome-codepage.txt") blt.set("zodiac font: ./Fonts/Zodiac-S.ttf, size=24x36, spacing=3x3, codepage=437") blt.clear() blt.color("white") blt.print_(2, 1, "[color=orange]1.[/color] Of course, there is default font tileset.") blt.print_(2, 3, "[color=orange]2.[/color] You can load some arbitrary tiles and use them as glyphs:") blt.print_(2+3, 4, "Fire rune ([color=red][U+E102][/color]), " "water rune ([color=lighter blue][U+E103][/color]), " "earth rune ([color=darker green][U+E104][/color])") blt.print_(2, 6, "[color=orange]3.[/color] Tiles are not required to be of the same size as font symbols:") blt.put(2+3+0, 7, 0xE200+7) blt.put(2+3+5, 7, 0xE200+8) blt.put(2+3+10, 7, 0xE200+9) blt.print_(2, 10, "[color=orange]4.[/color] Like font characters, tiles may be freely colored and combined:") blt.put_ext(2+3+0, 11, 0, 0, tiles['stone_wall'], [blt.color_from_name("red"), blt.color_from_name("red"), blt.color_from_name("blue"), blt.color_from_name("red")]) blt.put_ext(2 + 3 + 2, 11, 0, 0, tiles['stone_wall'], [blt.color_from_name("red"), blt.color_from_name("blue"), blt.color_from_name("red"), blt.color_from_name("red")]) blt.put_ext(2 + 3 + 0, 13, 0, 0, tiles['stone_wall'], [blt.color_from_name("red"), blt.color_from_name("red"), blt.color_from_name("blue"), blt.color_from_name("blue")]) blt.put_ext(2 + 3 + 2, 13, 0, 0, tiles['stone_wall'], [blt.color_from_name("blue"), blt.color_from_name("blue"), blt.color_from_name("red"), blt.color_from_name("red")]) blt.put_ext(2 + 3 + 0 + 5, 11, 0, 0, '#', [blt.color_from_name("yellow"), blt.color_from_name("black"), blt.color_from_name("black"), blt.color_from_name("black")]) blt.put_ext(2 + 3 + 1 + 5, 11, 0, 0, 'A', [blt.color_from_name("black"), blt.color_from_name("yellow"), blt.color_from_name("yellow"), blt.color_from_name("black")]) blt.put_ext(2 + 3 + 0 + 5, 12, 0, 0, 'A', [blt.color_from_name("black"), blt.color_from_name("black"), blt.color_from_name("yellow"), blt.color_from_name("yellow")]) blt.put_ext(2 + 3 + 1 + 5, 12, 0, 0,'@', [blt.color_from_name("dark yellow"), blt.color_from_name("dark yellow"), blt.color_from_name("dark yellow"), blt.color_from_name("dark yellow")]) blt.put_ext(2 + 3 + 0 + 7, 11, 0, 0, 'A', [blt.color_from_name("black"), blt.color_from_name("yellow"), blt.color_from_name("black"), blt.color_from_name("black")]) blt.put_ext(2 + 3 + 0 + 7, 12, 0, 0, 'A', [blt.color_from_name("yellow"), blt.color_from_name("yellow"), blt.color_from_name("black"), blt.color_from_name("black")]) ''' # blt.color("lightest red") blt.put(2+3+4, 11,tiles['stairs']) # blt.color("purple") blt.put(2+3+8, 11, tiles['gold']) #blt.color("darkest red") blt.put(17, 11, 0xE400+0) blt.put(18, 11, 0xE400+0) blt.put(19, 11, 0xE400+1) blt.put(20, 11, 0xE400 + 0) blt.put(20, 11, 0xE400 + 2) blt.put(17, 12, 0xE400 + 10) blt.put(18, 12, 0xE400 + 10) blt.put(19, 12, 0xE400 + 11) blt.put(20, 12, 0xE400 + 10) blt.put(20, 12, 0xE400 + 12) ''' blt.put(21, 11, 0xE400+0) blt.color("blue") blt.put(18, 11, '@') blt.color("white") order = [11, 10, 14, 12, 13] for i in range(len(order)): blt.put(30 + i * 4, 11, 0xE200 + order[i]); blt.put(30 + (len(order)+1) * 4, 11, 0xE200 + order[i]) blt.put(30 + len(order) * 4, 11, 0xE200 + 15) blt.print_(2, 15, "[color=orange]5.[/color] And tiles can even come from TrueType fonts like this:") for i in range(6): blt.put(5 + i * 5, 15, 0xE300 + i) blt.print_(5, 18, "...or like this:\n[font=zodiac]D F G S C") blt.refresh() key = None while key not in (blt.TK_CLOSE, blt.TK_ESCAPE): key = blt.read() # Clean up blt.set("U+E100: none; U+E200: none; U+E300: none; zodiac font: none") blt.composition(False)
def draw_page(tx, ty, page): for y in range(16): for x in range(16): terminal.put((x * 2) + tx, y + ty, page + (16 * y) + x)