PyBevy is in an early and experimental stage. The API is incomplete, subject to breaking changes without notice, and you should expect bugs. Many features are still under development.
The "Magic" - Hot Reloading
See your code changes live without restarting the app.
Introduction
This is pybevy's star feature! You can change your game's logic
and see the results instantly.
For this example, DO NOT run it with python 02_hot_reloading.py.
Instead, you must run it from your terminal using the pybevy watch command:
pybevy watch --full 02_hot_reloading.py
The --full flag reloads everything on each change, including
setup systems (scene creation, spawning entities). Without it, only
game logic (Update systems) is reloaded — faster for iterating on
runtime behavior once your scene is set up.
While in watch mode, you can also press F5 in the running app window to manually trigger a full reload of setup systems.
Your app will start. Now, try editing this file!
from pybevy.prelude import *Resources
A Resource is a global piece of data. There is only one of them.
The ClearColor resource tells the renderer what color to use for
the background.
We'll add a setup system that runs once at Startup to set
the initial background color.
commands.insert_resource() adds our resource to the app.
We'll start with a blue background.
def setup(commands: Commands):
commands.insert_resource(ClearColor(Color.srgb(0.1, 0.2, 0.7)))The Magic
While your app is still running (from pybevy watch), try
changing the ClearColor value below and saving the file.
For example, change Color.srgb(0.1, 0.2, 0.7) to Color.srgb(0.7, 0.2, 0.1).
You will see the window color update instantly!
@entrypoint
def main(app: App) -> App:
return app.add_plugins(DefaultPlugins).add_systems(Startup, setup)
if __name__ == "__main__":
main().run()