FlashPunk, DAME and Lua Tutorial (Part 0)
01/17/2011
This is a fairly lengthy post, which is an introduction to the next tutorial series I will be posting. If you don't care about the how, when or why, here is the quick version: Motivated to develop more flash games, I tried learning PushButtonEngine for the nth time, but still struggled grasping all of the concepts. Then I tried learning Flixel for the nth time, but still struggled with committing all the classes and workflow to memory. In attempt to keep trying to learn Flixel, I saw a post about creating a level with Flixel and DAME. Unfortunately, the tutorial ended before it actually got into Flixel, but I really fell in love with this app called the DAME Editor. After noticing that DAME came with a FlashPunk exporter, and after realizing I had never really tried FlashPunk, I decided to give that engine a go as well. Turns out, FlashPunk was just what I had been looking for, and now I've decided to write a tutorial on using FlashPunk, DAME, and incidentally, Lua. Phew.
Well, that was the short version. For the long version, please read on:
It's rare, but luckily a project came up which has allowed me to focus more on game development. In the past, I've made very simple games from scratch, with the exception of one using a Flash Box2D port, which in many ways was still pretty simple. At GDC Online in October of 2010, I sat in on a talk from Ben Garney, which was a very brief overview of the PushButtonEngine for Flash. Even though I had already seen the same information from the PBE videos on youtube, being able to ask a few questions and talk with other developers there really gave me motivation to start going through the tutorials.
After learning a bit about the engine, and really falling in love with whole composition vs inheritance approach, I still felt a little overwhelmed with the workflow. I could follow along with most of the tutorials I found online, however it seemed that the whole XML based approach was the way to go. With limited examples provided, it was hard to get beyond any unexpected issues that came up. I tried Flixel again, but like all the other times I've experimented with Flixel, it seemed like overkill for getting a quick and simple game up and running, in a way that made sense to me.
Searching for further tutorials, I came across a link that mentioned creating a level with Flixel and DAME. The tutorial didn't ever cover Flixel, and focused mostly on a tile map editor called DAME. Well, for a few hours I lost focus on reviewing game engines, and instead became fascinated with the amount of features, and ease of use within this DAME Editor. I also noticed that in the various formats it exported to, besides Flixel it also supported FlashPunk.
I'd always noticed the FlashPunk logo on the bottom of Flixel's homepage, which reads:
If you are allergic to flixel for one reason or another, don’t give up! Check out ChevyRay’s library FlashPunk instead, it’s awesome!
Seeing as how I hadn't been successful with PushButtonEngine or Flixel yet, I figured there was nothing to lose by checking it out. I followed along all the text and video tutorials on FlashPunk, followed by a few more I found on The Doglion. I noticed that almost all of the other FlashPunk developers on the forums, and on IRC all use OGMO Editor for tile maps. It seemed to do the trick, but after playing with DAME, it just couldn't compare in features.
After following through the OGMO and FlashPunk tutorials, I had everything working pretty quickly. And more importantly, I felt like I understand all the pieces that were working together within the engine, since they were designed in a way very similar to my own thinking. I tried using the FlashPunk exporter in DAME, and although it exported a few files as expected, I had no idea how to use all of the files that were generated. So instead of moving on, I decided to first make an XML exporter to reflect the output of an OGMO map. Being my first encounter with scripting in Lua, I did fairly well - the map I designed loaded up, just as if I had made it in OGMO.
The next step, was to try and integrate the more advanced features of DAME into a FlashPunk game. While not complete by any means, I've managed to create a custom exporter which handles tiles, sprites, custom properties and even random spawning areas. Features I'm still working on are paths, links, and a few other things. That being said, I'm really excited about the workflow I've been able to achieve between FlashPunk and DAME, and decided to start a new tutorial series on the entire process, starting with DAME, then Lua, then FlashPunk. Not sure how many parts the tutorial will be in, but probably at least 4. Anyways, hope some of you are as excited as I am about it! Stay tuned and subscribe to my blog to follow along!





Looking forward to it! I’m a bit overwhelmed right now at the start of the process you describe. I know how to learn a programming language from the ground up but thats because java and as3 are heavily documented. But these frameworks — how do these guys figure out the api so quickly? I feel like I’m missing a crucial ingredient.
I can relate, it took me quite a while to get into using any of these frameworks. For me, I had to try and create a few games on my own – and I noticed that there were certain features I had to implement every time, regardless of the game I was trying to make. Collision detection, tilemap loading, culling, game loops, state management, etc. None of this was obvious when I started, but over time the same design patterns kept emerging over and over. That’s around the time FlashPunk / Flixel / etc. started to make a lot of sense. They all just prepackage long lists of useful functions, to speed up the creation of games. As for figuring out the API quickly, once you understand the high level design of the framework (e.g. FlashPunk uses the Engine class for all the “global stuff,” it uses the World class for each screen/level, and uses the Entity class for objects like enemies, players, powerups, etc.) Once you understand the main components of the framework, it’s just a matter of trying different things out.
Trying to understand game programming AND a framework at the same time didn’t work for me, as it just got confusing. I had to essentially create a few of my own (really crude) game engines before I understood the typical game programming flow. Then, once I realized how inefficient my own code was – I was able to realize the power and usefulness of the frameworks.