2009/03/27

Black & White controls for Python

Do you remember the game Black and White and and its novel approach to UI control? The player used the mouse to draw gestures. These gestures were recognized by the game and controlled large parts of the game.

Inspired by an article published on GameDev.net, I reimplemented the stuff for single stroke gestures in Python. You can download the gestures class here. Additionally, you will need the Vector2D class published earlier. Both classes are well documented and I will publish some usage examples within the next days.

2009/03/26

Build a Game within one Week

Sounds great, doesn't it?

If you like the idea, than you should register for PyWeek8.

You can either take part as team or individual
, vote for one of five topics and after the theme for the challenge is announced, you have exactly one week to implement your game in Python.

Good Luck!

2009/03/25

A Two Dimensional Vector For Python

To make the usage of PyGame easier I implemented a simple class for two dimensional vectors which can be downloaded here. It makes heavy usage of Python's operator overloading and metaobject protocol.

Please leave a comment and let me know what you think about it.

2009/02/18

Collision Detection

Today I finished an example for collision detection in Pygame.

Pygame supports multiple methods for collision detection. The one presented in this tutorial will be pygame.sprite.spritecollide(sprite, group, dokill, collided = None). spritecollide gets a sprite and a group of sprites and returns a list of all sprites, which collides with the first sprite. Additionally you can define, if the collided sprites should be removed from the group or not. collided can be used to define the function, which should be used to decide, if two sprites collides. For more information you can take a look at Pygames documentation.

The interesting part in this demo is that the performance of the collision functions can be compared to each other. This is done by defining the collide parameter.


During the test we had 250 collision detection calls per frame.

It can be seen, that some functions are more expensive than others. It is up to you, to choose the best one.