Friday
Apr092010

Setting up Perl SDL 2.4

Because of the way SDL works, it takes some special tricks to get it working correctly with Perl. For some reason that's beyond my knowing, it's extra difficult on Mac OSX. These steps worked for me, but feel free to email me if you're having trouble and I'll see what I can do.

  1. Install the SDL library version 1.2. This is most easily done via Macports.
  2. Install the newest version of the SDL perl module using CPAN. There is a Macports module for this, but it hasn't been updated to the most recent version.
  3. In terminal, open up the build directory for the SDL module. It should be something like ~/.cpan/build/SDL-2.4-******/.
  4. Now execute the command: sudo perl Build bundle
  5. You should have now a folder called SDLPerl.app in the same directory.
  6. Copy SDLPerl.app wherever seems convenient to you.
  7. To run programs, you have to specifically pass in all the folders where your sources are contained. This includes the directory that you execute in.
  8. For example: PERL5LIBS=$PERL5LIBS:/a/b/c:/a/b/c/lib /path/to/SDLPerl.app/Contents/MacOS/SDLPerl myscript.pl

I'm sure there's a better way to do this, if you have any suggestions, please let me know.

Thursday
Apr082010

Perl SDL

Two weeks from now, on April 21, I'll be giving a talk at the St. Louis Perl Mongers about the SDL Perl modules. It's a timely talk due to the 2.4 release of the SDL module.

Here's the talk abstract:

Once upon a time, game development was a domain reserved for only the most intrepid programmers: those willing to bear the burden of manual memory management and hours of debugging highly optimized C code. Now, however, we are entering a brave new world of game development. Modern AAA titles are increasingly using dynamic languages to create core game logic while still keeping processor intensive tasks like AI and graphics in C. Moving forward further, we are starting to see bindings for languages like Perl and Python into graphics toolkits and other optimized libraries. Now programmers from all types of backgrounds can pop open their favorite text editor and have basic games running in very short order.

Robert will be giving a brief overview of the state of the art in Perl programming and talking about the different libraries that are available. Focusing on the Simple DirectMedia Layer (SDL), he will take the audience through the creation of a simple game from empty file to (hopefully) fun times. Lastly, he will pontificate briefly about the place of Perl and other dynamic languages in the future of game development.

I'll be updating this post shortly with links to the repositories for the talk and associated materials.

Saturday
Nov282009

Python & Pygame as a Prototyping Tool

I've been working on an idea for an iPhone game recently, a cool ( if I do say so myself ) variation on an old puzzle. Before I started in on the iPhone coding though, I wanted to make sure that the algorithms and function outlines I had in mind for the puzzle actually worked.

It too me the better part of an afternoon to whip up the display and function of the game so that it was playable, and then another ninety minutes or so to code the puzzle generation algorithm. The whole process was very painless, and in the end I had a fully functioning prototype of the game.

I think if I make a habit out of creating games for the iPhone or any platform, this will be a pretty standard first step for me.

Sunday
May102009

Wow...I'm a nerd...

For anyone else who has gotten tired of mucking around with Fallout 3's stupid hacking challanges, here's your salvation:

words = {
    "persevered": 1,
    "domination": -1,
    "resembling": -1,
    "generation": 3,
    "resounding": 2,
    "definition": -1,
    "adrenaline": -1,
    "definitely": -1,
    "reputation": -1,
    "revolution": -1,
    "meditation": -1,
    "separating": -1,
    "recuperate": -1}

def compare( one, two ):
    equal = 0

    for i in range(0,len(one)):
        if( one[i] == two[i] ):
            equal = equal + 1

    return equal


known_words = filter( lambda x: words[x] >= 0, words.keys() )
unknown_words = filter( lambda x: words[x] == -1, words.keys() )

possible_words = []

for word in unknown_words:
    valid = 1
    for check in known_words:
        if( compare( word, check ) != words[check] ):
            valid = 0
    
    if( valid == 1 ):
        possible_words.append(word)

print possible_words

I'll clean this up and make it a nice gui app at some point.

Friday
Mar062009

Initial Commit

The initial commit of my new and improved Mandelbrot Set renderer is up, right now it's a single file that renders the fractal with SDL.  I'm hoping that I'll have some more time this weekend to polish some things off of its todo list.  As with my first attempt at a fractal renderer, I used only the Jonathon Coulton song as a reference; I think I will probobly look up some resources about optimization in the future though.

In the mean time, here's a screenshot of the generated output:

Next Steps:

  • Multi-Threading
  • Color gradiants
  • Dynamic resizing / regenerating