From 68aa90cac85e495473f72ca6cc4dd20c6959b31b Mon Sep 17 00:00:00 2001 From: staubsauger Date: Mon, 19 Aug 2024 15:47:27 +0200 Subject: [PATCH] keine ahnung... --- game/components.py | 4 +++- game/screens/game_screens.py | 8 ++++---- game/tilesetmanager.py | 2 +- game/world_tools.py | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/game/components.py b/game/components.py index ed76117..2e914bf 100644 --- a/game/components.py +++ b/game/components.py @@ -57,13 +57,15 @@ def on_position_changed(entity: Entity, old: Position | None, new: Position | No if new is not None: entity.tags.add(new) +from numpy.typing import NDArray @attrs.define(frozen=True) class Graphic: """An entities icon and color.""" ch: int = ord("!") - fg: tuple[int, int, int] = (255, 255, 255) + fg: NDArray = (255, 255, 255, 255) + bg: NDArray = (0, 0, 0, 0) Action: Final = ("Action", Callable[[Entity], None]) """Possible action.""" diff --git a/game/screens/game_screens.py b/game/screens/game_screens.py index 96997b5..fdc1985 100644 --- a/game/screens/game_screens.py +++ b/game/screens/game_screens.py @@ -62,7 +62,7 @@ def _draw_entity(entity: tcod.ecs.Entity, camera_pos, camera_radius_x, camera_ra map_pos = world_pos_to_map_pos(pos) if g.world[None].components[Map].fov[map_pos.y, map_pos.x]: graphic = entity.components[Graphic] - g.foreground.rgb[["ch", "fg"]][screen_pos.y + camera_radius_y, screen_pos.x + camera_radius_x] = graphic.ch, graphic.fg + g.foreground.rgba[["ch", "fg", "bg"]][screen_pos.y + camera_radius_y, screen_pos.x + camera_radius_x] = graphic.ch, graphic.fg, graphic.bg @attrs.define() @@ -105,16 +105,16 @@ class MainScreen(Screen): in_map = 0 <= map_pos.x < map.width and 0 <= map_pos.y < map.height in_fov = in_map and map.fov[map_pos.y,map_pos.x] if not in_fov: - console.rgb[["ch","fg"]][j, i] = 0x2591, (50,50,50) + console.rgba[["ch","fg"]][j, i] = 0x2591, (50,50,50, 255) continue walkable = (not in_map) or map.walkable[map_pos.y, map_pos.x] if walkable: - console.rgb[["ch","fg"]][j, i] = FLOOR_CHAR, (70,70,70) + console.rgba[["ch","fg"]][j, i] = FLOOR_CHAR, (70,70,70, 255) continue ch = VERTICAL_WALL_CHAR if map.walkable[map_pos.y+1, map_pos.x] and world_pos+Position(0,1) not in doors: ch = WALL_CHAR - console.rgb[["ch","fg"]][j, i] = ch, (255,255,255) + console.rgba[["ch","fg"]][j, i] = ch, (255,255,255, 255) # draw all entities that are not actors for entity in g.world.Q.all_of(components=[Position, Graphic]).none_of(tags=[IsActor]): diff --git a/game/tilesetmanager.py b/game/tilesetmanager.py index d3aecc5..e8576f7 100644 --- a/game/tilesetmanager.py +++ b/game/tilesetmanager.py @@ -18,7 +18,7 @@ def valid_tileset(): "Oryx/oryx_roguelike_2.0/Terrain.png", columns=16, rows=11, charmap=[i for i in range(255)] ) - tileset.set_tile(ord('@'), monstertiles.get_tile(1)) + tileset.set_tile(ord('@'), tile=monstertiles.get_tile(1)) tileset.set_tile(ord('/'), terraintiles.get_tile(ord('?'))) tileset.set_tile(ord('|'), terraintiles.get_tile(ord('!'))) tileset.set_tile(ord('_'), terraintiles.get_tile(ord('0'))) diff --git a/game/world_tools.py b/game/world_tools.py index df06f11..d493862 100644 --- a/game/world_tools.py +++ b/game/world_tools.py @@ -50,7 +50,7 @@ def new_world() -> Registry: world.new_entity( components={ Position: player_pos, - Graphic: Graphic(ch=ord('@'), fg=(255, 0, 0)), + Graphic: Graphic(ch=ord('@'), fg=(255, 0, 0, 255), bg=(255, 255, 255, 0)), Gold: 0 }, tags=[IsActor, IsPlayer] @@ -60,7 +60,7 @@ def new_world() -> Registry: world.new_entity( components={ Position: Position(rng.randint(0, 20), rng.randint(0, 20)), - Graphic: Graphic(ord("$"), fg=(255, 255, 0)), + Graphic: Graphic(ord("$"), fg=(255, 255, 0, 255)), Gold: rng.randint(1, 10) }, tags=[IsItem]