Difference between revisions of "Complete roguelike tutorial using modern C++ and libtcod - Part 1: Setting Up"

From RogueBasin
Jump to navigation Jump to search
 
Line 43: Line 43:
     root->flush();
     root->flush();
      
      
     while ( !TCODConsole::isWindowClosed() )  
     while ( !root->isWindowClosed() )  
     {
     {
         TCOD_key_t key;
         TCOD_key_t key;

Latest revision as of 04:56, 3 February 2020

Setup

Windows

Set up Visual Studio Community, optionally use Clang add-on


Mac

Linux

Visual Studio Code

Packages: GCC, Clang, SDL, OpenGL


tcod

Clone tcod from source

Build tcod


Tutorial 1 - Basic @

Set up using CMake

Import tcod

#include "libtcod.hpp"

int main() 
{
   TCODConsole::initRoot(
       80,
       50,
       "libtcod C++ tutorial 1",
       false,
       TCOD_RENDERER_SDL2);

   auto root = TCODConsole::root;
   
   root->flush();
   
   while ( !root->isWindowClosed() ) 
   {
       TCOD_key_t key;
       TCODSystem::waitForEvent(TCOD_EVENT_KEY_PRESS, &key, nullptr);
       
       root->clear();
       root->putChar(40,25,'@');
       root->flush();
   }
   
   return 0;
}