A Serious Question About Tools

Earlier this week, I finally joined the IGDA.  Some of that was to support my friend Corvus’ bid for for the board. But I wouldn’t have done it at all if I didn’t want to make and write about games.  Games intrigue me because I’m about half writer and half programmer.  Yeah, that means there’s a lot of game-stuff I’m not good at (art and music, for example) but I want to tell stories, and help other people tell stories.  And I’ve been programming computers of one kind of another since I was a teenager, back in the Dark Ages.

My first computer game was written at computer camp over two weeks, when the instructor realized there were two of us who already knew everything she was going to teach, so we sat down at our Apple ][s and typed in a multiple guess adventure game.  I was in middle school, and ironically, responsible for the art assets (I made a fire breathing dragon in lo-res graphics! and animated the fire!)  I’ve worked on a lot of half-projects,  my most recent experiments are with HTML5 Canvas, both raw and with Akihabara.

Anyway, I’ve mostly worked with free tools, they’re what I can afford. Indie’s can’t afford a lot of fancy stuff, and I’m not even an indie.  I’m just a hobbyist.  But there are some cool tools out there. There’s the Impact game engine — not that I’m sure how it stacks up against Akihabara, which is free.

And that sort of encapsulates my problem: I’ve got a bit of money, about $100 to spend, and I’d like to get something to help me make games.  That’s kind of a broad category but only having $100 sort of limits it.  I work in Windows (xp and 7) and can work with Linux tools pretty easily as well,  would prefer my output to go to as wide an audience as possible.  Web platforms: HTML5 and Flash are preferred, but ease of use and flexibility of the tool are a bigger issue.

What’s out there that I could put this money towards? What would you use or license?  Would you save the money, and get something slightly more expensive later?

Um…

Remember how I said I’d be quiet?

Yeah.

I’m really happy with this bit of code, though.  It’s a programming chestnut that the hard things look boring and the easy things look exciting.  My boss is surprised when I can do the whiz-bang feature in 5 minutes, but sorting dates by  proper rules takes me two or three days.  This is one of those things. It’s almost a game.  The second map experiment (the refactoring) is going slowly. I suspect I need a long walk.

Quiet or Technical

So this week, I’m either going to be quiet or technical. I do have some things to write about inFamous, but I’m focusing on coding htis week. So, I’ll either be quiet, or writing code gobbledygook. (So, for some of you, technical is essentially quiet. Or you wish it were;)

Well the 371-in-1 Klik’n'Play event at Glorious Trainwrecks looms kind of close. I’m not as far along as I want to be, honestly, but a decent map and tile class will be good enough, I think. I’ve settled on jQuery and a game library written for it, called gameQuery. The latter seems to mostly handle animations (which I’m not using a great deal, but any Tile class I use should be able to handle it). The other issue is that jQuery isn’t very object oriented (like Prototype and Dojo, which I’ve also worked with). That’s not a problem, but I’ve been doing OO programming for so long, it’s hard not to think in those ways.

One thing I’m thinking about is Map tiles. Normally you’d mange it with a flyweight pattern, and load a tile image that would be split up in tile-sized bits, and used to build your map. One image is one internet connection, and you only have the image one place, except when it’s being drawn. This is a pretty good pattern and a standard way of writing a map, but I got to thinking about it — browsers already do this. So long as the graphic url is the same, it pulls it from cache or downloads it once from the internet. Let’s not over do things and do what the browser is going to do already.

So I’m not going to worry about loading and drawing graphics. I’ll just set the URL on any of the map tiles, and keep a buffer around the map so it scrolls prettily. And part of this shortcutting is that I have a week or so, and I don’t want to dawdle over the right way to do something, I just want to get it done. If it’s successful, I’ll fix it later. If it’s not, then the time wasn’t wasted.

OTOH, and since I’m second-guessing myself like crazy, having these as canvas objects means I can do cheap color animation, and that sort of thing, by redrawing the graphics. So I dunno. Maybe there’s an easy way to duplicate dom entries in jQuery, so that so long as it looks like an image, I can use it as a tile. Too bad almost no one supports animated pngs ;)

Of course, part of the issue i’m having is graphics themselves. I shouldn’t be worrying about it, but I am. I need some basic stuff, and I can’t draw–nor am I going to have time to draw. I just need to commit to the idea that my games are going to be about polygons doing polygonal things in a polygonal world. Dangit!

So, now i’m working on the classic map game that I always write to do this: concentration. There’s a sample out there, and I’m liberally copying, but hey I’m learning. As always, you can access these (and read all of the code, of course) at my games website.

Canvas

So, I said the other day that I was going to work more with HTML5 since the triumvirate of Python/Pygame/PGU were starting to bother me.  I don’t want to denigrate either python or pygame as both are well developed, maintained and documented projects.  I don’t quite get PGU, and I think it mainly suffers from the fact that programmers aren’t usually also writers.  Tech writing is its own specialty that is under-appreciated in the open source world, I think.

Anyway, that’s not why I want to abandon the way I was going.  Here’s the thing: for someone to run my pygame game, they’ve got to have python installed (and the correct version).  Also they need the pygame libraries installed, plus any libraries that I use need to be installed or delivered with my game.

I remember what this was like.

When I first became a full time programmer, I worked on a 4GL called PowerBuilder.  It took four hours to compile, and even then it was only pseudo-compiled.  In order to distribute it, you had to include 14 other DLLs, along with the executable and libraries you used. It didn’t come with an installer (ubiquitous setup programs came with windows 95, and this was in the Windows 3.1.1 days).  So we had to compile it — and just in case something had changed — copy all those DLLs along with it to send to the client.  Back then, that meant copying it to a disk and mailing it.  As our application grew, it no longer fit on a single 1.4MB floppy disk, so we had to go to two disks, which introduced more error.

I worked with other companies, but kept this up for several years.  VisualBasic was slightly better for distribution with it’s runtime, but writing VB game the hives.

Then came the web, and everything pretty much changed.   We lost that “client/server” architecture in favor of one that mirrored the old mainframe methods, just with a much smarter, more capable client.  (IT goes in these cycles, I wouldn’t be surprised if in 5-10 years we’re back to a client/server model, but the current trends are away from that.)

You see the same thing in game development. Most games on my PC want to install DirectX.  There’s still a huge suite of files installed when you run the setup for a game, and all that has to be managed, designed to run on multiple operating systems (even if they are all windows), builds, etc.  Abstraction is good, minimal distribution is better.

The thing is, pretty much everything that connects to the internet today has a browser. Pretty much system has a browser that supports HTML5.  Maybe you’re stuck in an environment where you must use IE.  Well, you probably aren’t playing games there, eh?

Lord of Ultima says, “All you need to enter is a normal web browser…,” as Corvus pointed out recently.  That’s pretty appealing.

I’m not finding any libraries yet, but the other reason I’m switching is that writing HTML and javascript is something that I do every day at my job.  My javascript-fu is a little rusty, but it’s coming back to me as I play with things.  You can look at some of my experiments over at the new Games website which is more of a lab at the moment. I do have a bouncing ball thing working using canvas.

It’s not much, but you know what? It works in Firefox and Chrome under windows xp and windows 7.  It also works on my iPod Touch and the browser on my Android phone. I bet it works under Linux and MacOS and on the iPad, too.  There will be some game design issues if I use keyboard controls, or want to support multitouch — those are the edge capabilities now.  But mouse clicks and single tap controls should work across all the platforms, defining the constraints of the design.

I’m excited by it, and it’s fun to boot!  Now to keep work on these tools so they’re ready in three and a half weeks!

pygame Frustrations

(This article is going to be geeky and technical and ranty.  Don’t say I didn’t warn you.)

As I’ve mentioned I’m prepping for the Glorious Trainwrecks’? THE 371-IN-1 KLIK & PLAY PIRATE KART II: KLIK HARDER event.  I’m on win7 and Klik & Play doesn’t really run all that easily, so I’ve been poking about for something else.  I did a bit with Construct, but it’s windows only, and I don’t really want to learn a new tool that isn’t going to give me some other benefit.

I thought about Unity, and that’s still a bit in the running, but I was already learning Python for other reasons, and pygame  is a fairly developed tool for making games.  I’m not looking for something fancy, just something I can quickly hack together, and make a few crapware games in a couple of hours each.  Once I’m more comfortable with the tools, and the games, I can develop the ones that seem good into something better.   To me the event is like a speed writing exercise, the goal isn’t something publishable,but something that’s creative that can be developed.

So, what I want to do is familiarize myself with the tools, and, if possible, find or write an engine that’ll let me do basic tile games (mazes and platformers, mostly).  I’ve found two or three of these, and they are either several years old, or quasi-documented.  PGU seems to be the most recently updated — and I’ve found in my years working with open source that you want two things: recent updates, and an active community.  That means the project is alive, and kicking, and working with the current suite of tools.

None of these tools that I’ve found have an active community, but PGU was updated in the past few months.  Unfortunately, PGU’s documentation leaves a lot to be desired.  I don’t really want to have to puzzle out someone’s code to figure out how it works — it’d be faster for me to just write my own code at that point.  If I’m using an engine, I want to not have to think about the low level implications of my decisions, and just move forward.

I don’t want to say that PGU’s documentation is bad. It follows a convention I’ve seen in the Java and Python worlds.  You put your documentation in the code, so it can be generated when you do a release.  You document functions and objects as you write them, and then everything is documented right?

Well, no. Not really.

There are two kinds of documentation that often — but not always — get left out of this. The first is systemic documentation, which tells you how all the pieces fit together and work together. A good project will have a page or two showing you how to fit all the pieces together to make something work.  Often this is a tutorial or a set of documented examples showing the project working.  PGU does this, but it feels largely esoteric.  Yes there’s code, and I can more-or-less see what it’s doing, but there’s some magic going on in there, and I’m not sure what it is.

That uncertainty, I realized was the missing second bit of documentation: file formats.  Unless you’ve got an object which reads and unpacks a file format and that process is documented in your Py or JavaDocs, you’ve got no documentation about your file formats.  PGU uses a Targa file (.tga, a graphic format) to store it’s tiles and maps.  The former, I get, the latter less so.

I delved into the code last night, to see if I could have an a-ha moment and move forward.  What I discovered was that he was being tricky. A graphics file is ultimately an array of color values, along with some information to tell you the shape of the rectangle that it is. In other words, it’s a 32 x32 graphic, the upper leftmost pixel is black, the next one is green, et cetera.

Color information is 32 bits in a Targa file (just like on your modern computer) it’s 8 bits for Red, Green, and Blue color values, and 8 bits for “alpha transparency”.  That’s how Vista and Win 7 (for example) manage to give you that  see-through the window look.   Getting the colors out of pygame is pretty easy, it’s Surface class will give you those four values for any pixel in an image.

The author of PGU is then using these four values for different things. I’m not 100% sure what they all are. One is the tile index, which I get and expected — tile games have a pretty stable design, they work a certain way, and I’ve worked with 5 or 6 different libraries, and they all share certain similarities. Another is something called “codes” and another is “background”.  He’s also using the alpha for something, but I’m not sure what.

Not knowing how all that works makes the code really hard to read.  Add to it’s object-oriented nature (I’m not against that, but it spreads the actual verbs around in ways that make it hard to trace through the code, as I bounce between API and program code)

I don’t want to invest too much time into this, I’ve got about 3 weeks to become proficient enough to make some games with something.  That’s like agreeing to write stories using a different keyboard than you were used to, and trying to Mavis Beacon your way through it.  Sometimes it’s better to find a different keyboard.

Today, I’m a bit tempted by HTML5, and I already know a great deal about that.