< index < 2. Console emulator < 2.4 Using off-screen consoles |
===================================== |
C++ : static void blit(const TCODConsole *src,int xSrc, int ySrc, int wSrc, int hSrc, TCODConsole *dst, int xDst, int yDst, int fade=255) C : void TCOD_console_blit(TCOD_console_t src,int xSrc, int ySrc, int wSrc, int hSrc, TCOD_console_t dst, int xDst, int yDst, int fade) Py : console_blit(src,xSrc,ySrc,xSrc,hSrc,dst,xDst,yDst,fade)This function allows you to blit a rectangular area of the source console at a specific position on a destination console. It can also simulate alpha transparency with the fade parameter.
Parameter | Description |
---|---|
src | The source console that must be blitted on another one. |
xSrc, ySrc, wSrc, hSrc | The rectangular area of the source console that will be blitted. |
dst | The destination console. |
xDst, yDst | Where to blit the upper-left corner of the source area in the destination console. |
fade | Alpha transparency of the blitted console. 0 => The source console is completely transparent. This function does nothing. 255 => The source console is opaque. Its cells replace the destination cells. 0 < fade < 255 => The source console is partially blitted, simulating real transparency. |
C++ : TCODConsole *off1 = new TCODConsole(80,50); TCODConsole *off2 = new TCODConsole(80,50); ... print screen1 on off1 ... print screen2 of off2 // render screen1 in the game window TCODConsole::blit(off1,0,0,80,50,TCODConsole::root,0,0,255); TCODConsole::flush(); // wait or a keypress TCODConsole::waitForKeypress(true); // do a cross-fading from off1 to off2 for (int i=1; i <= 255; i++) { TCODConsole::blit(off1,0,0,80,50,TCODConsole::root,0,0,255); // renders the first screen (opaque) TCODConsole::blit(off2,0,0,80,50,TCODConsole::root,0,0,i); // renders the second screen (transparent) TCODConsole::flush(); } C : TCOD_console_t off1 = TCOD_console_new(80,50); TCOD_console_t off2 = TCOD_console_new(80,50); int i; ... print screen1 on off1 ... print screen2 of off2 /* render screen1 in the game window */ TCOD_console_blit(off1,0,0,80,50,NULL,0,0,255); TCOD_console_flush(); /* wait or a keypress */ TCOD_console_wait_for_keypress(true); /* do a cross-fading from off1 to off2 */ for (i=1; i <= 255; i++) { TCOD_console_blit(off1,0,0,80,50,NULL,0,0,255); /* renders the first screen (opaque) */ TCOD_console_blit(off2,0,0,80,50,NULL,0,0,i); /* renders the second screen (transparent) */ TCOD_console_flush(); } Py : off1 = libtcod.console_new(80,50) off2 = libtcod.console_new(80,50) ... print screen1 on off1 ... print screen2 of off2 # render screen1 in the game window libtcod.console_blit(off1,0,0,80,50,0,0,0,255) libtcod.console_flush() # wait or a keypress libtcod.console_wait_for_keypress(True) # do a cross-fading from off1 to off2 for i in range(1,256) : litbcod.console_blit(off1,0,0,80,50,0,0,0,255) # renders the first screen (opaque) litbcod.console_blit(off2,0,0,80,50,0,0,0,i) # renders the second screen (transparent) litbcod.console_flush()
C++ : void TCODConsole::setKeyColor(const TCODColor &col) C : void TCOD_console_set_key_color(TCOD_console_t con,TCOD_color_t col) Py : console_set_key_color(con,col)This function defines a transparent background color for an offscreen console. All cells with this background color are ignored by the blit operation. You can use it to blit only some parts of the console.
Parameter | Description |
---|---|
con | In the C version, the offscreen console handler or NULL for the root console. |
col | The transparent background color. |