Monthly Archive for February, 2010

Tidings and Nexus One

We’ve just met a major deadline in the office! Looks like it’s gonna be pretty easy-going for the rest of the week. The website template for has more or less been completed. The only thing left to do is add content to the site (and remove those super cool placeholder content :().

I’ve recently come across a cool smartphone by google, dubbed the Nexus One, and apparently from the reviews it’s hardware is far more superior than the iPhone 3gs. I’m an owner of a iPhone 3g (not 3gs) and frankly I’m sick of the lack of customizability, and the ridiculous need to use iTunes (which runs horribly on windows). I mean just check out this trailer and tell me you don’t wanna get one.

Anyway, part 2 of my Skeletal Animation in 2D article will be out in a couple of days, after I actually implement the system. I’ll make sure I have some screenshots and a couple of code listings. As for Project Warpy, my team has requested that I reveal as little as possible until the demo release date. It’ll help build the excitement I guess. 🙂

Until we next meet… happy coding! 😀

Skeletal Animation in 2D (Part 1: Concept)

Sometime last year I was playing the game patapon for the psp. Impressed by the fluid animation I tried to look for the technique utilized by the game to perform it’s character animations. I guess my search terms must have been wrong because I couldn’t find any viable results. Half a year later I stumbled across Patapon DS a homebrew version of patapon for the DS, and this post, in particular, caught my attention.

After examining the animation technique presented in that post, I was left thinking: “This seems awfully familiar” and before I knew it I decided to try skeletal animation in 2D (like patapon). My first experiment consists of loading .X models (with only bones exported) and using these bones as entities in a 2D scene graph.

So here’s the motivation factors of this technique:

  • Easy to deploy (Information on bone transformation and .X file format easy to obtain)
  • Easy to create content (No special animation tool or file format required, just a .X exporter)
  • Easy to integrate (Since bones function similarly to parent-child scene-graphs)

This technique, if successful, will be utilized in project warpy for enemy animations.

Work work

Been having a busy week in the office.. Got a deadline coming in 2 days and “loads” of work to do. Ah well, time to pump caffeine into my veins. I’ve been working on a new website design for, the company I’m setting up in late 2011.

Here’s a screenshot of what I’ve got:

All placeholder images belong to their respective owners, of course!

I’ll be back in 2 days to post an article (about bone transformation and hierarchical rendering in 2D) so see ya then.

Hierarchical Based Systems

Programming complex game scenes often leads to very large and unmodular classes. During my years as a game programmer, one of the systems I’ve discovered to solve this problem is Hierarchical Based Systems. In fact, some languages are even centered around this ideology, namely flash as3!

Structure of a Hierarchical System

So what exactly is a hierarchical based system? Well simply put, a scene is divided into nodes where each node is a useful object that “exists” in the scene. One can say nodes are modular logic code. The basic rule of a node, in my opinion, is that it must have a parent and a set of children. The node first runs it’s own logic followed by all its children logics. Therefore just by calling the root node’s logic functions, all its children (and their children too) have their logics called automagically.

Here’s an example of a game component:

class Component
  std::list<Component*> children;

  void addChild(Component* component)

  void removeChild(Component* component)

  virtual void update()

  void _update()
    for (std::list<Component*>::iterator i = children.begin(); i != children.end(); i ++)

This class serves as a template, where inheriting classes just have to modify the update() function. The framework programmer then calls _update() to update the object and all its children down the hierarchy.

As if this wasn’t useful enough, nodes can further improve coding in games by providing the platform for scene management techniques, such as scene-graphs and octrees. But more on that another time. 😛

Platformer Character Control (Farseer Physics Engine)

Creating believable 2D platformer physics using a physics engine is always a challenge as character control is mostly “unrealistic” and often cannot be perfectly replicated using any simulator. I learned this the hard way when I embarked on project “Warpy”. However after receiving some help from another programmer, Robert Dodd of Boxycraft (, I managed to code a character movement system that I was happy with.

Image courtesy of Robert Dodd

Image courtesy of Robert Dodd

The whole idea stems from movable objects in a physics world having “wheels” to move around. Robert explains this technique in detail in his blog at: Using some of the helpful advice he provided I managed to replicate his system using Farseer’s rectangle and circles body.

My rectangle body is connected to the circular wheel by the means of a RevoluteJoint (as illustrated in Robert’s Blog) with a motor enabled on it (travelling at a constant speed). The result is a character that is able to climb slopes, stop abruptly and collide into walls without travelling up them.

The next part of the character physics was to create the jump logic that would eventually control the player’s jumping and midair movement. This was done using a ray (like the image above) cast to the ground to determine player’s distance from the ground. When the player is closer than 5 pixels to the ground I set a flag so the player knows he is on the ground and is able to jump.

For midair movement, I studied Super Mario World for the snes and realized that when moving in midair Mario can adjust his position by moving left and right, however he could not move faster than his initial “lift off” velocity. Following this concept closely, I extracted the characters linear velocity along the x axis on initial lift off:

In jump function:

xJumpStrength = body.body.LinearVelocity.X;

In movement function:

if (jumpState != JumpState.GROUNDED)
    // player is in mid air.. add force to body..
    body.ApplyForce(new Vector2(xMovement * 10000, 0));

    if (Math.Abs(body.LinearVelocity.X) > Math.Abs(xJumpStrength))
        float jumpDir = body.body.LinearVelocity.X / Math.Abs(body.LinearVelocity.X);
        body.LinearVelocity.X = jumpDir * Math.Abs(xJumpStrength);

The result of all this, is a character that sort of moves and behaves like Mario, but with support for odd angle slopes, round surfaces and polygon platforms!

p.s. if you’re wondering what Project “Warpy” is about, it’s a secret… at least for now. 🙂

Descent into Madness

Hello there! If you happened to chance across this blog (by whatever means)… Welcome!

This is going to be my development blog but it’s still not ready. I’m busy customizing this blog to my needs (which is mostly easy because wordpress is just so awesome).

In the meantime if you’re bored, do drop a comment or visit my entertainment blog: for jokes and funny videos I find on the internet.

Anyway, if you really want to find out about what I’m up to, come back in a few days. Thanks for dropping by though!