< index
< 2. Console emulator
< 2.1 Initializing the console

=====================================
2.1.8 Showing credits for libtcod
=====================================

You can print a "Powered by libtcod x.y.z" screen during your game startup simply by calling this function after initRoot :

C++ : static void TCODConsole::credits()
C   : void TCOD_console_credits()
Py  : console_credits()

The credits screen can be skipped by pressing any key.
Example :

C++ : TCODConsole::initRoot(80,50,"The Chronicles Of Doryen v0.1",false); // initialize the root console
      TCODConsole::credits(); // print the credits page
      // your game here...
C   : TCOD_console_init_root(80,50,"The Chronicles Of Doryen v0.1",false);
      TCOD_console_credits();
Py  : libtcod.console_init_root(80,50,"The Chronicles Of Doryen v0.1",False)
      libtcod.console_credits()



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 :

C++ : static bool TCODConsole::renderCredits(int x, int y, bool alpha)
C   : bool TCOD_console_credits_render(int x, int y, bool alpha)
Py  : console_credits_render(x, y, alpha)

ParameterDescription
x,yPosition of the credits text in your root console
alphaIf 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.
This function returns true when the credits screen is finished, indicating that you no longer need to call it.
Example :

C++ : 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();
      }
C   : 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();
      }
Py  : 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()

insert a comment