Tuesday, August 30, 2011

Libtcod in C#: I give up

   No not on Libtcod but instead on trying to program a roguelike without something like it. I don't currently know enough about putting pictures on screen to make what I want on my own. I "tried" in the 7DRL but used a library to display the screen and it did not allow me the control of the the console that I wanted.
   I have given up and thus can proceed with it as Libtcod does all that I need and then some. I actually have my recursive shadow casting code all tidied up into a library so I could technically use it but Libtcod comes with basically the same code already built in so using my library would just add another complication. I could just use the generic C# random number generator but Libtcod has a slightly better generator and allows me to specify the seed so I can get the same string of numbers whenever I want.
   I do however still plan to work on the pathfinding myself as it interests me and I want to see what I can do with it before just using Libtcod's built in pathfinding.
   There may be a few posts on Libtcod in specific and the Roguelike I will be slapping together but nothing is certain as Collage just started up on Monday so my schedule may less free time in it real soon. Anyway a few things I picked up while testing Libtcod.

  • The libtcod 1.5.1 c# download did not have terminal.png in it which is the default font so your code will fail for lack of it. To get it you can get any of the other 1.5.1 downloads and maybe any of the downloads though I have only checked the 1.5.1 versions. (or just change the default font if you happen to have another just laying around)
  • You need libtcod-net-unmanaged.dll in the same folder as your .exe and libtcod-VS.dll needs to be with it. libtcod-VS.dll also needs to be in the same folder as libtcod-net.dll so basicly its easier to have them all just in there with your exe. A quick list of what I had in with the exe to get libtcod running correctly:
    • libtcod-net.dll
    • libtcod-net-unmanaged.dll
    • libtcod-VS.dll
    • SDL.dll
    • zlib1.dll
    • terminal.png
  • I use Microsoft Visual Studios for this as I get a good version of it free through collage. Making the game as a console app works fine though normally you would have the blank console that normally appears as well as the game console made by Libtcod. You can get rid of the blank one through project properties and changing output type from console application to windows application.
  • libtcod-net.dll is the one you add as a reference, you don't need to add any of the others.
Overall I like what I saw once I got libtcod working right and I had figured out what I needed to do. The documentation for libtcod 1.5.1 is Here though it seems the C# stuff needs a lot of work to actually reflect reality as it is but overall is quite helpful. Of course I will probably do a post about the basic stuff and what I observed happening anyway.


  1. "Of course I will probably do a post about the basic stuff and what I observed happening anyway."

    Did that ever happen? If not, make it so!

  2. ...

    Its in the works though I won't promise anything.

  3. I found all these things out the hard way and fixed them before discovering your post, so I can confirm they work. Renaming the supplied garamond font to terminal did not do the trick as expected, I had to hunt the original terminal.png down from their repo.

    I was going to tell you not to give up -- but now that I've solved all the problems of getting this working in c# express, I'm staring at an "@" symbol with coder's block. Go figure.

    7DRL is coming up next week, good time to get back up on the horse.