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()) {
// ... draw on TCODConsole::root
TCODConsole::flush();
TCOD_key_t key = TCODConsole::checkForKeypress();
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.
}
tcod.console.initRoot(80,50,"my game", false)
root=libtcod.TCODConsole_root
tcod.system.setFps(25)
while not tcod.console.isWindowClosed() do
-- ... draw on root
tcod.console.flush()
key=tcod.console.checkForKeypress()
-- ... update world, using key and tcod.system.getLastFrameLength
end
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::waitForKeypress(true);
//... update world, using key
}