Code Examples
A curated collection of runnable examples, each demonstrating a specific feature.
2d →
2D Shapes
Render 2D shape primitives like circles and rectangles.
Bloom 2D
Bloom post-processing effect with glowing 2D sprites and meshes.
CPU Draw
Modify image pixel data directly from the CPU each frame.
Mesh 2D
Render a 2D mesh from a rectangle primitive with a color material.
Mesh 2D Alpha Mode
Demonstrate different alpha blending modes for 2D meshes.
Mesh 2D Vertex Color Texture
Render a 2D mesh with per-vertex colors blended with a texture.
Move Sprite
A sprite that moves back and forth across the screen.
Rotation
Rotate a 2D sprite continuously using a custom rotation speed.
Sprite
Displays a single sprite loaded from an image file.
Sprite Animation
Animate sprites in response to keyboard input with configurable FPS.
Sprite Flipping
Displays a sprite flipped horizontally using the flip_x property.
Sprite Sheet
Animate a sprite by cycling through frames in a sprite sheet.
Sprite Tile
A sprite tiled in a grid with an oscillating size animation.
Text 2D
Render and animate text in 2D world space.
Transparency 2D
Display overlapping sprites with different transparency levels.
3d →
Simple 3D Scene
A simple 3D scene with a light shining over a cube on a plane.
3D Shapes
Display multiple 3D shape primitives like cubes, spheres, and cylinders.
Animated Material
Animate a material's color over time using a system.
Load glTF
Load and display a glTF/GLB 3D model.
Lighting
Demonstrates different light types: point, directional, and spot lights.
Orthographic
Set up a 3D scene with an orthographic camera projection.
Parenting
Illustrates how to create parent-child relationships between entities and how parent transforms are propagated to their descendants.
Spherical Area Lights
Demonstrates point lights with different radii acting as area lights.
Texture
Load and apply a texture image to a 3D mesh.
Vertex Colors
Display a mesh with per-vertex colors.
Wireframe
Render meshes in wireframe mode.
animation →
Animated Transform
Animate an entity's position, rotation, and scale over time.
Color Animation
Animate material colors over time for visual effects.
Easing
Demonstrate different easing functions for smooth animations.
glTF Skinned Mesh
Load and display an animated skinned mesh from a glTF file.
Morph Targets
Demonstrate morph target (blend shape) animation on a glTF model.
app →
Empty App
The absolute minimal PyBevy application — creates and runs an app with no plugins.
Empty Defaults
An app with default plugins that opens a window and runs until closed.
Plugin
Create and register a custom plugin that prints a message at regular intervals.
Return After Run
Execute code after a PyBevy app has exited.
Without Winit
Run a headless PyBevy app without a window.
ecs →
Change Detection
Detect when components or resources have been modified.
ECS Guide
A guided introduction to PyBevy's Entity Component System pattern.
Fixed Timestep
Compare Update (every frame) with FixedUpdate (fixed time intervals).
Hierarchy
Create parent-child entity relationships with automatic transform propagation.
Message
Send and receive messages between systems using the message system.
Removal Detection
Detect when components are removed from entities using observers.
Startup System
Demonstrates systems that run once at application startup.
System Closure
Use closures and captured variables as systems.
System Param
Shows the different system parameter types available in PyBevy.
input →
Character Input Events
Read character input events for text entry and typing detection.
Gamepad Input
Read gamepad button and axis state for connected controllers.
Gamepad Input Events
Print gamepad connection, button, and axis events as they occur.
Keyboard Input
Check keyboard button state for pressed, just pressed, and just released keys.
Keyboard Input Events
Print all keyboard events as they occur using the message system.
Keyboard Modifiers
Detect modifier keys like Ctrl, Shift, and Alt in combination with other keys.
Mouse Grab
Capture and hide the mouse cursor for FPS-style camera control.
Mouse Input
Track mouse button state and detect mouse motion.
Mouse Input Events
Print all mouse events including button, motion, cursor, and scroll.
Touch Input Events
Handle touch screen input events for mobile and touch devices.