Skip to content

Fall Release: Assets and Sound!

Compare
Choose a tag to compare
@pathunstrom pathunstrom released this 24 Sep 23:54
f76bc6e

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! (api reference) 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:

Added:

  • ppb.vfs module - Enables loading of files from Python packages (#306)
  • Asset system - Enables eager, background loading of assets (#306)
    • AbstractAsset ABC (#329)
    • AssetLoaded event (#315)
    • Loading Screen feature (#336)
  • Two Phase Update feature (#273)
  • Sound! (#326)
  • Sprite Layering! (#350, #322)
  • Add ppb.Circle, ppb.Square, and ppb.Triangle generated images (#363)
  • ppb.Sprite is now the base sprite class (#357)
  • ppb.run() accepts arbitrary engine and subsystem arguments (#307)

Changed:

  • ppb.BaseSprite is now deprecated in favor of ppb.Sprite (#357)
  • Deprecate string filenames in favor of assets (#306)
  • Significant file rearrangement. (#316)
  • Animations now based on Asset system. (#308)

Removed:

  • __resource_path__() protocol removed in favor of ppb.vfs (#306)

Invisible:

  • ppb.sprites.BaseSprite now truly just a base class, using mixins to provide features. (#357)
    • ppb.sprites.SquareShapeMixin (#357)
    • ppb.sprites.RenderableMixin (#357)
  • Accept only stable versions of ppb_vector (#303)
  • Renderer no longer tracks resources (#306)
  • Tolerances on Camera dimensions loosened. (#319)
  • Manual Tests (#328)
  • Updated Contributing.md (#324)