This repository has been archived on 2025-06-21. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
raylib-python-cffi/docs-src/pyray.rst
2023-05-22 18:24:44 +01:00

69 lines
1.6 KiB
ReStructuredText

Python API
==============
This is a wrapper around the C API with some syntactic sugar.
The API is *still the same as Raylib*, so you should still reply on:
* `the C Raylib docs <https://www.raylib.com/cheatsheet/cheatsheet.html>`_
* `the C Raylib examples <https://github.com/electronstudio/raylib-python-cffi/tree/master/examples>`_
* `the C Raylib header file <https://github.com/raysan5/raylib/blob/master/src/raylib.h>`_
The *differences* are:
* the function names are in **snake_case**.
* Some string and pointer conversions are handled automatically.
* There are some helper functions to create structures.
Examples
--------
Example program:
.. code-block::
import pyray as pr
pr.init_window(800, 450, "Hello Pyray")
pr.set_target_fps(60)
camera = pr.Camera3D([18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0)
while not pr.window_should_close():
pr.update_camera(camera, pr.CAMERA_ORBITAL)
pr.begin_drawing()
pr.clear_background(pr.RAYWHITE)
pr.begin_mode_3d(camera)
pr.draw_grid(20, 1.0)
pr.end_mode_3d()
pr.draw_text("Hello world", 190, 200, 20, pr.VIOLET)
pr.end_drawing()
pr.close_window()
.. tip:: New in 3.7.0.post9:
You can also now import the functions with no prefix:
.. code-block::
from pyray import *
init_window(800, 450, "Raylib texture test")
...
(You don't need to use the PyRay() class anymore.)
`See all examples here <https://github.com/electronstudio/raylib-python-cffi/tree/master/examples>`_
API reference
-------------
.. autoapimodule:: pyray
:members:
:undoc-members: