LD 29 is the first LD that I participated in. The jam went okay, beside not having a great idea, I didn’t get to finish all that I wanted to do. The game didn’t do too well in the rankings, but its not a big deal. Every time I make a game using Pygame, I find myself typing in the same thing over and over, wasting time. That’s why I made Rapid Pygame for MiniLD 51.
Rapid Pygame is a set of classes and tools that help accelerate the game development process when using Pygame, letting the developers to focus on game play features rather than the tiny building blocks behind the scene. It requires Python 3+ (Its time to move on)
Now of course, since Pygame uses Python, no body is going to use it, let alone this library. However I did spent a lot of time writing the docs for this project.
Enough words! Lets see what it can do!
Painless relative loading
Games load stuff. Images, sound, levels… And its pretty common to load a file relative to the executable or script. How do you do it in Pygame normally?
(Getting the path of the script, and then use os.path.join to join together path names. Loading from “./” wouldn’t always work since its relative to the current working directory)
Its fairly easy to read and understand, but its long and kind of messy.
Enter the ImageLoader class
Easier to read and understand. Loading using the instance is all relative to the path given in the constructor. Cross-platform relative path loading made easier.
It would be a pretty boring helper class if that’s all it can do. ImageLoader is also capable of other things outline here. Loading all images in a folder, loading a sequence of images and giving back a path string relative to the origin if you don’t want to load an image.
Collision powered level manager
One approach of managing a map in games is using collision, the player can move around, as long as he/she is not colliding with the level. Its intuitive and powerful. Rapid Pygame provides a way of quickly getting a level up and running.
This will produce a level that a player can move around in (left right and jump). The level manager will take care of gravity, player movement and level collision. Pretty simple right? A 60 line basic game :). This will become even shorter and simpler in future version of the library. The details about the level format and the player class can all be found in the docs.
Behind the scenes
That’s pretty much all the features of the library, other than the pre-made Player class that renders animation for you. Below is a bit about how the level manager behind the scenes.
One thing the level manger do is take the level landscape, and break it down into rectangles, which are then used for collision checking with the player. I’ve made some improvement to the algorithm compare to the old ones I used in the past. Each block represents a rectangle
The old approach is to break the level down into strips either vertically or horizontally.
The algorithm in the library will try to maximize the area of the rectangles, producing fewer rectangles for faster collision checking
Although its not prefect
Both methods are probably fast enough to not have a real impact on the game’s performance, but its nice to know that the algorithm that powers the manager is semi-smart XD
Well, hopefully I didn’t just waste my time typing this up, even though I highly doubt it. Thanks for reading and good luck to everyone in your future LD endeavors! Whether you use Pygame or not