keine ahnung...

This commit is contained in:
staubsauger 2024-08-19 15:47:27 +02:00
parent 64e4e4f437
commit 68aa90cac8
4 changed files with 10 additions and 8 deletions

View file

@ -57,13 +57,15 @@ def on_position_changed(entity: Entity, old: Position | None, new: Position | No
if new is not None: if new is not None:
entity.tags.add(new) entity.tags.add(new)
from numpy.typing import NDArray
@attrs.define(frozen=True) @attrs.define(frozen=True)
class Graphic: class Graphic:
"""An entities icon and color.""" """An entities icon and color."""
ch: int = ord("!") 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]) Action: Final = ("Action", Callable[[Entity], None])
"""Possible action.""" """Possible action."""

View file

@ -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) map_pos = world_pos_to_map_pos(pos)
if g.world[None].components[Map].fov[map_pos.y, map_pos.x]: if g.world[None].components[Map].fov[map_pos.y, map_pos.x]:
graphic = entity.components[Graphic] 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() @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_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] in_fov = in_map and map.fov[map_pos.y,map_pos.x]
if not in_fov: 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 continue
walkable = (not in_map) or map.walkable[map_pos.y, map_pos.x] walkable = (not in_map) or map.walkable[map_pos.y, map_pos.x]
if walkable: 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 continue
ch = VERTICAL_WALL_CHAR ch = VERTICAL_WALL_CHAR
if map.walkable[map_pos.y+1, map_pos.x] and world_pos+Position(0,1) not in doors: if map.walkable[map_pos.y+1, map_pos.x] and world_pos+Position(0,1) not in doors:
ch = WALL_CHAR 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 # draw all entities that are not actors
for entity in g.world.Q.all_of(components=[Position, Graphic]).none_of(tags=[IsActor]): for entity in g.world.Q.all_of(components=[Position, Graphic]).none_of(tags=[IsActor]):

View file

@ -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)] "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('!'))) tileset.set_tile(ord('|'), terraintiles.get_tile(ord('!')))
tileset.set_tile(ord('_'), terraintiles.get_tile(ord('0'))) tileset.set_tile(ord('_'), terraintiles.get_tile(ord('0')))

View file

@ -50,7 +50,7 @@ def new_world() -> Registry:
world.new_entity( world.new_entity(
components={ components={
Position: player_pos, 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 Gold: 0
}, },
tags=[IsActor, IsPlayer] tags=[IsActor, IsPlayer]
@ -60,7 +60,7 @@ def new_world() -> Registry:
world.new_entity( world.new_entity(
components={ components={
Position: Position(rng.randint(0, 20), rng.randint(0, 20)), 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) Gold: rng.randint(1, 10)
}, },
tags=[IsItem] tags=[IsItem]