Doom, Heretic, and Hexen in Flash

by Mike Welsh on June 29, 2010

This project was originally posted on my Newgrounds.com blog on December 4, 2008.

Near the end of 2008, Adobe released Alchemy, a toolset to cross-compile C++ into ActionScript libraries. Naturally, the first thing that popped into my mind was to try to port Doom!

Doom running in Flash

This port is based on the vanilla Doom source code for Linux. A few months later, I added Heretic and Hexen support using the original DOS source of Heretic and Hexen. These sources were released by id Software and Raven Software under the GPL. The (messy) code for my port is also released under the GPL, available on GitHub.

These type of reverse-engineering projects are always fun. It’s a blast to look through the source of an ancient game! And it’s truly an experience when the game suddenly springs to life after a late-night hacking session. It was such a trip when I first saw “R_Init: Init DOOM refresh daemon” in my Flash output window… :)

If I were to start again, I’d probably base it on a more modern source port like PrBoom. That way I’d gain many of the bug fixes and cool features that these ports have solved years ago!

This port did manage to win FHM’s 2009 Web Game Awards! The amount of work I did to port such an awesome game was negligible, so I decided to donate the prize to charity. Go open source!

{ 0 comments }

ActionScript 3.0 Game Architecture

by Mike Welsh on June 23, 2010

I had the pleasure of giving a talk on ActionScript 3.0 game programming at Flash Camp Philadelphia 2009. I spoke about how games are built, the pros and cons of the standard game inheritance hierarchy, and a few alternatives to it. I also talked about some techniques such as:

  • Game loop timing using getTimer()
  • Decoupling game logic and animation from Flash Player’s frame rate
  • Rolling your own display list for benefits such as depth sorting
  • Using the Flex Builder profiler to optimize your game

A lot of these techniques are used by the newer game frameworks such as Flixel, FlashPunk, and PushButton Engine, so it’s good to have an understanding of what’s going on behind the scenes.

This talk was given on November 7, 2009 at Philadelphia University. You can download the slides and some sample code here!

{ 0 comments }

Julia Set Fractal with Pixel Bender

by Mike Welsh on June 23, 2010

This project was originally posted on my Newgrounds.com blog on October 1, 2008.

I spent some time playing with fractals after hearing Keith Peters lecture on chaos theory and reading through his Chaos-101 site. It’s amazing how some ostensibly arbitrary math can spit out psychedelic pictures. Tweak a few values, and you’ll get a whole new landscape.

Here’s a little Julia set renderer written with Pixel Bender. You can zoom, pan around, and tweak the values of the Julia set. It features a simple colorization scheme.

Julia fractal

Julia fractal rendered with Pixel Bender

Unfortunately, it’s difficult to get this kernel to run in the Flash Player—the Pixel Bender implementation in the Flash Player is crippled, and doesn’t support for loops! That’s a shame, because most of the cool things that you’d want to do with Pixel Bender would require a for loop. The only hope would be to unroll the loop.

You can download the source here (requires the Pixel Bender Toolkit).

{ 1 comment }

Pixel Bender Raytracer

by Mike Welsh on June 21, 2010

This project was originally posted on my Newgrounds.com blog on July 22, 2008.

Here’s a small raytracer created with Adobe’s Pixel Bender. It supports ambient, diffuse, and specular lighting; shadows; and reflections. It’s even possible to do texturing by supplying another input to the shader.

Raytracers are easily parallelizable, so they are well-suited to shader languages like Pixel Bender. Unfortunately, the lack of indirection in these languages makes it difficult to render a variety of different shapes, so here I’m only rendering the cliche checkered plane with a set of spheres.

Pixel Bender Raytracer

Pixel Bender raytracer

You can download the source here (requires the Pixel Bender Toolkit).

{ 0 comments }