stuff renders now, but we still got no alpha channel on the foreground console.... 🤦
This commit is contained in:
parent
c17cef8bfe
commit
64e4e4f437
4 changed files with 21 additions and 8 deletions
6
g.py
6
g.py
|
|
@ -24,6 +24,12 @@ screens: list[Screen] = []
|
||||||
console: tcod.console.Console
|
console: tcod.console.Console
|
||||||
"""The current main console."""
|
"""The current main console."""
|
||||||
|
|
||||||
|
foreground: tcod.console.Console
|
||||||
|
"""The foreground console"""
|
||||||
|
|
||||||
|
background: tcod.console.Console
|
||||||
|
"""The background console"""
|
||||||
|
|
||||||
tileset: tcod.tileset.Tileset
|
tileset: tcod.tileset.Tileset
|
||||||
"""The tileset to use"""
|
"""The tileset to use"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,16 @@ def main_draw() -> None:
|
||||||
"""Render and present the active screen."""
|
"""Render and present the active screen."""
|
||||||
if not g.screens:
|
if not g.screens:
|
||||||
return
|
return
|
||||||
g.console.clear()
|
g.background.clear()
|
||||||
g.screens[-1].on_draw(g.console)
|
g.foreground.clear()
|
||||||
|
g.screens[-1].on_draw(g.background)
|
||||||
# g.context.present(g.console)
|
# g.context.present(g.console)
|
||||||
g.sdl_renderer.copy(g.console_render.render(g.console))
|
|
||||||
|
g.sdl_renderer.copy(g.console_render.render(g.background))
|
||||||
|
|
||||||
|
# g.sdl_renderer.copy(g.console_render.render(g.foreground))
|
||||||
|
g.foreground.blit(g.background, fg_alpha=1.0, bg_alpha=0.0)
|
||||||
|
g.sdl_renderer.copy(g.console_render.render(g.background))
|
||||||
g.sdl_renderer.present()
|
g.sdl_renderer.present()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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.console.rgb[["ch", "fg"]][screen_pos.y + camera_radius_y, screen_pos.x + camera_radius_x] = graphic.ch, graphic.fg
|
g.foreground.rgb[["ch", "fg"]][screen_pos.y + camera_radius_y, screen_pos.x + camera_radius_x] = graphic.ch, graphic.fg
|
||||||
|
|
||||||
|
|
||||||
@attrs.define()
|
@attrs.define()
|
||||||
|
|
|
||||||
9
main.py
9
main.py
|
|
@ -18,10 +18,11 @@ def main() -> None:
|
||||||
|
|
||||||
#tcod.tileset.procedural_block_elements(tileset=tileset)
|
#tcod.tileset.procedural_block_elements(tileset=tileset)
|
||||||
g.screens = [MainMenu()]
|
g.screens = [MainMenu()]
|
||||||
g.console = tcod.console.Console(80, 35)
|
g.background = tcod.console.Console(80, 35)
|
||||||
|
g.foreground = tcod.console.Console(80, 35)
|
||||||
g.sdl_window = tcod.sdl.video.new_window(
|
g.sdl_window = tcod.sdl.video.new_window(
|
||||||
g.console.width * g.tileset.tile_width,
|
g.background.width * g.tileset.tile_width,
|
||||||
g.console.height * g.tileset.tile_height,
|
g.background.height * g.tileset.tile_height,
|
||||||
flags=tcod.lib.SDL_WINDOW_RESIZABLE,
|
flags=tcod.lib.SDL_WINDOW_RESIZABLE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -30,7 +31,7 @@ def main() -> None:
|
||||||
|
|
||||||
g.console_render = tcod.render.SDLConsoleRender(atlas=g.atlas)
|
g.console_render = tcod.render.SDLConsoleRender(atlas=g.atlas)
|
||||||
|
|
||||||
with tcod.context.new(console=g.console, tileset=g.tileset) as g.context:
|
with tcod.context.new(console=g.background, tileset=g.tileset) as g.context:
|
||||||
game.screens.main_loop()
|
game.screens.main_loop()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue