texture render pain
This commit is contained in:
parent
6cfa795463
commit
06dda08e8e
3 changed files with 24 additions and 10 deletions
|
|
@ -53,15 +53,21 @@ def main_draw() -> None:
|
|||
if not g.screens:
|
||||
return
|
||||
g.background.clear()
|
||||
g.foreground.clear()
|
||||
g.foreground.rgba["bg"][:] = 0
|
||||
g.foreground.rgba["fg"][:] = 0
|
||||
g.screens[-1].on_draw(g.background)
|
||||
# g.context.present(g.background)
|
||||
|
||||
g.sdl_renderer.copy(g.console_render.render(g.background))
|
||||
# g.sdl_renderer.copy(g.console_render.render(g.background))
|
||||
# g.foreground.blit(g.background, fg_alpha=1.0, bg_alpha=0.0)
|
||||
bg_tex = g.console_render.render(g.background)
|
||||
bg_tex.blend_mode = 1
|
||||
|
||||
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))
|
||||
with g.sdl_renderer.set_render_target(bg_tex):
|
||||
fg_tex = g.console_render.render(g.foreground)
|
||||
fg_tex.blend_mode = 1
|
||||
g.sdl_renderer.copy(fg_tex)
|
||||
g.sdl_renderer.copy(bg_tex)
|
||||
g.sdl_renderer.present()
|
||||
|
||||
|
||||
|
|
@ -114,5 +120,7 @@ def draw_previous_screens(screen: Screen, console: tcod.console.Console, dim: bo
|
|||
return
|
||||
prev_screen.on_draw(console)
|
||||
if dim and screen is g.screens[-1]:
|
||||
console.rgb["fg"] //= 4
|
||||
console.rgb["bg"] //= 4
|
||||
g.foreground.rgb["fg"] //= 4
|
||||
g.foreground.rgb["bg"] //= 4
|
||||
g.background.rgb["fg"] //= 4
|
||||
g.background.rgb["bg"] //= 4
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class MainScreen(Screen):
|
|||
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.rgba[["ch","fg"]][j, i] = ch, (255,255,255, 255)
|
||||
console.rgba[["ch", "fg", "bg"]][j, i] = ch, (255,255,255, 255), (0,0,0,0)
|
||||
|
||||
# draw all entities that are not actors
|
||||
for entity in g.world.Q.all_of(components=[Position, Graphic]).none_of(tags=[IsActor]):
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
## returns a valid tileset
|
||||
|
||||
import tcod.tileset
|
||||
|
||||
from numpy.typing import NDArray
|
||||
def valid_tileset():
|
||||
tileset = tcod.tileset.load_tilesheet(
|
||||
"data/Bmac_smooth_16x24.png", columns=16, rows=16, charmap=tcod.tileset.CHARMAP_CP437
|
||||
|
|
@ -18,11 +18,17 @@ 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('@'), tile=monstertiles.get_tile(1))
|
||||
player = monstertiles.get_tile(1)
|
||||
player = [[[r,g,b,a] if a > 0 else [0,0,0,0]
|
||||
for r,g,b,a in row]
|
||||
for row in player]
|
||||
|
||||
tileset.set_tile(ord('@'), player)
|
||||
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('/')))
|
||||
tileset.set_tile(ord('.'), terraintiles.get_tile(20))
|
||||
tileset.set_tile(ord(','), terraintiles.get_tile(12))
|
||||
print(tileset.get_tile(ord('@'))[10])
|
||||
return tileset
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue