|
6 | 6 | from __future__ import annotations |
7 | 7 |
|
8 | 8 | import copy |
| 9 | +import importlib.metadata |
9 | 10 | import math |
10 | 11 | import random |
11 | 12 | import sys |
|
18 | 19 | from numpy.typing import NDArray |
19 | 20 |
|
20 | 21 | import tcod.cffi |
| 22 | +import tcod.context |
21 | 23 | import tcod.event |
22 | 24 | import tcod.noise |
23 | 25 | import tcod.render |
@@ -160,8 +162,8 @@ def print_banner(self) -> None: |
160 | 162 | string="The Doryen library uses 24 bits colors, for both " "background and foreground.", |
161 | 163 | fg=WHITE, |
162 | 164 | bg=GREY, |
163 | | - bg_blend=tcod.BKGND_MULTIPLY, |
164 | | - alignment=tcod.CENTER, |
| 165 | + bg_blend=libtcodpy.BKGND_MULTIPLY, |
| 166 | + alignment=libtcodpy.CENTER, |
165 | 167 | ) |
166 | 168 |
|
167 | 169 |
|
@@ -297,7 +299,7 @@ def on_draw(self) -> None: |
297 | 299 | # in python the easiest way is to use the line iterator |
298 | 300 | for x, y in tcod.los.bresenham((xo, yo), (xd, yd)).tolist(): |
299 | 301 | if 0 <= x < sample_console.width and 0 <= y < sample_console.height: |
300 | | - tcod.console_set_char_background(sample_console, x, y, LIGHT_BLUE, self.bk_flag) |
| 302 | + libtcodpy.console_set_char_background(sample_console, x, y, LIGHT_BLUE, self.bk_flag) |
301 | 303 | sample_console.print( |
302 | 304 | 2, |
303 | 305 | 2, |
@@ -581,8 +583,8 @@ def on_draw(self) -> None: |
581 | 583 | self.draw_ui() |
582 | 584 | sample_console.print(self.player_x, self.player_y, "@") |
583 | 585 | # Draw windows. |
584 | | - sample_console.tiles_rgb["ch"][SAMPLE_MAP == "="] = 0x2550 # BOX DRAWINGS DOUBLE HORIZONTAL |
585 | | - sample_console.tiles_rgb["fg"][SAMPLE_MAP == "="] = BLACK |
| 586 | + sample_console.rgb["ch"][SAMPLE_MAP == "="] = 0x2550 # BOX DRAWINGS DOUBLE HORIZONTAL |
| 587 | + sample_console.rgb["fg"][SAMPLE_MAP == "="] = BLACK |
586 | 588 |
|
587 | 589 | # Get a 2D boolean array of visible cells. |
588 | 590 | fov = tcod.map.compute_fov( |
@@ -625,7 +627,7 @@ def on_draw(self) -> None: |
625 | 627 | dark_bg: NDArray[np.float16] = self.dark_map_bg.astype(np.float16) |
626 | 628 |
|
627 | 629 | # Linear interpolation between colors. |
628 | | - sample_console.tiles_rgb["bg"] = dark_bg + (light_bg - dark_bg) * light[..., np.newaxis] |
| 630 | + sample_console.rgb["bg"] = dark_bg + (light_bg - dark_bg) * light[..., np.newaxis] |
629 | 631 | else: |
630 | 632 | sample_console.bg[...] = np.where(fov[:, :, np.newaxis], self.light_map_bg, self.dark_map_bg) |
631 | 633 |
|
@@ -1411,7 +1413,7 @@ def init_context(renderer: int) -> None: |
1411 | 1413 | context = tcod.context.new( |
1412 | 1414 | columns=root_console.width, |
1413 | 1415 | rows=root_console.height, |
1414 | | - title=f"python-tcod samples (python-tcod {tcod.__version__}, libtcod {libtcod_version})", |
| 1416 | + title=f"""python-tcod samples (python-tcod {importlib.metadata.version("tcod")}, libtcod {libtcod_version})""", |
1415 | 1417 | vsync=False, # VSync turned off since this is for benchmarking. |
1416 | 1418 | tileset=tileset, |
1417 | 1419 | ) |
|
0 commit comments