Unbearably Fun Game Development

24 September 2019

Fall Release: Assets and Sound!

by Jamie

The big headline is the Asset Revamp. Instead of just passing around strings (and the whole resource path concept), actual Asset objects are given to systems. (api reference, ) These are a mechanism for eager background loading of data.

As part of this, we’ve introduced the concept of a Virtual File System (VFS). The VFS allows assets to be loaded from the Python Path (sys.path), using the same structure as python modules. This simplifies the usage of asset packs (like ppb-mutant) and allows assets not tied to a sprite (namely sound effects) to work.

As a quick example this v0.6 code:

class MySprite(ppb.BaseSprite):
    image = 'thingy.png'
    resource_path = 'resources/sprites'

becomes this v0.7 code:

class MySprite(ppb.Sprite):
    image = ppb.Image('resources/sprites/thingy.png`)

You may also notice that ppb.BaseSprite became ppb.Sprite. This is the result of a bunch of refactoring, and the old name is now deprecated and will be removed in a future release.

Also part of this effort is that there’s three generated image assets available: ppb.Circle, ppb.Square, and ppb.Triangle. Instead of loading data from a file, these generate basic shapes in memory.

The lesser headline is the addition of sound effects! (, ) These are just simply `signal(ppb.events.PlaySound(ppb.Sound('path/to/sound.ogg')))`. Other types of sounds (namely background music) and more advanced control will come in future releases, as we develop the APIs.

Note that the warning about PyGame and Python version compatibility from the v0.6 release notes still apply. In summary: Do not use PyGame 2 or Python 3.8 at this time.

Changes since v0.6:





tags: ppb - releases