Saturday, August 13, 2011

roguelike tutorial: the what and why

Let's make a roguelike!

I've made a few roguelikes — mostly for myself — and I think they're a fun mix of computer science algorithms, code design decisions, and game design decisions. They are also fun to make and a great way to try new programing ideas and new game ideas.

I've created a 20 part series that I'm going to post here where I stumble my way through creating a roguelike that has most of the features any mainstream roguelike has. I consider myself a decent programmer but I'll try some things that may or may not work out and, for the sake of explanation via blog posts, cut some corners and leave out a few details. Because of that, don't take this as an example of the ideal rogulike or ideal code but if you stumble through it with me and add your own ideas, you'll have a roguelike too and, more importantly, may be better armed to make your own roguelike or contribute to someone else's roguelike.

Here's the rundown of what's to come:

Part 01: Java, Eclipse, AsciiPanel, application, applet
Part 02: input, output, modes and screens
Part 03: scrolling through random caves
Part 04: the player
Part 05: stationary monsters
Part 06: hitpoints, combat, and messages
Part 07: z levels and deeper caves
Part 08: vision, line of sight, and field of view
Part 09: wandering monsters
Part 10: items, inventory, inventory screens
Part 11: hunger and food
Part 12: weapons and armor
Part 13: aggressive monsters
Part 14: experience and leveling up
Part 15: help, examine, and look screens
Part 16: throwing and ranged weapons
Part 17: smarter monsters
Part 18: potions and effects
Part 19: mana, spells, and magic books
Part 20: item appearance and identification

Some experience with Java and object oriented programming is expected but I can answer any questions that you may have. Not only am I including the code for each part, but I've got a final version, with a few additional tweaks, running as an applet on my blog.

13 comments:

  1. Outstanding!
    It's about time someone made a tutorial on how to make a roguelike! Thanks!
    The finished game is cool and good but the screen updates slow so it's hard to play without getting angry :)

    ReplyDelete
  2. I've updated the library that it uses for display but I can't tell if it's better or not since it was working fine for me before. Hopefully the only reason to get angry now is the monsters hunting you down and the RNG tormenting you.

    ReplyDelete
  3. Sweet. Now it runs smooth and nice! Very good game & I'm looking forwards to the tutorial.
    Where can one download the game?

    ReplyDelete
  4. @Jocke
    I added links to the main jar file and the jar file that has display functionality.

    ReplyDelete
  5. Fantastic tutorial. I really appreciate the time you took to create this and am enjoying following along!

    ReplyDelete
  6. Hi Trystan, I've been recently delving into my own roguelike project, and I'm sure this tutorial will help move things along. The finished project is quite nice and fun to play! It's very simple to learn, which is how I like my roguelikes.

    Also, this is a totally coincidental encounter with you, Jocke, but I'm quite a fan of your games, especially Dark Forest 1/2!

    ReplyDelete
  7. Trystan,

    This tutorial was my first attempt at game making, much less Roguelikes, and I really liked it. I've added quite a bit to the existing tutorial code and am going to set out and make my own game implementation here soon but had a question.

    I'm trying to implement saving and loading and it's way harder than initially thought. The idea seems simple - write out the location of every tile, creature, and item to a file and read it back in and feed it to a new constructor in PlayScreen. Turns out HOW to do this is really, really hard though. Got any tips or some reading material to help get me started?

    ReplyDelete
    Replies
    1. First off: Congratulations! Game making can be much less fun than game playing and a roguelike is quite a complex achievement - even if you're just tweaking this tutorial. I ask for feedback at the end and I'd like to see what you have to say.

      For saving and loading I'd look into a library for serializing and deserializing. That's probably the easiest way. Serialize everything as xml, json, text, or binary then save it to a file. Do the reverse for loading it. I rarely use Java so I'm not sure what the best library is for that.

      Versioning is also something you'll need to look into. You'll probably want to save the version number to the save files so when loading a game you know what fields will and will not be there and can use custom serializers to load old files. That way you can change your classes and still load old saves. Different serialization libraries may make that easier or not.

      Delete
  8. Those are the essential programs which have been initiated herein and hopefully for the future would govern even better platform which is indeed considered to be more essential for the students to regard about.

    ReplyDelete
  9. So in regards to purchasing underwear, it's no longer an easy choice between boxers, briefs and boxer-briefs. If you want to get more interesting details about best mens underwear, click here now.

    ReplyDelete
  10. While blogs are primarily text-based, vlogs (video blogs) involve using videos to convey information or share experiences. Baker Of Ace Vlogging has gained popularity with the rise of platforms like YouTube, where content creators share their stories in a more visual format.

    ReplyDelete