Skip to content

Commit c7936eb

Browse files
committed
Fix more samples deprecations
1 parent abdb169 commit c7936eb

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

examples/samples_tcod.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from __future__ import annotations
77

88
import copy
9+
import importlib.metadata
910
import math
1011
import random
1112
import sys
@@ -18,6 +19,7 @@
1819
from numpy.typing import NDArray
1920

2021
import tcod.cffi
22+
import tcod.context
2123
import tcod.event
2224
import tcod.noise
2325
import tcod.render
@@ -160,8 +162,8 @@ def print_banner(self) -> None:
160162
string="The Doryen library uses 24 bits colors, for both " "background and foreground.",
161163
fg=WHITE,
162164
bg=GREY,
163-
bg_blend=tcod.BKGND_MULTIPLY,
164-
alignment=tcod.CENTER,
165+
bg_blend=libtcodpy.BKGND_MULTIPLY,
166+
alignment=libtcodpy.CENTER,
165167
)
166168

167169

@@ -297,7 +299,7 @@ def on_draw(self) -> None:
297299
# in python the easiest way is to use the line iterator
298300
for x, y in tcod.los.bresenham((xo, yo), (xd, yd)).tolist():
299301
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)
301303
sample_console.print(
302304
2,
303305
2,
@@ -581,8 +583,8 @@ def on_draw(self) -> None:
581583
self.draw_ui()
582584
sample_console.print(self.player_x, self.player_y, "@")
583585
# 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
586588

587589
# Get a 2D boolean array of visible cells.
588590
fov = tcod.map.compute_fov(
@@ -625,7 +627,7 @@ def on_draw(self) -> None:
625627
dark_bg: NDArray[np.float16] = self.dark_map_bg.astype(np.float16)
626628

627629
# 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]
629631
else:
630632
sample_console.bg[...] = np.where(fov[:, :, np.newaxis], self.light_map_bg, self.dark_map_bg)
631633

@@ -1411,7 +1413,7 @@ def init_context(renderer: int) -> None:
14111413
context = tcod.context.new(
14121414
columns=root_console.width,
14131415
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})""",
14151417
vsync=False, # VSync turned off since this is for benchmarking.
14161418
tileset=tileset,
14171419
)

0 commit comments

Comments
 (0)