Complete roguelike tutorial using modern C++ and libtcod - Part 1: Setting Up

From RogueBasin
Jump to: navigation, search

Contents

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;
}
Personal tools