Aug. 18, 2008

GameJam0808 was awesome fun, which is really what games are all about. In the end I got a crapload of code written, much of which I will be able to re-use again in the future, just as I used quite a bit of old code for my engine. I refined a lot of my existing code, made it more modular, and more re-useable than it was before. I now have a load of generic game code that has been separated from the underlying engine I use, PyGame. It should be easier to switch engines to Pyglet, or something else if I want to in the future.

Huge thanks go to Simon Wittber who organised GameJam, and wrote the entire GameJam site in time for the competition. He also did the awesome procedural audio ambience for my game, and on top of that, he did the most incredibly annoying bit of making a game for me: the deployment.

Contact Agent zipfile

Contact Agent screenshot

I didn't finish the game, so it's just one level, and all you can do is run and jump and explore. I can't even really call it an art game because I feel like that would be selling other, really awesome art games short. The vector graphics engine I wrote is massively slow because I didn't have time to optimise anything, which had the side effect of making you fall through floors and stuff on any computer that isn't massively fast. I shouldn't have multiplied all vectors by frame-elapsed time since that number gets really large on those slower computers. Oh well. Good lessons for next time!

Aug. 11, 2008

Update: the article below is for an Inkscape extension I built a while back for doing animation. For a newer and much better solution for doing frame-by-frame animation in both Inkscape and Adobe Illustrator check out SVG Flipbook. Enjoy!

Inkscape is an awesome, free and open source vector graphics program. It's the free world's version of Adobe's Illustrator program. I can't comment on whether it's better or worse since I've never used Illustrator, but there are many things to love about Inkscape and it's very capable when it comes to vector graphics.

One thing that is hard to come by is a good, free and open source vector animation program. The Inkscape website says that they are looking at introducing animation into the program some time in the future, but who knows how long that will take. I needed to make animated vector graphics for my GameJam 0808 entry, which is a vector graphics platformer, so I knocked together a quick script to do layer based animation in Inkscape. Luckily Inkscape's extensions system is quite extensible, so I was able to write a small Python script that renders each layer separately using Inkscape itself, and then uses Imagemagick's "convert" program to mash the layers together into an animated GIF. Finally, the extension automatically launches the default browser to display the result. This currently only works under GNU/Linux systems with Imagemagick installed, but I'm sure it wouldn't be too big a stretch to get it working on other operating systems.

Here is the Inkscape extension XML file. Place this in your .inkscape/extensions/ directory in a file called gifanimate.inx:

<inkscape-extension>
  <_name>GIF Animate</_name>
  <id>org.ekips.filter.GIFAnimate</id>
  <dependency type="executable" location="extensions">gifanimate.py</dependency>
  <dependency type="executable" location="extensions">inkex.py</dependency>
  <!-- <param name="what" type="string" _gui-text="What would you like to greet?">World</param> -->
  <effect>
    <object-type>all</object-type>
    <effects-menu>
       <submenu _name="Animate"/>
    </effects-menu>
  </effect>
  <script>
    <command reldir="extensions" interpreter="python">gifanimate.py</command>
  </script>
</inkscape-extension>

Here is the Python script that does all the work. Put this in the same place, and name it 'gifanimate.py'.

#!/usr/bin/env python
import sys, os
sys.path.append('/usr/share/inkscape/extensions')

import inkex
from simplestyle import *

class GIFAnimate(inkex.Effect):
    def __init__(self):
        inkex.Effect.__init__(self)

    def effect(self):
        infile = sys.argv[-1]

        # Get access to main SVG document element and get its dimensions.
        from xml.dom.minidom import parse, parseString
        dom = parse(infile)
        svg = dom.getElementsByTagName('svg')[0]

        layers = svg.getElementsByTagName('g')
        pngcommand = "inkscape %s -C -i '%s' -j -e /tmp/%s.png 2>&1 > /dev/null"

        layerids = []
        delays = []
        for l in layers:
            bits = l.getAttribute('inkscape:label').split("#")
            if not "ignore" in bits:
                layerids.append(l.getAttribute('id'))
                delays.append(bits[0])

        [os.system(pngcommand % (infile, id, id)) for id in layerids]
        bits = " ".join(["-delay %d /tmp/%s.png" % (int(delays[x]), layerids[x]) for x in range(len(layerids))])
        gifcmd = "convert -loop 0 " + bits + " /tmp/inkscape-anim.gif"
        os.system(gifcmd)
        import webbrowser
        webbrowser.open("file:///tmp/inkscape-anim.gif")

# Create effect instance and apply it.
effect = GIFAnimate()
effect.affect()

To use it go to the 'effects' menu and choose 'Animate > GIF Animate'. Specify frame lengths (in milliseconds) by renaming the layer to the length of time that you'd like each frame to last. Inkscape will add a hash followed by a number for each duplicate entry, but my script will ignore that.

Main character walkcycle

Have fun!

Aug. 5, 2008

A few weeks back my friend Simon came up with the great idea of doing a game jam here in Perth. A game jam is where a bunch of people make teams and try to develop full games in a time limited situation. Similar competitions are Ludum Dare, and Pyweek. They are a lot of fun, and you tend to get lots of code and experience out of it.

This is the tenative title, and main character, from my entry into the competition:

Contact Agent - my game

Anyway, Simon built this cool community site in a matter of days using Pylons, which you can see at http://gamejam.org/ and then we put out the word on the internets, and now we are in the midst of it, with eleven days left to go. The turnout has been pretty superb and I am looking forward to seeing everyone's finished projects. The competition is very loose; you can use any engine you want and pretty much do any kind of game you want, as long as you use the 'significant asset' in your game. Also, it isn't really limited to Perth only and it only just started not long ago, so if you have a hankering to develop a game idea then this is the forum for you; go ahead and join the fray!

My own game is a vector graphics platformer. I think I'll probably get all the code done in time with a basic playable game, but I'm not so sure about getting it deployed onto all platforms. We'll see, I guess!

We'll almost certainly do more game jams in future months. Can't wait.

July 5, 2008

Futuristic Building #1

I recently bought a 'digital notepad'. It's a device that looks kind of like a clipboard, and you can clip regular paper notepads into. When you draw on the paper with a special pen, your pen strokes are digitally recorded. Later you can hook the thing up to a computer to copy the vectorised notes across and get your hand-drawings in a nice flexible vector format.

Futuristic Building #2

This one is made by a company called Laser here in Australia but pretty much every digital notepad on the market is made by one taiwanese company, Waltop, who sell them to other companies for rebranding. The device runs fine under Debian in both USB disk mode, and tablet mode. Here is a link to a blog post with a heap of information about the digital notepad and running it under GNU/Linux (there is lots of info in the comments too):

http://eddie.niese.net/20071129/new-digital-notepad-gadget/

Futuristic Building #3

Modes

The notepad operates in two distinct modes. The first mode is as a regular notepad that internally digitises everything that you write in ink while it's not connected to your computer. This is reasonably effective although I have found that very occasionally, maybe one to three times per page, the pen will miss a stroke. I think this is due to the angle I write on, or not pressing the pen down hard enough when I do a light stroke. For what I am using the notepad for it's no problem since I import the notes as SVG files and then modify them in tablet mode later. I use a small Python script by Jorik Blaas to turn the notes from the .top file format they are stored as, to svg format. You can copy the .top files from the device to your computer when it's connected via the USB cable. Click here to download the Python script (I got it from the URL listed above).

Futuristic Building #4

Which brings me to the other mode; tablet mode. When the notepad is connected via USB to a computer it acts like a USB disk that you can copy notes off, but it simultaneously makes the notepad behave like a primitive graphics tablet. I say primitive because it has no pressure sensitivity, and it really just emulates a mouse - as you move the pen about on the surface, the mouse cursor follows. When you press the pen down, the mouse clicks. So far this has been fine for the little sketches I've been making.

Futuristic Building #5

Other stuff

The box also came with a black portfolio to carry the notepad around in, a USB cable, batteries, replacement ink cartridges, a plastic tipped cartridge for tablet mode, and a bunch of Windows software that I did not use. The whole package cost me about $160(AU) plus twenty five bucks or so postage.

Futuristic Building #6

I am pretty excited about this device and it's been fun playing with it over the last week or so. One of the difficult things about being a solo indie games programmer is not having graphics for your games. I have always found the hand-drawn aesthetic quite endearing in video games so I might have a shot at sketching some characters and backgrounds.

Futuristic Building #7

I have a bunch of other ideas for applications using tablet/touchscreen, so hopefully I'll get around to coding up some of those. Exciting times!

Futuristic Building #8

June 11, 2008

For the last few months I have been helping my friends Rodney Glick (Artist) and Moshe Y Bernstein (Rabbi) with the technical aspects of one of Rodney's artworks. The artwork, entitled "Master Of Prayer" will be showing among many other fascinating works in Rodney's exhibition. It opens tommorrow night (Thursday), 6pm at the Lawrence Wilson Art Gallery at the University of Western Australia. I'm really excited about this project. I got to use Pure Data, voice synthesis (Mbrola), and a network based pseudo-AI to help Rodney and Moshe create a really compelling and thought provoking artwork. Here's the blurb that Moshe wrote about it:

"In the Jewish tradition the full prayer service can be performed only in a quorum of ten adult males known in Hebrew as a minyan. The main part of the service, which occurs three times daily, is the Shmona Esrei, or Eighteen Benedictions. These blessings are first recited silently by the entire congregation. Afterwards, during the morning and afternoon liturgies, they are repeated aloud by the cantor, often referred to as the Ba'al Tefillah or 'Master of Prayer'. In orthodox Judaism any male, whether layman or cleric, over the age of thirteen can lead the prayers. During the repetition of the Shmona Esrei, also called the Amidah, or 'standing prayer', the congregation answers responsively to each of the benedictions recited. In this installation each computer has been individually programmed to respond to the blessings recited by the main computer, the 'Master of Prayer', leading the afternoon Mincha service. Though the installation appears to parody the human condition of prayer by rote, on a deeper level it asks a haunting question about the inherent nature of artificial intelligence. The Jewish sages require kavannah, or 'proper intent' for prayer to be truly acceptable. To the extent that computers can be programmed to 'think', might they not be programmed to this 'proper intent' as well? In a tentative answer to that question, 'Master of Prayer' can be experienced as a high-tech, Jewish version of the Tibetan prayer-wheel or Christian rosary beads."