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_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_world_player(camera, player): x, y = camera.map_to_camera(player.x, player.y) draw_player(player, x, y) if player.orientation: push_colors() (px, py) = camera.map_to_camera(*player.looking_position()) terminal.color(terminal.pick_color(px, py)) terminal.bkcolor("#222222") terminal.put(px, py, terminal.pick(px, py)) pop_colors()
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_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 highlight_targets(self): attack_targets, defend_targets, both_targets = self.get_targets() for _, (_, position) in self.world.get_components(Player, Position): # Set player offset relative to display x_offset = 16 - position.x y_offset = 10 - position.y # Set the bounding box for filtering out entities x_min = position.x - 16 x_max = position.x + 16 y_min = position.y - 10 y_max = position.y + 10 terminal.color(0xFF000000) terminal.bkcolor(0xFFFF0000) for x, y in attack_targets: if x_min <= position.x <= x_max and y_min <= position.y <= y_max: x += x_offset y += y_offset terminal.put(x, y, terminal.pick(x, y)) terminal.bkcolor(0xFF0000FF) for x, y in defend_targets: if x_min <= position.x <= x_max and y_min <= position.y <= y_max: x += x_offset y += y_offset terminal.put(x, y, terminal.pick(x, y)) terminal.bkcolor(0xFFFF00FF) for x, y in both_targets: if x_min <= position.x <= x_max and y_min <= position.y <= y_max: x += x_offset y += y_offset terminal.put(x, y, terminal.pick(x, y))
def test_pick(): blt.set("window.title='Omni: examining cell contents'") blt.set("input.filter={keyboard, mouse}") blt.clear() blt.color("white") blt.puts(2, 1, "Move mouse over characters:") blt.bkcolor("darkest gray") blt.clear_area(2, 3, 76, 19) blt.bkcolor("none") colors = ("red", "orange", "yellow", "green", "cyan", "light blue", "violet") combining = (0x02C6, 0x02C9, 0x02DC, 0x2014, 0x2044, 0x2017, 0x203E) seed() for i in range(100): combined = randrange(5) == 0 n = randrange(2, 4) if combined else 1 x = randrange(2, 78) y = randrange(3, 22) blt.color(choice(colors)) blt.put(x, y, choice(ascii_lowercase)) blt.composition(True) for i in range(1, n): blt.color(choice(colors)) blt.put(x, y, choice(combining)) blt.composition(False) blt.color("white") while True: x = blt.state(blt.TK_MOUSE_X) y = blt.state(blt.TK_MOUSE_Y) blt.clear_area(2, 23, 76, 1) if 2 <= x < 78 and 3 <= y < 22: n = 0 while True: code = blt.pick(x, y, n) if code == 0: break color = blt.pick_color(x, y, n) blt.puts(2 + n * 2, 23, u"[color=#%x]%c" % (color, code)) n += 1 if n == 0: blt.puts(2, 23, "Empty cell") blt.refresh() key = blt.read() if key in (blt.TK_CLOSE, blt.TK_ESCAPE): break blt.set("input.filter={keyboard}")
def pick(self, *args): if isinstance(args[0], Point): return _terminal.pick(args[0].x, args[0].y, *args[1:]) else: return _terminal.pick(*args)