New articles at Beginner’s Guide to Roguelikes in C/C++

Earlier I wrote about the Beginner’s Guide to Roguelikes in C/C++. The author has updated the tutorial with some new stuff, including NPC characters. The new articles are

The 7th article is all about writing NPC that can randomly wander around the map. This article has a gentle introduction into OOP, by creating class for Actor (who currently is used for NPCs, but I suspect will be used for player character too).

The 8th article especially was interesting to read, because, in progress of adding multiple NPCs, he explains three different ways of doing it and some of the ramifications of each of them. After all, it pays to think of these things some before committing to a specific implementation. You can of course change it later, but it might be harder at that point.

The 9th article breaks the code into smaller chunks and shows how it makes things more manageable. Very useful skill to have, since navigating a huge source file gets tedious pretty quickly.

When I was trying out the previous articles, I was having some trouble with console library (instead of @, I kept getting floating point number on screen). Craig was really helpful and made some changes in his console library to get it working on my system too (I’m using CodeLite with MinGW). So if you had the same problem, try again and see if it works now.

The guide can be found here.


Roguelike tutorial in C/C++

I stumbled upon something neat: Beginner’s Guide to Roguelikes in C/C++. Craig Stickel has been writing a tutorial on how to write own roguelike in C/C++. Currently all the articles are from the point of view of C, but judging on the index page, C++ stuff is on the horizon.

What I really like about the articles is that they always have something tanglible at the end. So if you stick to it, read the article through and code, you’ll end up with a new feature. Constant progress is very important when learning something new after all. He also provides full source code, so in case of copy/paste error, you can still get the program up and running.

Maybe I should try to write something similar in the future, when I have a bit more ready for my own project. Could do it from the point of view of using pyherc as a platform to create roguelike game. There are beginnings of the documentation online already, but should polish up things a lot more before it’s useful as a platform.

Time to reflect

No, this is not about special effects and environmental mapping in 3D-graphics, but about the experience of writing the game so far. Reason I’m writing this is, that I hit 501 commits today and thought it might be a good time to look back.

pyherc is my pet project that I have been working in a form or another for years. It all started back in the 90s, when I wanted to program the greatest rpg-game ever. I was using Turbo Pascal back then and learned quite a bit about basics of object oriented programming, but never got the game even to run.

Next try was some years later when I started learning C/C++ and tried writing the game again. Success was about as good as with Turbo Pascal (so, I learned how objects work in C/C++ and how easy it is to get tangled to little details), but again I didn’t get a playable game.

Then came Java and I thought it would be useful language to learn (I also liked the amount of libraries available out there) and I started hacking the code together. This time I actually got runnable game, where you could walk around, pick up and eat bananas and kill some randomly wandering monsters. This was also the first time I was exposed to unit testing. I wrote some of those, but the approach was not very structured or disciplined. Despite of that, I quickly realised that writing unit tests was good way to catch bugs before you could even run the code in actual game. Eventually I gave up with the game though and abandoned it.

Latest try has been written with Python. So far the results have been much better than before. I have playable game (albeit very basic) with extensive test cases around it. I’m trying to maintain healthy pace (not coding too much, not abandoning the project completely), while learning and trying out new things (inversion of control, dependency injection, doctests and so on). The game isn’t anything particularly special, but I’m quite proud that I finally got this far. Lets see where next 500 commits will take me.