Complete Roguelike Tutorial, using python+libtcod
Hi there!
|
Complete Roguelike Tutorial, using Python+libtcod
Short introduction
Welcome!
Welcome to this tutorial! As you probably guessed, the goal is to have a one-stop-shop for all the info you need on how to build a good Roguelike from scratch. We hope you find it useful! But first, some quick Q&A.
Why Python?
Anyone familiar with this language will tell you it's fun! This tutorial would probably be much harder without it. We recommend that you install Python 2.6 and go through at least the first parts of the [Python Tutorial http://docs.python.org/tutorial/]. This tutorial will be much easier if you experimented with the language first. Remember that the [Python Library Reference http://docs.python.org/library/index.html] is your friend -- the standard library has everything you might need and when programming you should be ready to search it for help on any unknown function you might encounter.
Why libtcod?
If you haven't seen it in action yet, check out the [features http://doryen.eptalys.net/libtcod/features/] and [some projects http://doryen.eptalys.net/libtcod/projects/] where it was used successfully. It's extremely easy to use and has tons of useful functions specific to RLs.
Graphics
Setting it up
Ok, now that we got that out of our way let's get our hands dirty! If you haven't yet, [download and install Python 2.6 http://www.python.org/download/]. Other versions may work but then you'd have to smite any incompatibilities (though they shouldn't be too many). Then [download libtcod http://doryen.eptalys.net/libtcod/download/] and extract it somewhere. If you're on Windows, the choice between the Visual Studio and Mingw version shouldn't matter since we're using Python.
Now to create your project's folder. Create an empty file with a name of your choice, like firstrl.py. The easiest way to use libtcod is to copy the following files to your project's folder:
- libtcodpy.py
- libtcod-mingw.dll or libtcod-VS.dll on Windows, libtcod.so on Linux
- SDL.dll on Windows, SDLlib.so on Linux
- A font from the fonts folder. We chose celtic_garamond_10x10_gs_tc.png.
Levels
The code includes a simple algorithm, it's just a sequence of rooms, each one connected to the next through a tunnel. The overlaps make it look more complex than may be apparent at first though.
Missing sections
Here are some quick guidelines for the next sections. Remember the goal is to create a RL that feels complete, but with minimal fluff so anyone can do it. The sections are not set in stone, they're open to debate and will surely go through many changes.
Stats
HP/Attack/Defense, for both the player and every monster. (I'm sure this is one of those areas where a beginner would love to tinker and it's pretty easy to add other stats.)
Items
Additive HP/Attack/Defense modifiers when worn. A string determines its class. Can equip one item of every class (weapon, armor, helmet...). Item screen with drop and use options (use equips/dequips stuff). (Should be relatively easy in python at least, where list support is awesome.)
Combat
Damage = Attack - Defense, or something. Would be cool to have a special graphical effect tied to wands and staffs (which would just be weapons with different names).
AI
Cast ray to player, if unblocked move towards, if near it, attack.