Hypothermia is now on itch.io!

 

A while back I made a little game called Hypothermia for Experimental Gameplay‘s “Temperature” challenge, a game jam of sorts that ran for a week during November/December 2013. It got reviewed by Indie Impressions and Indie Statik, and some guy from China did a Let’s Play of it.

Based solely on download count, it’s my most successful game thus far, but I never managed to find a hosting site for it that was a good fit, so despite it being a flash game anyone who wanted to play it had to download an archive containing the SWF and a web page. Thanks to itch.io, I now have a place to upload it without having to worry about it being blammed by people who don’t understand game jams. ;)

Play it here!

Exploiting Actionscript 3’s “this” keyword for fun and profit

I originally posted this as a reply to a topic over at the Flashpunk developer forums and thought it would make a good post all on its own.

Something I really like about as3 is that you can define functions anywhere, even within other functions. Such a function is called a closure, as it “closes over” its surrounding environment and has access to all variables that exist in the current scope. For example, you can do this:

When the alarm triggers (after one second, for those unfamiliar with Flashpunk), the closure is called and the message “Hello, world!” is displayed. The function will keep a reference to the message variable as long as it’s being used, long after the function it was created in goes out of scope.

The trouble begins when you use the this keyword inside a function you’re going to pass as a callback.

You’d expect that this would refer to the object that was in scope at the time the function was created; for example, running this code from your player class should trace “[class Player]”. Unfortunately that’s not the case; this always refers to the object that calls the function. In this case, the callback is being called by the Alarm, so it will trace “[class Alarm]”.

This can actually be helpful at times, such as if you pass a function to a GUI control, like so:

In most cases, however, this behavior is just a pain and causes crashes that can’t be caught at compile-time. There’s a solution to that as well, though:

Since self is captured by the function, it will always refer to the this object at the time of the function’s creation; in this case, the Player class instance. This code will trace out “[class Player]”, just as expected.

The Actionscript family of languages is ultimately based on ECMAScript, so a lot of the quirks present in Javascript carry over. Some of them can be annoying to get used to, but as long as you’re aware of them they can serve you well.

 

Game design by necessity

I started work on a game called Gunbuilding about a week ago with the purpose of stress-testing #Punk, a C# port of Flashpunk that I’ve been developing. Nothing puts a framework through its paces like using it for a game jam, and if nothing else I ended up fixing a lot of bugs that would have inevitably bitten me later on. On the downside, though, my idea for the game changed drastically to fit inside my schedule, and I’m not thrilled with the way it came out.

If you want to play it, go here.

The first thing to go was the mechanic that gave the game its name. I created a system that assembled bullets by passing data through a set of components that could be swapped out at any time. In theory, this could have allowed for a crazy number of combinations, resulting in bullets that homed in on enemies and spawned others to ricochet around after impact. The system technically works as it is, but I didn’t have time to create more than one component for each category. I’d like to explore this type of system again in the future, though; it seemed like it had potential to be a lot of fun.

The next feature to be cut was the enemy AI. I’m pretty happy with the way my little guys hop around (the quadratic curve movement system they use was one of the first holdups I encountered), but they don’t do anything to avoid each other and always ended up clumping together into a group as they moved towards the player. As a solution (though at the time it was a joke) I made them explode when they touched each other, and then made that explosion chain to other nearby enemies. The chaining was super simple and easy to do thanks to #Punk’s extensive message broadcasting capabilities, and it turned out to be a lot more fun than the approach I had been using, so in one sense I’m glad I ran low on time to implement the rest of the game systems.

The last thing I didn’t have time for was to put any effort into graphics. Everything in the game is made up of colored squares, with the  exception of a grass tile I used for the background and a tiny image for the particle effects. I generally try to prototype with as few art assets as possible to avoid getting stuck perfecting them before any gameplay is in place. In one sense that worked out this time — I can’t imagine what else I would have had to cut had I spent all kinds of time on art early on — but I feel like shipping the game in such an incomplete state is a real shame.

Overall I’m disappointed with the way the game turned out, but this was never about the game. I’m pleased with the number of bugs I was able to fix in the framework, and that was the whole point anyway, so I’d call this experiment a success.

Humphrey’s Tiny Adventure: Remastered

Last year I participated in my first game jam with Ludum Dare #23. The result of those 48 hours was Humphrey’s Tiny Adventure, which I’ve written about previously. I was really proud of what I was able to accomplish, but there was a lot that I wanted to do with the project that I didn’t have time for. I didn’t include any sound or music, and I didn’t have anyone test it before release, so I never had the chance to get feedback. I recently decided to give Humphrey a long-overdue makeover for one of my entries in OneGameAMonth.

Over the past three weeks I’ve rewritten every piece of code in the game. Looking back at the original code, I’m literally terrified at the prospect of dealing with it. For the most part the gameplay is nothing complex, so I was able to build on the engine I wrote for Hypothermia. I created a data-driven cutscene scripting system using Slang, which I wrote about here. This was immensely helpful both in terms of writing reusable code and iterating quickly on the way each scene played out.

I’ve also redone almost all of the artwork. The art in the original version of Humphrey was composed entirely of large colored squares. This was mainly due to time constraints; the abstract style allowed me to spend very little time on each asset while still conveying the desired meaning. For the remake I did away with this restriction, and I’m very happy with the results. As usual, I used Inkscape for all the art.

Finally, this release includes a fantastic soundtrack by Chris Logsdon. It was composed specifically for the game, and you can download it here in high quality for the price of your choice.

Download the game here! I’d love to hear what you think of it!

Data-driven action scheduling in Flash

One of recent experiments in game development has been to orient my workflow away from code and towards data. When I use Flash, I’ve started using Ogmo Editor to design my levels, XML to handle settings, and Slang to handle game logic whenever possible. As a result, a lot of the code I’ve written recently can be easily reused across projects, and my classes are systemic and steer clear of situation-specific behavior. It’s been quite fulfilling and has done wonders for my iteration time; the focus on data instead of code means that I can take advantage of live-reloading for nearly every aspect of development. It’s not uncommon for me to work for an hour without ever closing my game, as I can simply reload all assets and data with the press of a button.

Today I’ve been working on Humphrey’s Tiny Adventure: Remastered, a post-compo version of my first 48 hour game. There are a number of places in the game where I need to set up events on a timeline, which I’ve done a few times already (see here and here), and each time I used some variation of traversal over a queue of function closures. While this approach worked well enough, it was tedious to set up and a pain to debug, not to mention the fact that it was anything but systemic. The most criticized aspect of the Ludum Dare version of Humphrey was that the intro cutscene was too long, and I agree. I think I knew that even before I released the game, but there was no way I was diving into that code to change it.

For Humphrey: Remastered, I was determined to achieve the same type of event scheduling in a data-driven way. Thanks to Slang, I was able to do just that. Here are the scripts for a scene I’ve been testing that involve two actors; Humphrey and Abe. This won’t be in the finished game, but it’s a good demonstration of the system’s capabilities.

Actions are called sequentially by the actor that the script is attached to. Each action block defines a set of statements that will be run as the events are executed. Calling done moves to the next action, and delay causes the actor to stop executing actions for the given number of seconds.

The give-cue and await-cue functions allow actors to pass messages between each other. In the above example, Humphrey give a cue to tell that he’s finished a set of actions, and Abe, who has been waiting for that cue, executes his final action in response.

There are only a few control functions involved, but so far the system has proven to be very powerful, and more than capable enough for the needs of this project. With the addition of message passing and response, specialized actor classes will be able to define custom behaviors while allowing the system to remain pure.

I’m quite happy with the way this has turned out. It’s fun to experiment with what can be done with Slang even in its current, quite minimal state.