Update: The Liberty Engine: Running Clean

I’ve been all damn talk for too long. Ladies and gentlemen, I give you, the Liberty Engine Demo!

Liberty Engine demo 1


-Click the scrolling play button (or press space) to pause the animation.

-“In” and “Out” values determine number of seconds into the animation that the loop will begin and end.

-“Rate” determines the speed at which time will pass (seconds per second).

-“Duration” is the duration of the loop. If modified, it will automatically change the “Out” value.

-All forces in the system are set to enact at the 10 second mark and all calculations end at the 30 second mark.

Aside from the animation controls, this is not an interactive demo. Interactivity will probably be in the next one, but this demonstrates all of the engine principles. You’ll notice a slight lag period just as the swf loads. That’s because it is calculating all of the physics for the entire animation during the first frame. It saves all of that data and then replays it based on the passage of time. That’s why you can scroll back and forth or play at different rates (super slow-motion or fast-forward). The animation is actually set to 40fps, but I guarantee your browser can’t keep up with that speed. Fortunately, because the engine is time based rather than frame based, dropped frames do not effect the rate of movement. Oh, and by the way this is in AS2. I’ll translate it to AS3 later.

I haven’t mentioned the Liberty Engine up here very much, but it’s been a project of mine for over a year now. The concept behind the Liberty Engine is to create a physics engine that ANYONE can use; to liberate the thousands of young game developers without the programming or mathematical know-how to build the kind of games they dream of and provide it for public use free of charge. I hope, with a powerful and easy-to-use engine like this one, to foster a serious indie gaming movement at the grassroots level.

How It Started

LG, Rock’s Platformer Engine, The Penguin, Loki, Breakfast Club

In the summer of ’06, I had started working at LiquidGeneration.com and on my first day I had nothing to do! So I started building a platformer engine. Why not, right?

I had dabbled in that kind of code before, but I never dedicated the time to really figure it all out. Bryson helped a lot showing me some good engines others had built, particularly a Bubble Bobble tech demo by a fellow named Marmotte (of the flashkit forums). This was a real learning period for me. Before then, I had only really experimented with flash, at most building “beginnings” of games (concepts that taught me so much they outdated themselves). But with 8 hours a day in an office, with nothing to do but code non-stop, I was making serious progress on what I considered to be a noble endeavor.

The Liberty Engine would allow me to use Flash’s paint brush to simply paint out levels that would automatically be fully interactive with my characters. Its first incarnation was what I now consider the “pre-school” version. My first demo was this little “penguin simulator.”

Use arrow keys and space bar. Press F to throw rocks. Try pressing different directions while in the air, landing at the different angles, jumping off your head, and jumping underwater to swim. You can even do flips when you fly out of the water if you press and hold left or right just in time.

The Penguin demo was meant to test out it’s different capabilities and I was very happy with the results. While that engine was still in something of an alpha stage, it was used for Bryson’s game, Little Loki Escapes from Hell. Bryson put together a nice little level editor and the development process went really smoothly. We were both very happy with the results.

I still wanted to use the engine for a game of my own, preferably one based on my penguin demo that really showed off what could be done. Unfortunately, it didn’t go through. Eventually what I worked on was The Breakfast Club: The Video Game. That was kind of a frustrating game to work on, but the engine was a breeze and I could take pride in some design elements so I was happy.

The New Liberty Engine

It was March of ’07. By this time I had a pretty complex level editor that I had been putting together since Little Loki was being made the previous summer. The goal was to replace the code that hitTested against flash’s paint with polygon values so movements could be much more precise and therefore much quicker without errors (I like speed in games). On my free time, I had returned to my old Meteor Henry demo (which I first put together in 5/07 to convince LiquidGeneration to hire me), and started recoding it to be made into a full game, only to realize that it would either move too slowly or demand a much more powerful engine. I had come up with all kinds of ways to reduce the effects of dropped frames like a framerate compensator that would loop the engine so it could run smoothly at lower framerates, and forms of averaging movements to smooth them out or predict future actions without doing full calculations. But all that was just putting off the inevitable, finding lazy solutions that led to non-stop bug chasing. What I really needed was a completely time based engine that did things right from the start, but that would require starting over from scratch! No way was I gonna do that. . . . Then I read an Arthouse Games interview with Jonathan Blow about Braid and his experiments with time. “Hell yes,” I said, and I got started immediately.

Over the coming months I went back and forth between engine coding and other small LG projects. Eventually they hired a third programmer, our buddy Tom. Tom saved my ass. He really took a lot of the pressure off so I could focus more on the engine, but summer came and went. The new engine was taking way longer than I expected and the fall semester was fast approaching. Come school, my time was burned. Very little progress was made from late August to late December of ’07. Then I go on vacation and after two days on my own, I have polygons successfully bouncing off of each other, everything working according to plan. Hallelujah.


At the start of the semester I switched from working at the LG office to working at home. School killed most of that idea, but come winter I still knew that last I was in the office, LG was interested in a pinball game. I had all but lost contact with those guys (probably not smart on my part), but I heard they still needed content as badly as ever and I could have a pretty fantastic pinball game in no time if I just implemented circles into my physics engine. So after chasing a few bugs with the polygons, to see them move nicely, I got to work on circles.

Circles are much much easier to code than polygons so progress was delightfully constant. There were a few bugs that took time to hunt, but before long I was looking at perfectly crisp collisions and nice little impulses bouncing my circles back and forth.

That brings us to today.

What’s Next?

Next I must complete a few more steps before I throw together the first pinball demo:

1-Make force coding more user friendly (ideally visual).

2- Implement artificial mechanics like polygons that hinge around a point (for the paddles, hammer, spinners, etc).

3- Implement a method of recording shape creation and destruction (for introducing new balls or other shapes).

4-Small updates to polygon collision testing and engine timing.

Maybe I’ll also implement my latest TraceManager (which I’d love to see in this engine, but I’ve postponed implementing it for a long time so I can continue physics progress).

How It Works?

Sorry, but I won’t go into the inner-workings just yet. There’s still work to do and I’d rather not spend a lot of time on explaining details until I have the final product up here. In the meantime, if anyone has a specific physics or coding question, I would be happy to explain my methods.

-Christopher J. Rock

About the author:
Christopher J. Rock (http://)
Film student at California State, Long Beach. I want to make the gaming world a better place.