2.1.6. libtcod's credits
Use these functions to display credits, as seen in the samples.
Using a separate credit page
You can print a "Powered by libtcod x.y.z" screen during your game startup simply by calling this function after initRoot.
The credits screen can be skipped by pressing any key.
static void TCODConsole::credits()
void TCOD_console_credits()
console_credits()
static void TCODConsole::credits()
tcod.console.credits()
Embedding credits in an existing page
You can also print the credits on one of your game screens (your main menu for example) by calling this function in your main loop.
This function returns true when the credits screen is finished, indicating that you no longer need to call it.
static bool TCODConsole::renderCredits(int x, int y, bool alpha)
bool TCOD_console_credits_render(int x, int y, bool alpha)
bool TCOD_console_credits_render(int x, int y, bool alpha)
static bool TCODConsole::renderCredits(int x, int y, bool alpha)
tcod.console.renderCredits(x, y, alpha)
Parameter | Description |
---|---|
x,y | Position of the credits text in your root console |
alpha | If true, credits are transparently added on top of the existing screen. For this to work, this function must be placed between your screen rendering code and the console flush. |
Example:
TCODConsole::initRoot(80,50,"The Chronicles Of Doryen v0.1",false); // initialize the root console
bool endCredits=false;
while ( ! TCODConsole::isWindowClosed() ) { // your game loop
// your game rendering here...
// render transparent credits near the center of the screen
if (! endCredits ) endCredits=TCODConsole::renderCredits(35,25,true);
TCODConsole::flush();
}
TCOD_console_init_root(80,50,"The Chronicles Of Doryen v0.1",false);
bool end_credits=false;
while ( ! TCOD_console_is_window_closed() ) {
// your game rendering here...
// render transparent credits near the center of the screen
if (! end_credits ) end_credits=TCOD_console_credits_render(35,25,true);
TCOD_console_flush();
}
libtcod.console_init_root(80,50,"The Chronicles Of Doryen v0.1",False)
end_credits=False
while not libtcod.console_is_window_closed() :
// your game rendering here...
// render transparent credits near the center of the screen
if (not end_credits ) : end_credits=libtcod.console_credits_render(35,25,True)
libtcod.console_flush()
tcod.console.initRoot(80,50,"The Chronicles Of Doryen v0.1") -- initialize the root console
endCredits=false
while not tcod.console.isWindowClosed() do -- your game loop
-- your game rendering here...
-- render transparent credits near the center of the screen
if not endCredits then endCredits=tcod.console.renderCredits(35,25,true) end
tcod.console.flush()
end
Restart the credits animation
When using rederCredits, you can restart the credits animation from the begining before it's finished by calling this function.
static void TCODConsole::resetCredits()
void TCOD_console_credits_reset()
console_credits_reset()
static void TCODConsole::resetCredits()
tcod.console.resetCredits()