My very first Pygame project. Its not professional and it certainly isn’t the best way to implement what I was hoping to implement. But as they say, a journey of thousand miles begins with a single step.



This little program here lets the user click around the screen to make a maple leaf move. The basic idea is, the closer you click, the faster the leaf moves. The user will have to do his part by imagining that a wind blows from the point of click to the center of the maple leaf. Also, simply keeping the mouse button pressed won’t do the trick. You have to keep it pressed AND move it a little bit. The problem is, when u keep ur mouse button pressed, my program interprets it as a single mouse press as long as the location remains the same.

Everything done using python. The maple leaf is actualy a png image. Used pygame library for creating chunk of the program. The little menu u see before the program runs was created using wxpython. Oh, and I’ve converted the whole thing into an exe format using py2exe. Download the ready to execute version here:

For the source code, go here

Note: The source code is in a tarball. Linux users just have to extract it. But windows users will have to find some software that can open tarball files.  But I think new versions of winrar can open that file.

Here’s an overview of what I’ve done :

  1. vector2.py : Created a vector class to handle all those vector additions (for adding velocity of wind to that of leaf)

  2. wind.py : A Wind class which contains functions that calculate the direction and magnitude of the vector from a point to the centre of the leaf

  3. World.py: Mainly contains the code for creating platforms (hurdles) that reflect the leaf. Since I found the collision detection a little buggy, I’ve programmed the game.py (main file) to skip over platforming creation

  4. Leaf.py: Contains everything directly related to the protagonist of our story - the maple leaf. Contains functions to render the picture (which is really a static png image) , move the picture (update the coordinates) and collision detection in case the platforms are present

  5. game.py: The main file. Calls every other function. Contains the code for creating a basic menu for the program as well

    The program is not very complicated, even though it spans multiple files.