When running the code I has written following part 1 of the tutorial, I noticed the application window closed directly after opening. Running the program using the debugger, I see there's a segmentation fault, signaled at line 20 (and, if you comment it out, also 21).
So what's not working is TCODConsole::root->clear(); and TCODConsole:root->putChar();.
Here's the full code:
#include "libtcod.hpp"
int main()
{
int playerx = 40, playery = 25;
TCODConsole::initRoot(10,10, "The Roguelike of the Nallebjörn",false);
while (!TCODConsole::isWindowClosed())
{
TCOD_key_t key;
TCODSystem::checkForEvent(TCOD_EVENT_KEY_PRESS, &key, NULL);
switch (key.vk)
{
case TCODK_UP: playery--; break;
case TCODK_DOWN: playery++; break;
case TCODK_LEFT: playerx--; break;
case TCODK_RIGHT: playerx++; break;
default:break;
}
TCODConsole::root->clear();
TCODConsole::root->putChar(playerx,playery, '@');
TCODConsole::flush();
}
return 0;
}
So what's wrong? Seems very much like something's wrong with the root pointer to me... If you need more info (got a feeling you do, but not sure about what you have to know), tell me and I'll be happy to help you help me :)
I had tried replacing my libtcod with the one in reply #6 without luck earlier... However, I forgot replacing the libtcod DLL files with with new ones.
If anyone could explain why the linked version (compiled with GCC 4.7) works, but not the standard one, downloaded from the official website, I'd bee very happy, though.