Rabbyt: a fast sprite library for Python
Rabbyt is a sprite library for Python with game development in mind. It has two goals:
- Be fast, without sacrificing ease of use.
- Be easy to use, without sacrificing speed.
Download
You may always download the latest release of Rabbyt on it's cheeseshop page.
You can get the latest development version of rabbyt using mercurial:
$ hg clone http://matthewmarshall.org/projects/rabbyt/hg.cgi rabbyt_dev
Additionally you can browse the mercurial repository online.
Documentation
By popular demand, (or rather, by necessity,) you can now browse the rabbyt documentation online!
Current Features
Rabbyt is early in development, but there is already a lot it can help with.
Sprites
Sprites are easy! You can create one by just specifying a texture:
car = rabbyt.Sprite("car.png")![]()
Rotating and scaling are hardware accelerated, and easy!
car.rot = 45 car.scale = 0.5![]()
Animations
Animating is common need for game graphics, and doing a large number of them in python can get slow. Rabbyt provides a set of Anim (short for animator) classes to calculate common animations in C. For example, you can slowly fade out the car sprite like this:
car.alpha = rabbyt.lerp(1.0, 0.0, dt=1.0)
That will linearly interpolate the sprite's alpha from 1.0 to 0.0 over the next 1 second. This both easy to use, (you just set it and forget it,) and fast (it all happens in C code.)
Take a look at the lotsofsprites.py example in the Rabbyt download. It makes use of anims for the position, rotation, scaling, and color of 2400 sprites. And it runs fast.
Collision Detection
Collision detection is another thing that is difficult to do in pure python. Rabbyt can do the tedious part for you. Just pass rabbyt.collisions.collide() a list of anything that has x, y, and bounding_radius attributes (like a sprite) and you'll get back a list of collisions. (Ok, that sounds a little corny after I wrote it, but whatever.)
Check out the collision.py example to see how fast it is. On my machine, it takes an average of 1 millisecond to do a brute force collision check between 400 sprites.
Mailing List
There is a Google Group set up here. This is the place to go if you need help.
Or you can contact me directly. I don't bite :)
What's up with the name?
Well, both of the goals are to be fast, like rabbits. Also, there is another cool multimedia library for python called Pyglet, and Rabbyt just seemed to follow. If you're looking to name your own library, consider Wynnye or Tygger or Chrystopher Robbyn. Tygger especially would make a good name for a physics library.