< index
< 2. Console emulator
< 2.4 Using off-screen consoles

=====================================
2.4.1 Creating an offscreen console
=====================================

C++ : TCODConsole::TCODConsole(int w, int h)
C   : TCOD_console_t TCOD_console_new(int w, int h)
Py  : console_new(w,h)

You can create as many off-screen consoles as you want by using this function. You can draw on them as you would do with the root console, but you cannot flush them to the screen. Else, you can blit them on other consoles, including the root console. See blit. The C version of this function returns a console handler that you can use in most console drawing functions.
ParameterDescription
w,hThe console size.
0 < w
0 < h
Example :
Creating a 40x20 offscreen console, filling it with red and blitting it on the root console at position 5,5

C++ : TCODConsole *offscreenConsole = new TCODConsole(40,20);
      offscreenConsole->setBackgroundColor(TCODColor::red);
      offscreenConsole->clear();
      TCODConsole::blit(offscreenConsole,0,0,40,20,TCODConsole::root,5,5,255);
C   : TCOD_console_t offscreen_console = TCOD_console_new(40,20);
      TCOD_console_set_background_color(offscreen_console,TCOD_red);
      TCOD_console_clear(offscreen_console);
      TCOD_console_blit(offscreen_console,0,0,40,20,NULL,5,5,255);
Py  : offscreen_console = libtcod.console_new(40,20)
      libtcod.console_set_background_color(offscreen_console,libtcod.red)
      libtcod.console_clear(offscreen_console)
      libtcod.console_blit(offscreen_console,0,0,40,20,0,5,5,255)

insert a comment