Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Passer

A Python 2D game framework in the spirit of Sparrow and Starling — the Flash-style display list, reborn on moderngl (rendering) and pyglet (window, input, audio).

The sparrow (genus Passer) flies again — this time in Python.

Leggi il README in italiano.

from passer import App, Quad

app = App(400, 300, "Hello Passer")
quad = app.stage.add_child(Quad(100, 100, color=0xFF3355))
quad.align_pivot()
quad.x, quad.y = 200, 150

app.run(lambda dt: setattr(quad, "rotation", quad.rotation + dt))

Why

Sparrow brought Flash's display list to iOS, and Starling carried it to a whole generation of 2D games: a scene graph with hierarchical transforms, tweens, jugglers and texture atlases — an ergonomics the Python 2D ecosystem (flat sprite lists) never had. Passer brings that architecture to Python, with a batching renderer on modern OpenGL that can be tested headless, down to the pixel.

Features

  • Scene graphSprite, Quad, Image, Mesh, hierarchical transforms (pivot, scale, rotation, skew), bubbling events, touch and keyboard input, hit testing that follows actual geometry
  • Starling 2 rendering core — CPU-transformed mesh batching (MeshBatch/BatchProcessor): one draw call per state run
  • Mesh styles — plug your own GLSL shader into any mesh without breaking batching (MeshStyle/MeshEffect)
  • Distance field text & shapes — crisp at any scale, with outline, glow and drop shadow in a single pass; built-in SDF generator (exact euclidean distance transform, pure Python)
  • Masks — stencil-based, rotated and nested, inverted masks included
  • Blend modes — add, multiply, screen, erase, mask, below + custom
  • Canvas & Polygon — filled polygons (ear-clipping triangulation), circles, rounded rectangles, quadratic/cubic Bézier paths
  • Filters — blur, color matrix, drop shadow, glow, and FilterChain to compose them; pooled render targets
  • RenderTexture — draw once, render forever (trails, painting, destructible terrain)
  • AnimationJuggler, Tween (with transitions), MovieClip, delayed calls
  • Text — AngelCode bitmap fonts, embedded 8px "mini" font (plus its distance-field twin, generated at runtime)
  • AssetManager — enqueue folders, load with progress, fetch everything by name; atlas regions found automatically
  • Desktop citizenship — letterbox scaling (fit/integer/stretch), fullscreen, mouse wheel, hover

Install

pip install passer-2d

Requires Python ≥ 3.10 and OpenGL 3.3. Linux, Windows and macOS (everything pyglet + moderngl support).

Tested where it counts

The whole rendering pipeline is exercised by 134 tests that render on a headless standalone GL context and assert on real pixels — masks, blend modes, filters, distance fields, triangulation. No window needed; they run in CI.

Demos

The demos/ folder is a tour: a mini platformer with the original Sparrow assets, vector night scenes, playing cards drawn with Bézier curves, plasma shaders, stencil-mask lanterns, drop shadows, SDF typography, and the three-line AssetManager pantry.

Heritage & license

Passer is a conceptual port of the Sparrow Framework and of Starling 2 (© Gamua GmbH, Simplified BSD) — same architecture, pythonic API (snake_case, properties, duck typing). Passer itself is released under the Simplified BSD license; see LICENSE.md.

A heads-up for contributors: the codebase is documented in Italian (docstrings and comments) — the author's native tongue. The API itself is plain English.

About

A Python 2D game framework in the spirit of Sparrow and Starling — the Flash-style display list, reborn on moderngl (rendering) and pyglet (window, input, audio). The sparrow (genus Passer) flies again — this time in Python.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages