Errors and constants¶
When things go wrong¶
VS2 tries to fail at the line that caused the problem, during build(), rather
than rendering something wrong later. These are the errors you will actually
meet.
- exception vs2.SceneSealedError[source]¶
Bases:
RuntimeErrorA structural call was made outside
Scene.build().Creating layers and drawables is only legal while
build()runs. Once it returns the scene is sealed, and callingLayer.sprite()or any other factory fromupdate(), a timer, orteardown()raises this instead of quietly growing the display graph mid-game.It is also raised when a drawable that outlived its scene is written to, which is how a stale handle kept across scene entries surfaces.
- exception vs2.ResourceLimitError[source]¶
Bases:
RuntimeErrorA scene asked for more sprites, tilemaps or layers than the target has.
The message carries a per-layer census so the offending budget is obvious:
sprite 101/100 in Vixeous (world: 62, hud: 39); reduce the sprite budget
Because every structural call happens during
Scene.build(), this is always raised the first time the scene is entered rather than mid-game.
- exception vs2.AssetLimitError[source]¶
Bases:
ResourceLimitErrorThe loaded asset pack holds more image strips than the target supports.
- exception vs2.AssetNotFoundError[source]¶
Bases:
LookupErrorAn image name is not present in the scene’s asset pack.
Usually a typo, or a PNG that is not in the game’s
images/folder.
- exception vs2.FrameError[source]¶
Bases:
ValueErrorA frame index falls outside its image’s frame count.
Raised at the assignment, so an out-of-range frame is reported at the line that set it instead of rendering garbage pixels.
Reading the messages¶
Error |
Usual cause |
What to do |
|---|---|---|
|
A typo, or the PNG is not in the game’s |
Fix the name or add the image. |
|
A frame out of range. |
Use |
|
Shrink a pool, or move text from sprites to a |
|
|
A drawable was created from |
Create it in |
|
A drawable handle outlived its scene, often one stored in |
Create drawables in |
Constants¶
Projections¶
Passed to Scene.layer as projection=, and
decide how a layer maps Y to LEDs. The tutorial’s
circular display chapter explains them with examples.
- vs2.TUNNEL = 1¶
Perspective. Y is depth,
0..255, from the outermost ring to the centre. The usual choice for a game world.
- vs2.HUD = 2¶
Flat, no perspective. Y is a direct LED index,
0..53, soy = 0is the outermost LED. The usual choice for scores and overlays, which are most legible at low Y.
- vs2.FULLSCREEN = 0¶
One centred image, for planets, backdrops and cloud cover.
y = 0fills all 54 LEDs and larger Y contracts it toward the centre. Sprites only — creating a tilemap or label on aFULLSCREENlayer raises duringbuild().
Tiles and pools¶
- vs2.EMPTY_TILE = 255¶
A tilemap cell that draws nothing. Newly allocated cell buffers are filled with it, and
Label.writepads with it.
- vs2.TRANSPARENT = 255¶
The palette index the renderer treats as see-through.
- vs2.RECYCLE¶
Passed as
on_empty=toLayer.sprite_pool. An exhausted pool then reuses its oldest live sprite instead of returningNone— the right default for explosions and particles, where dropping one is worse than cutting another short.