keine ahnung...
This commit is contained in:
parent
64e4e4f437
commit
68aa90cac8
4 changed files with 10 additions and 8 deletions
|
|
@ -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."""
|
||||
|
|
|
|||
|
|
@ -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]):
|
||||
|
|
|
|||
|
|
@ -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')))
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue