⚠️ Beta State

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.

Your First Window

The absolute simplest pybevy app that opens a window.

Introduction

Welcome to pybevy! This is the simplest possible app you can make. It will import pybevy, add the DefaultPlugins, and start the app. The DefaultPlugins are a pre-packaged bundle that adds all the essentials for a game: window creation, input, rendering, and more.

# We import all the common features from the pybevy library.
from pybevy.prelude import *

The App

In PyBevy, everything starts with an App object. This object holds all your game's data, logic, and plugins.

Here, we:

  1. Create the App().
  2. Add DefaultPlugins. This tells PyBevy to create a window, set up rendering, and handle input.
  3. Call .run() to start the application.
@entrypoint
def main(app: App) -> App:
    return app.add_plugins(DefaultPlugins)
 
if __name__ == "__main__":
    main().run()

When you run this file (python 01_first_window.py), you should see a new, empty window appear!