2. Console
The console emulator handles the rendering of the game screen and the keyboard input.
Classic real time game loop:
TCODConsole::initRoot(80,50,"my game",false);
TCODSystem::setFps(25); // limit framerate to 25 frames per second
while (!endGame && !TCODConsole::isWindowClosed()) {
TCOD_key_t key;
TCODSystem::checkForEvent(TCOD_EVENT_KEY_PRESS,&key,NULL);
updateWorld (key, TCODSystem::getLastFrameLength());
// updateWorld(TCOD_key_t key, float elapsed) (using key if key.vk != TCODK_NONE)
// use elapsed to scale any update that is time dependant.
// ... draw world+GUI on TCODConsole::root
TCODConsole::flush();
}
Classic turn by turn game loop:
TCODConsole::initRoot(80,50,"my game",false);
while (!endGame && !TCODConsole::isWindowClosed()) {
// ... draw on TCODConsole::root
TCODConsole::flush();
TCOD_key_t key;
TCODConsole::waitForEvent(TCOD_EVENT_KEY_PRESS,&key,NULL,true);
//... update world, using key
}