reusable Animator for Gosu….

Gosu is a cool lightweight game development library for Ruby. It has a notion of image-tiles(an image which contains multiple images(tiles)… related to an animation(sequence of images)).

While working on a small 2D game(Bakery), i came across the need for an animator, which could handle switching between images in commonly used ways. Since Gosu doesn’t have a wrapper like this…. i had to write one myself.

It can help in playing an animation based on image-tileset in following ways…

  • Playing one way animation(start to end) with custom width(width here means update events).
  • Playing two way animation(start to end to start) with custom width.
  • Playing continuous animation(start to end) in an endless loop.
  • Playing continuous animation(start to end to start) in an endless loop.

It will have support for callback in some time(which is not there as of now). To figure out what all places an animation may need callbacks… i’ll have to use it in multiple places, so it has to wait for some more time.

There is a shoulda testcase(in the same codebase) which shows how to use the animator.

Check out Util::Animator at project’s github repository. The clone url is git://github.com/janmejay/bakery.git.

Go ahead and use it if you need something similar…..

The codebase itself uses the animator in multiple places… those may serve as decent examples.

About these ads

About this entry