• Hi folks…. this week I’ve been rushing to prepare my home in the woods for the storm, and I apologize that this post is a few days late. Now that I’m done cutting, splitting, and stacking firewood, tying down tarps, and shoveling walkways, I’d like to get in the spirit of Thanksgiving and talk about some open source tools for which I am very grateful… valgrind, sqlite3, and SDL.

    Maine Blizzard

    A blizzard arrives Found Time Games headquarters. (i.e. My House)

    1) Valgrind is an amazing tool for C and C++ programmers. While it has many capabilities, my favorite way to use it is to check my game for memory leaks. Even a basic 2d game engine can get complicated really quickly… Jumpsmith loads a bunch of data from the hard drive, and valgrind can see if any objects should have been freed from memory when the game closes. If you are just getting into programming in C or C++, you should set up valgrind right away. It’s free, and it can save you from a lot of trouble. Here’s the command I use when I do a leak check with valgrind on a command line:

    valgrind -v –track-origins=yes –leak-check=full –show-reachable=yes ./game > valgrind_out 2>&1

    If you run this, you’ll want to replace ./game with the path to the executable for your game. The text file that it spits out will be called valgrind_out. Your game will be slow during the test, but you’ll get a detailed report of exactly which lines of code left a memory mess.

    Valgrind's logo... maybe they're saying that they make memory problems as defeatable as paper dragons?

    Valgrind’s logo… maybe they’re saying that they make memory problems as defeatable as paper dragons?

    2) Sqlite is a serverless, zero-configuration, transactional SQL database engine. It is nearly ubiquitous… all Android and iOS devices have it installed by default, as well as Mac and Linux. It is a pain to use CSV (comma separated value) files for game data. Super Pooper used CSVs, and it sucked when I wanted to add or change features. I learned from my mistakes; all of the joystick data, game worlds, and player profiles of Jumpsmith are stored in sqlite databases. As I’ve evolved the game mechanics, it has been really easy to update the game world files with a nice little SQL statement. Also, if players want to make wacky scripts that edit Jumpsmith levels or create procedural content, most scripting languages have a sqlite3 API. Sqlite3 is public domain, so you can use it for commercial software.

    Sqlite3 Logo

    As they say, “Small. Fast. Reliable. Choose any 3.”

    3) Simple DirectMedia Layer is an open source gaming library. It provides a layer of abstraction between you and the user’s OS. You can use SDL functions to create a window, get mouse, keyboard, and joystick events, play sound, load images, do threading, etc. It has been used by many games, such as:

    -Amnesia

    -Antichamber

    -Fez

    -FTL

    -Cave Story

    -Don’t Starve

    -Mark of the Ninja

    -Super Meat Boy

    -Braid

    -Trine 2

    -Rogue Legacy

    -VVVVVV

    Note: I made this list by searching the Games directory on my Linux laptop for SDL files. Some of these games have other versions that do not use SDL.

    SDL2 is the latest major version, and it runs on PC, Mac, Linux, iOS, and Android. That’s right- you can write a game in C or C++, and then recompile it for 5 major systems, and probably not have to change a line of code. I’ve seen a video of a PC game that was recompiled for iOS, and SDL interpreted the screen touches as mouse events, and the game was playable without changing any code. Of course, if you want to get a little more in-depth with handling mobile-specific stuff, SDL can handle events like Low Memory, App Terminating, entering foreground, etc.

    SDL Logo

    SDL. It makes the games do.

    I think that making your own engine with SDL can be really beneficial in the long term- Jumpsmith will be released on Windows, Mac, Linux, and Steam OS, and I won’t have to pay royalties to a game engine company like Unity, which can be expensive.

    UPDATE: Jumpsmith is available now!

    Game porting guru Ryan Gordon has done a few talks where he discussed these tools and several others, you can check them out here and here. I hope that this information is useful to you on your next game!

    Leave a Reply

    Your email address will not be published. Required fields are marked *


    three − 2 =

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>