Some Python Raylib Notes

Getting Started

You don’t need to manually install the native raylib; installing the Python bindings brings it in for you automatically:

python3 -m pip install --user raylib

Try it out:

#!/usr/bin/env python3

import pyray as pr

def main():
    init_game()
    while not pr.window_should_close():
        update_game()

        pr.begin_drawing()
        pr.clear_background(pr.BLACK)

        draw_game()

        pr.end_drawing()

    pr.close_window()

def init_game():
    pr.init_window(800, 450, "Window Title")
    pr.set_target_fps(60)
    pr.hide_cursor()

def update_game():
    pass

def draw_game():
    pr.draw_text("Hello world", 100, 200, 20, pr.VIOLET)

#---------------
main()