Compare commits

..

88 commits

Author SHA1 Message Date
Richard Smith
0f8367566b merge master 2024-11-19 12:19:53 +00:00
Richard Smith
fc9d66ed14 Merge remote-tracking branch 'origin/master' into fix_underscore2
# Conflicts:
#	create_stub_pyray.py
#	docs/genindex.html
#	docs/objects.inv
#	docs/pyray.html
#	docs/raylib.html
#	docs/searchindex.js
#	dynamic/raylib/defines.py
#	make_docs.sh
#	pyray/__init__.pyi
#	raylib/__init__.pyi
#	raylib/build.py
#	raylib/defines.py
#	raylib/raylib.h.modified
#	raylib/rlgl.h.modified
#	version.py
2024-11-19 12:14:37 +00:00
Richard Smith
32cc42dab3 fix how regex inserts underscore in function names with '2d' and '3d' 2024-10-24 18:04:55 +01:00
Richard Smith
96d620382c Merge branch 'master' into sdl
# Conflicts:
#	version.py
2024-10-24 17:43:45 +01:00
Richard Smith
1817fec006 try 2024-10-17 15:58:59 +01:00
Richard Smith
cfad3eacaa try 2024-10-17 11:31:56 +01:00
Richard Smith
e01bdb3b78 try 2024-10-17 11:25:56 +01:00
Richard Smith
509771f482 try 2024-10-16 22:11:02 +01:00
Richard Smith
3d8f36e9c7 try 2024-10-16 22:02:23 +01:00
Richard Smith
9683c579c3 try 2024-10-16 19:16:54 +01:00
Richard Smith
e97135eb8c try 2024-10-16 19:03:30 +01:00
Richard Smith
5dafa4e99a try 2024-10-16 14:22:45 +01:00
Richard Smith
be6cf57d85 try 2024-10-16 13:49:19 +01:00
Richard Smith
62ff73d0e7 try 2024-10-16 12:11:34 +01:00
Richard Smith
4670e271ca try 2024-10-16 11:21:40 +01:00
Richard Smith
adbcdce416 try 2024-10-16 03:06:52 +01:00
Richard Smith
3269b0cb9b try 2024-10-16 02:59:35 +01:00
Richard Smith
d17d3abb92 try 2024-10-16 02:44:36 +01:00
Richard Smith
b0da316441 try 2024-10-16 02:30:45 +01:00
Richard Smith
2154d36b41 update raylib 2024-10-16 02:19:24 +01:00
Richard Smith
b3ff23e6cf try 2024-10-16 01:59:21 +01:00
Richard Smith
fb3f3f9b22 try 2024-10-16 01:57:56 +01:00
Richard Smith
b8231d23b8 try 2024-10-16 01:44:19 +01:00
Richard Smith
29f5f42af7 try 2024-10-16 01:20:35 +01:00
Richard Smith
b14d0a2b3c try 2024-10-16 00:58:26 +01:00
Richard Smith
cadf3d1f0c try 2024-10-16 00:53:49 +01:00
Richard Smith
3c7289c844 try 2024-10-16 00:30:04 +01:00
Richard Smith
0bf9138122 try 2024-10-16 00:22:22 +01:00
Richard Smith
447b17446f try 2024-10-16 00:18:19 +01:00
Richard Smith
a11016ba34 try 2024-10-16 00:07:25 +01:00
Richard Smith
7899b51bbd try 2024-10-16 00:00:10 +01:00
Richard Smith
3314597eed try 2024-10-15 23:47:34 +01:00
Richard Smith
391e600693 try 2024-10-15 23:41:36 +01:00
Richard Smith
05ada5fa0d try 2024-10-15 21:00:59 +01:00
Richard Smith
10692d5168 try 2024-10-15 20:29:41 +01:00
Richard Smith
7e2da775ae try 2024-10-15 19:51:44 +01:00
Richard Smith
35c457ef7d try 2024-10-15 19:44:20 +01:00
Richard Smith
05c455b17f try 2024-10-15 19:43:04 +01:00
Richard Smith
3b0238c61d try 2024-10-15 19:28:21 +01:00
Richard Smith
05e71eae62 try 2024-10-15 19:22:58 +01:00
Richard Smith
1b73f0f8b0 try 2024-10-15 19:14:25 +01:00
Richard Smith
1f172355d3 try 2024-10-15 19:12:08 +01:00
Richard Smith
e692b7ce99 try 2024-10-15 18:57:55 +01:00
Richard Smith
7f05708aad try 2024-10-15 18:47:47 +01:00
Richard Smith
30913ef51a try 2024-10-15 18:25:57 +01:00
Richard Smith
afa5ae9463 try 2024-10-15 18:18:11 +01:00
Richard Smith
a5cb5ab6ed try 2024-10-15 18:12:09 +01:00
Richard Smith
c98bdcd961 try 2024-10-15 17:44:42 +01:00
Richard Smith
65f89be6ee try 2024-10-15 17:32:19 +01:00
Richard Smith
467263a43d try 2024-10-15 17:07:26 +01:00
Richard Smith
2ffd22435a try 2024-10-15 16:54:32 +01:00
Richard Smith
730c9d4643 try 2024-10-15 16:29:30 +01:00
Richard Smith
4c4c17d0de try 2024-10-15 16:23:03 +01:00
Richard Smith
cbdba24ff2 try 2024-10-14 19:41:34 +01:00
Richard Smith
7793b056a0 try 2024-10-14 19:35:17 +01:00
Richard Smith
5fc35c919d try 2024-10-14 19:01:12 +01:00
Richard Smith
fb417dbf71 try 2024-10-14 18:48:15 +01:00
Richard Smith
22f624d7ca try mac 2024-10-13 18:26:29 +01:00
Richard Smith
19ab15d89e try mac 2024-10-13 18:20:06 +01:00
Richard Smith
9d14fbfb23 try mac 2024-10-13 18:13:37 +01:00
Richard Smith
192d2031a7 try mac 2024-10-13 18:06:42 +01:00
richard
ac5b6b95e1 try 2024-10-12 16:32:08 +01:00
richard
ea4b0a007d try 2024-10-12 16:21:46 +01:00
Richard Smith
d0330043c1 try 2024-10-11 18:14:10 +01:00
Richard Smith
edb2d55aa6 try 2024-10-11 18:08:26 +01:00
Richard Smith
b3d05efd05 try 2024-10-11 18:01:43 +01:00
Richard Smith
d693a846ce try 2024-10-11 17:52:39 +01:00
Richard Smith
e2f8b4fb11 try 2024-10-11 17:48:32 +01:00
Richard Smith
6286a2cf66 try 2024-10-11 17:46:08 +01:00
Richard Smith
ecc3c08a45 try 2024-10-11 17:43:40 +01:00
Richard Smith
7323343ada try 2024-10-11 17:40:35 +01:00
Richard Smith
d8647daafa try 2024-10-11 17:39:11 +01:00
Richard Smith
452881e916 try 2024-10-11 17:33:25 +01:00
Richard Smith
c12365d448 try 2024-10-11 17:27:38 +01:00
Richard Smith
4a787f1c71 fix 2024-10-09 19:02:03 +01:00
Richard Smith
55a0d150c4 windows 2024-10-09 18:53:45 +01:00
Richard Smith
957584a9d4 install alsa etc before building sdl 2024-09-24 23:56:31 +01:00
Richard Smith
8db9563c53 try to set fpic 2024-09-24 23:29:29 +01:00
Richard Smith
216c4696f2 try static sdl build 2024-09-24 23:23:30 +01:00
Richard Smith
a9f2884f39 remove glfw header 2024-09-24 19:00:36 +01:00
Richard Smith
dad06219c3 sdl2 link flags 2024-09-20 19:30:14 +01:00
Richard Smith
0bf42b291e sdl dl 2024-09-20 19:10:51 +01:00
Richard Smith
dd9916a8f8 sdl dl 2024-09-20 19:07:23 +01:00
Richard Smith
0a0ceea1dd sdl 2024-09-20 18:48:53 +01:00
Richard Smith
6b7cffe86f add libxkbcommon-dev 2024-09-20 18:40:56 +01:00
Richard Smith
9b81a6d699 update headers 2024-09-20 18:36:17 +01:00
Richard Smith
a48757b815 add libwayland-dev 2024-09-20 18:30:26 +01:00
Richard Smith
271c6e1aeb latest raylib version 2024-09-20 18:25:27 +01:00
59 changed files with 11431 additions and 10821 deletions

View file

@ -89,12 +89,6 @@ mac_task:
- env:
PY_VER: "3.11"
RAYLIB_PLATFORM: Desktop
- env:
PY_VER: "3.11"
RAYLIB_PLATFORM: SDL
- env:
PY_VER: "3.12"
RAYLIB_PLATFORM: Desktop
- env:
PY_VER: "3.12"
RAYLIB_PLATFORM: SDL
@ -137,6 +131,7 @@ mac_task:
- sudo cp -r raylib-c/src/external/glfw/include/GLFW /usr/local/include/
- sudo cp physac/src/physac.h /usr/local/include/
- sudo cp raygui/src/raygui.h /usr/local/include/
- /opt/homebrew/bin/python${PY_VER} -m pip install --break-system-packages --upgrade pip
- /opt/homebrew/bin/python${PY_VER} -m pip install --break-system-packages cffi
- /opt/homebrew/bin/python${PY_VER} -m pip install --break-system-packages setuptools
- /opt/homebrew/bin/python${PY_VER} -m pip install --break-system-packages wheel

View file

@ -12,10 +12,10 @@ on:
jobs:
build-mac-intel:
runs-on: macos-13
runs-on: macos-12
strategy:
matrix:
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy-3.9', 'pypy-3.10', 'pypy-3.11' ]
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy-3.9', 'pypy-3.10' ]
raylib-platform: ['Desktop', 'SDL']
env:
MACOSX_DEPLOYMENT_TARGET: '10.13'
@ -93,9 +93,9 @@ jobs:
fi
- name: Upload build Artifact wheel
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3.2.1
with:
name: wheel-mac-${{ matrix.raylib-platform }}-${{ matrix.python-version }}
name: wheel
path: dist/*
# build-mac-universal:
@ -182,12 +182,12 @@ jobs:
build-linux:
runs-on: ubuntu-22.04
runs-on: ubuntu-20.04
strategy:
# You can use PyPy versions in python-version.
# For example, pypy2 and pypy3
matrix:
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy-3.9', 'pypy-3.10', 'pypy-3.11' ]
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy-3.9', 'pypy-3.10' ]
raylib-platform: ['Desktop', 'SDL', 'DRM']
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
@ -256,9 +256,9 @@ jobs:
- name: Upload build Artifact wheel
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3.2.1
with:
name: wheel-linux-${{ matrix.raylib-platform }}-${{ matrix.python-version }}
name: wheel
path: dist/*
@ -271,7 +271,7 @@ jobs:
# You can use PyPy versions in python-version.
# For example, pypy2 and pypy3
matrix:
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy-3.9', 'pypy-3.10', 'pypy-3.11' ]
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy-3.9', 'pypy-3.10' ]
raylib-platform: ['Desktop', 'SDL']
steps:
- uses: actions/checkout@v4
@ -299,7 +299,7 @@ jobs:
architecture: x64
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
uses: microsoft/setup-msbuild@v1.0.2
- name: Build raylib
run: |
@ -345,13 +345,13 @@ jobs:
fi
- name: Upload build Artifact wheel
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3.2.1
with:
name: wheel-windows-${{ matrix.raylib-platform }}-${{ matrix.python-version }}
name: wheel
path: dist/*
source-distro:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
@ -392,13 +392,13 @@ jobs:
python setup.py sdist
- name: Upload build Artifact wheel
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3.2.1
with:
name: wheel-source
name: wheel
path: dist/*
dynamic-distro:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
@ -424,17 +424,7 @@ jobs:
python setup.py sdist
- name: Upload build Artifact wheel
uses: actions/upload-artifact@v4
with:
name: wheel-dynamic
path: dynamic/dist/*
merge:
needs: [build-mac-intel, build-windows, build-linux, source-distro, dynamic-distro]
runs-on: ubuntu-latest
steps:
- name: Merge All Artifacts
uses: actions/upload-artifact/merge@v4
uses: actions/upload-artifact@v3.2.1
with:
name: wheel
pattern: wheel-*
path: dynamic/dist/*

4
.gitmodules vendored
View file

@ -1,9 +1,9 @@
[submodule "raylib-c"]
path = raylib-c
url = https://git.terah.dev/UnrealXR/raylib.git
url = https://github.com/raysan5/raylib.git
[submodule "raygui"]
path = raygui
url = https://github.com/raysan5/raygui.git
[submodule "physac"]
path = physac
url = https://github.com/victorfisac/Physac.git
url = https://github.com/raysan5/physac.git

View file

@ -83,6 +83,11 @@ To build a binary wheel distribution:
pip3 install wheel
python setup.py bdist_wheel
.. TODO::
There's a hardcoded path (to the raylib header files) in `raylib/build.py` you will probably need to edit.
Would be useful if some Windows user could figure out how to auto detect this.
Then install it:
::

View file

@ -1,30 +1,22 @@
# Python Bindings for Raylib 5.5
## Libraries: raymath, raygui, rlgl, physac and GLFW
## Backends: Desktop, SDL, DRM, Web
## Platforms: Windows, Mac, Linux, Raspberry Pi, Web
![PyPI - Downloads](https://img.shields.io/pypi/dm/raylib)
Chatroom: [Discord](https://discord.gg/fKDwt85aX6)
HELP WANTED: [writing examples](https://github.com/electronstudio/raylib-python-cffi/issues/155)
Features:
* CFFI API static bindings.
New CFFI API static bindings.
* Automatically generated to be as close as possible to
original Raylib.
* Faster, fewer bugs and easier to maintain than ctypes.
* Commercial-friendly license.
* Docstrings and auto-completion.
* Type checking with Mypy
[Full documentation](http://electronstudio.github.io/raylib-python-cffi)
# Quickstart
`pip3 install raylib==5.5.0.2 --break-system-packages`
`pip3 install raylib==5.0.0.4`
```python
from pyray import *
init_window(800, 450, "Hello")
@ -38,19 +30,14 @@ close_window()
# Installation
If you are on a modern Linux you will probably want to create a venv:
python3 -m venv venv
source venv/bin/activate
Then make sure you have the latest pip installed:
First make sure you have the latest pip installed:
python3 -m pip install --upgrade pip
Then install
python3 -m pip install setuptools
python3 -m pip install raylib==5.5.0.2
python3 -m pip install raylib==5.0.0.4
On most platforms it should install a binary wheel. If yours isn't available then pip will attempt to build from
source, in which case you will need to have Raylib development libs installed, e.g.
@ -72,7 +59,7 @@ Older MacOS requires building from source but this is usually simple:
brew install pkg-config
brew install raylib
python3 -m pip install raylib==5.5.0.2
python3 -m pip install raylib==5.0.0.4
(I do have binaries for arm64 MacOS 11, 12 and 13 but I have no way of testing they work, so post an issue
if you want to test them.)
@ -89,8 +76,6 @@ so may not work on other boards.
[Using on Rasperry Pi](RPI.rst)
# Backends
## Dynamic binding version
There is now a separate dynamic version of this binding:
@ -100,8 +85,6 @@ There is now a separate dynamic version of this binding:
It works on some systems where the static version doesn't, [but be sure to read these caveats before using it](https://electronstudio.github.io/raylib-python-cffi/dynamic.html)
You can't have multiple raylib packages installed at once.
## SDL backend
This is not well tested but has better support for controllers:
@ -133,63 +116,53 @@ If it still doesn't work, [submit an issue](https://github.com/electronstudio/ra
# How to use
There are *two* modules in the raylib package, `raylib` and `pyray`. (There is no separate package for
pyray. Do *not* `pip install pyray`). You can use either or both:
There are two modules in the raylib package, `raylib` and `pyray`. (There is no separate package for
pyray). You can use either or both:
### If you are familiar with C coding and the Raylib C library and you want to use an exact copy of the C API
Use [the raylib module](https://electronstudio.github.io/raylib-python-cffi/raylib.html).
### If you prefer a more Pythonistic API
### If you prefer a more Pythonistic API
Use [the pyray module](https://electronstudio.github.io/raylib-python-cffi/pyray.html).
# Running in a web browser
[Pygbag](https://pypi.org/project/pygbag/) >=0.8.7 supports running in a web browser. Usually the latest git version
is recommended.
[Pygbag](https://pypi.org/project/pygbag/) >=0.8.7 supports running in a web browser.
Make a folder `my_project` with a file `main.py`:
```python
# /// script
# dependencies = [
# "cffi",
# "raylib"
# ]
# ///
import asyncio
import platform
from pyray import *
# /// script
# dependencies = [
# "cffi",
# "raylib"
# ]
# ///
import asyncio
import platform
from pyray import *
async def main(): # You MUST have an async main function
init_window(500, 500, "Hello")
platform.window.window_resize() # You MAY want to add this line
while not window_should_close():
begin_drawing()
clear_background(WHITE)
draw_text("Hello world", 190, 200, 20, VIOLET)
end_drawing()
await asyncio.sleep(0) # You MUST call this in your main loop
close_window()
async def main(): # You must have an async main function
init_window(500, 500, "Hello")
platform.window.window_resize() # You must add this line
while not window_should_close():
begin_drawing()
clear_background(WHITE)
draw_text("Hello world", 190, 200, 20, VIOLET)
end_drawing()
await asyncio.sleep(0) # You must call this in your main loop
close_window()
asyncio.run(main())
```
asyncio.run(main())
Then to create the web files and launch a web server:
python3.12 -m pip install --user --upgrade pygbag
python3.12 -m pygbag --PYBUILD 3.12 --ume_block 0 --template noctx.tmpl --git my_project
python3.12 -m pygbag --PYBUILD 3.12 --ume_block 0 --template noctx.tmpl my_project
Point your browser to http://localhost:8000
Some features may not work, so you can disable them like this:
```python
if platform.system() != "Emscripten": # audio may not work on current version of emscripten
init_audio_device()
```
This is all done by Pygbag rather than by me, so you should probably contact them with any issues.
Carefully read all their [documentation](https://pygame-web.github.io/).
@ -197,20 +170,10 @@ It does work for most of [these examples](https://electronstudio.github.io/rayli
# App showcase
[Tempest-raylib](https://github.com/Emtyloc/tempest-raylib)
[KarabinerKeyboard](https://github.com/bilbofroggins/KarabinerKeyboard)
[PyTaiko](https://github.com/Yonokid/PyTaiko)
[DOOM-Clone](https://github.com/StanislavPetrovV/DOOM-Clone)
[Tanki](https://github.com/pkulev/tanki)
[Alloy Bloxel Editor](https://pebaz.itch.io/alloy-bloxel-editor)
[Eidolon](https://github.com/Miou-zora/Eidolon)
Add your app here!
# RLZero

View file

@ -42,7 +42,7 @@ Then have pip compile and install the wheel:
::
python3 -m pip install --break-system-packages setuptools
python3 -m pip install --no-cache-dir --no-binary raylib --upgrade --force-reinstall --break-system-packages raylib==5.5.0.0
python3 -m pip install --no-cache-dir --no-binary raylib --upgrade --force-reinstall --break-system-packages raylib==5.0.0.4
Option 3: Compile Raylib from source DRM mode
---------------------------------------------
@ -85,7 +85,7 @@ Then have pip compile and install the wheel:
::
python3 -m pip install --break-system-packages setuptools
python3 -m pip install --no-cache-dir --no-binary raylib --upgrade --force-reinstall --break-system-packages raylib==5.5.0.0
python3 -m pip install --no-cache-dir --no-binary raylib --upgrade --force-reinstall --break-system-packages raylib==5.0.0.4

View file

@ -24,7 +24,6 @@ def process(filename):
for e in js['enums']:
if e['name'] and e['values']:
print ("class "+e['name']+"("+"IntEnum):")
print(f' """{e['description']}."""')
for value in e['values']:
print(" "+value['name']+" = "+str(value['value']))
print("")
@ -35,4 +34,3 @@ print("""from enum import IntEnum
process("raylib.json")
process("raygui.json")
process("glfw3.json")
process("physac.json")

View file

@ -32,8 +32,7 @@ for filename in (Path("raylib.json"), Path("raymath.json"), Path("rlgl.json"), P
known_structs[st["name"]] = st
for e in js['enums']:
if e['name'] and e['values']:
print("class "+e['name']+"(int):")
print(f' """{e['description']}."""')
print ("class "+e['name']+"(int):")
for value in e['values']:
print(" "+value['name']+" = "+str(value['value']))
print("")
@ -79,11 +78,10 @@ def ctype_to_python_type(t):
print("""from typing import Any
from warnings import deprecated
import _cffi_backend # type: ignore
ffi: _cffi_backend.FFI
PhysicsShapeType = int
""")
# These words can be used for c arg names, but not in python
@ -120,11 +118,8 @@ for name, attr in getmembers(rl):
if 'description' in json_object:
description = json_object['description']
if 'physics' in uname:
print('@deprecated("Raylib no longer recommends the use of Physac library")')
print(f'def {uname}({sig}) -> {ctype_to_python_type(return_type)}:')
print(f' """{description}."""')
print(f' ...')
print(
f'def {uname}({sig}) -> {ctype_to_python_type(return_type)}:\n """{description}"""\n ...')
elif str(type(attr)) == "<class '_cffi_backend._CDataBase'>":
return_type = ffi.typeof(attr).result.cname
@ -149,7 +144,7 @@ for struct in ffi.list_types()[0]:
print("weird empty struct, skipping " + struct, file=sys.stderr)
continue
print(f"class {struct}:")
print(f' """{known_structs[struct]['description']}."""')
print(f' """ struct """')
sig = ""
for arg in ffi.typeof(struct).fields:
ptype = ctype_to_python_type(arg[1].type.cname)

View file

@ -69,12 +69,11 @@ def ctype_to_python_type(t):
print("""from typing import Any
from warnings import deprecated
import _cffi_backend # type: ignore
ffi: _cffi_backend.FFI
rl: _cffi_backend.Lib
PhysicsShapeType = int
class struct: ...
@ -115,12 +114,8 @@ for name, attr in getmembers(rl):
if 'description' in json_object:
description = json_object['description']
if 'Physics' in uname:
print('@deprecated("Raylib no longer recommends the use of Physac library")')
print(f'def {uname}({sig}) -> {ctype_to_python_type(return_type)}:')
print(f' """{description}."""')
print(f' ...')
print(
f'def {uname}({sig}) -> {ctype_to_python_type(return_type)}:\n """{description}"""\n ...')
elif str(type(attr)) == "<class '_cffi_backend._CDataBase'>":
return_type = ffi.typeof(attr).result.cname

View file

@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: f2032a6434b52f7c68551d0ad70d555b
config: 6b88b88b20947586d6498748ffd23a92
tags: 645f666f9bcd5a90fca523b33c5a78b7

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Building from source &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
@ -48,7 +48,6 @@
<li class="toctree-l1"><a class="reference internal" href="README.html">Python Bindings for Raylib 5.5</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#quickstart">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#installation">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#backends">Backends</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#how-to-use">How to use</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#running-in-a-web-browser">Running in a web browser</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#app-showcase">App showcase</a></li>

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Python Bindings for Raylib 5.5 &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
@ -48,7 +48,6 @@
<li class="toctree-l1 current"><a class="current reference internal" href="#">Python Bindings for Raylib 5.5</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#libraries-raymath-raygui-rlgl-physac-and-glfw">Libraries: raymath, raygui, rlgl, physac and GLFW</a></li>
<li class="toctree-l2"><a class="reference internal" href="#backends-desktop-sdl-drm-web">Backends: Desktop, SDL, DRM, Web</a></li>
<li class="toctree-l2"><a class="reference internal" href="#platforms-windows-mac-linux-raspberry-pi-web">Platforms: Windows, Mac, Linux, Raspberry Pi, Web</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#quickstart">Quickstart</a></li>
@ -57,9 +56,6 @@
<li class="toctree-l2"><a class="reference internal" href="#macos">MacOS</a></li>
<li class="toctree-l2"><a class="reference internal" href="#linux">Linux</a></li>
<li class="toctree-l2"><a class="reference internal" href="#raspberry-pi">Raspberry Pi</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#backends">Backends</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#dynamic-binding-version">Dynamic binding version</a></li>
<li class="toctree-l2"><a class="reference internal" href="#sdl-backend">SDL backend</a></li>
<li class="toctree-l2"><a class="reference internal" href="#drm-backend">DRM backend</a></li>
@ -68,7 +64,7 @@
</li>
<li class="toctree-l1"><a class="reference internal" href="#how-to-use">How to use</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#if-you-are-familiar-with-c-coding-and-the-raylib-c-library-and-you-want-to-use-an-exact-copy-of-the-c-api">If you are familiar with C coding and the Raylib C library and you want to use an exact copy of the C API</a></li>
<li class="toctree-l2"><a class="reference internal" href="#if-you-prefer-a-more-pythonistic-api">If you prefer a more Pythonistic API</a></li>
<li class="toctree-l2"><a class="reference internal" href="#if-you-prefer-a-more-pythonistic-api">If you prefer a more Pythonistic API</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#running-in-a-web-browser">Running in a web browser</a></li>
@ -120,29 +116,22 @@
</section>
<section id="backends-desktop-sdl-drm-web">
<h2>Backends: Desktop, SDL, DRM, Web<a class="headerlink" href="#backends-desktop-sdl-drm-web" title="Link to this heading"></a></h2>
</section>
<section id="platforms-windows-mac-linux-raspberry-pi-web">
<h2>Platforms: Windows, Mac, Linux, Raspberry Pi, Web<a class="headerlink" href="#platforms-windows-mac-linux-raspberry-pi-web" title="Link to this heading"></a></h2>
<p><img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/raylib" /></p>
<p>Chatroom: <a class="reference external" href="https://discord.gg/fKDwt85aX6">Discord</a></p>
<p>HELP WANTED: <a class="reference external" href="https://github.com/electronstudio/raylib-python-cffi/issues/155">writing examples</a></p>
<p>Features:</p>
<p>New CFFI API static bindings.</p>
<ul class="simple">
<li><p>CFFI API static bindings.</p></li>
<li><p>Automatically generated to be as close as possible to
original Raylib.</p></li>
<li><p>Faster, fewer bugs and easier to maintain than ctypes.</p></li>
<li><p>Commercial-friendly license.</p></li>
<li><p>Docstrings and auto-completion.</p></li>
<li><p>Type checking with Mypy</p></li>
</ul>
<p><a class="reference external" href="http://electronstudio.github.io/raylib-python-cffi">Full documentation</a></p>
</section>
</section>
<section id="quickstart">
<h1>Quickstart<a class="headerlink" href="#quickstart" title="Link to this heading"></a></h1>
<p><code class="docutils literal notranslate"><span class="pre">pip3</span> <span class="pre">install</span> <span class="pre">raylib==5.5.0.2</span> <span class="pre">--break-system-packages</span></code></p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">pyray</span><span class="w"> </span><span class="kn">import</span> <span class="o">*</span>
<p><code class="docutils literal notranslate"><span class="pre">pip3</span> <span class="pre">install</span> <span class="pre">raylib==5.0.0.4</span></code></p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">pyray</span> <span class="kn">import</span> <span class="o">*</span>
<span class="n">init_window</span><span class="p">(</span><span class="mi">800</span><span class="p">,</span> <span class="mi">450</span><span class="p">,</span> <span class="s2">&quot;Hello&quot;</span><span class="p">)</span>
<span class="k">while</span> <span class="ow">not</span> <span class="n">window_should_close</span><span class="p">():</span>
<span class="n">begin_drawing</span><span class="p">()</span>
@ -155,18 +144,13 @@ original Raylib.</p></li>
</section>
<section id="installation">
<h1>Installation<a class="headerlink" href="#installation" title="Link to this heading"></a></h1>
<p>If you are on a modern Linux you will probably want to create a venv:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>python3 -m venv venv
source venv/bin/activate
</pre></div>
</div>
<p>Then make sure you have the latest pip installed:</p>
<p>First make sure you have the latest pip installed:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>python3 -m pip install --upgrade pip
</pre></div>
</div>
<p>Then install</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>python3 -m pip install setuptools
python3 -m pip install raylib==5.5.0.2
python3 -m pip install raylib==5.0.0.4
</pre></div>
</div>
<p>On most platforms it should install a binary wheel. If yours isnt available then pip will attempt to build from
@ -187,7 +171,7 @@ using homebrew, apt, etc.</p>
<p>Older MacOS requires building from source but this is usually simple:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>brew install pkg-config
brew install raylib
python3 -m pip install raylib==5.5.0.2
python3 -m pip install raylib==5.0.0.4
</pre></div>
</div>
<p>(I do have binaries for arm64 MacOS 11, 12 and 13 but I have no way of testing they work, so post an issue
@ -202,11 +186,8 @@ so may not work on other boards.</p>
</section>
<section id="raspberry-pi">
<h2>Raspberry Pi<a class="headerlink" href="#raspberry-pi" title="Link to this heading"></a></h2>
<p><span class="xref myst">Using on Rasperry Pi</span></p>
<p><a class="reference internal" href="RPI.html"><span class="std std-doc">Using on Rasperry Pi</span></a></p>
</section>
</section>
<section id="backends">
<h1>Backends<a class="headerlink" href="#backends" title="Link to this heading"></a></h1>
<section id="dynamic-binding-version">
<h2>Dynamic binding version<a class="headerlink" href="#dynamic-binding-version" title="Link to this heading"></a></h2>
<p>There is now a separate dynamic version of this binding:</p>
@ -215,7 +196,6 @@ python3 -m pip install raylib_dynamic
</pre></div>
</div>
<p>It works on some systems where the static version doesnt, <a class="reference external" href="https://electronstudio.github.io/raylib-python-cffi/dynamic.html">but be sure to read these caveats before using it</a></p>
<p>You cant have multiple raylib packages installed at once.</p>
</section>
<section id="sdl-backend">
<h2>SDL backend<a class="headerlink" href="#sdl-backend" title="Link to this heading"></a></h2>
@ -237,7 +217,7 @@ python3 -m pip install raylib_drm
</section>
<section id="problems">
<h2>Problems?<a class="headerlink" href="#problems" title="Link to this heading"></a></h2>
<p>If it doesnt work, <span class="xref myst">try to build manually.</span>. If that works then <a class="reference external" href="https://github.com/electronstudio/raylib-python-cffi/issues">submit an issue</a>
<p>If it doesnt work, <a class="reference internal" href="BUILDING.html"><span class="std std-doc">try to build manually.</span></a>. If that works then <a class="reference external" href="https://github.com/electronstudio/raylib-python-cffi/issues">submit an issue</a>
to let us know what you did.</p>
<p>If you need help you can try asking on <a class="reference external" href="https://discord.gg/fKDwt85aX6">our discord</a>. There is also a large <a class="reference external" href="https://discord.gg/raylib">Raylib discord</a>
for issues that are not Python-specific.</p>
@ -246,70 +226,59 @@ for issues that are not Python-specific.</p>
</section>
<section id="how-to-use">
<h1>How to use<a class="headerlink" href="#how-to-use" title="Link to this heading"></a></h1>
<p>There are <em>two</em> modules in the raylib package, <code class="docutils literal notranslate"><span class="pre">raylib</span></code> and <code class="docutils literal notranslate"><span class="pre">pyray</span></code>. (There is no separate package for
pyray. Do <em>not</em> <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">pyray</span></code>). You can use either or both:</p>
<p>There are two modules in the raylib package, <code class="docutils literal notranslate"><span class="pre">raylib</span></code> and <code class="docutils literal notranslate"><span class="pre">pyray</span></code>. (There is no separate package for
pyray). You can use either or both:</p>
<section id="if-you-are-familiar-with-c-coding-and-the-raylib-c-library-and-you-want-to-use-an-exact-copy-of-the-c-api">
<h2>If you are familiar with C coding and the Raylib C library and you want to use an exact copy of the C API<a class="headerlink" href="#if-you-are-familiar-with-c-coding-and-the-raylib-c-library-and-you-want-to-use-an-exact-copy-of-the-c-api" title="Link to this heading"></a></h2>
<p>Use <a class="reference external" href="https://electronstudio.github.io/raylib-python-cffi/raylib.html">the raylib module</a>.</p>
</section>
<section id="if-you-prefer-a-more-pythonistic-api">
<h2>If you prefer a more Pythonistic API<a class="headerlink" href="#if-you-prefer-a-more-pythonistic-api" title="Link to this heading"></a></h2>
<h2>If you prefer a more Pythonistic API<a class="headerlink" href="#if-you-prefer-a-more-pythonistic-api" title="Link to this heading"></a></h2>
<p>Use <a class="reference external" href="https://electronstudio.github.io/raylib-python-cffi/pyray.html">the pyray module</a>.</p>
</section>
</section>
<section id="running-in-a-web-browser">
<h1>Running in a web browser<a class="headerlink" href="#running-in-a-web-browser" title="Link to this heading"></a></h1>
<p><a class="reference external" href="https://pypi.org/project/pygbag/">Pygbag</a> &gt;=0.8.7 supports running in a web browser. Usually the latest git version
is recommended.</p>
<p><a class="reference external" href="https://pypi.org/project/pygbag/">Pygbag</a> &gt;=0.8.7 supports running in a web browser.</p>
<p>Make a folder <code class="docutils literal notranslate"><span class="pre">my_project</span></code> with a file <code class="docutils literal notranslate"><span class="pre">main.py</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># /// script</span>
<span class="c1"># dependencies = [</span>
<span class="c1"># &quot;cffi&quot;,</span>
<span class="c1"># &quot;raylib&quot;</span>
<span class="c1"># ]</span>
<span class="c1"># ///</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">asyncio</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">platform</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">pyray</span><span class="w"> </span><span class="kn">import</span> <span class="o">*</span>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span># /// script
# dependencies = [
# &quot;cffi&quot;,
# &quot;raylib&quot;
# ]
# ///
import asyncio
import platform
from pyray import *
<span class="k">async</span> <span class="k">def</span><span class="w"> </span><span class="nf">main</span><span class="p">():</span> <span class="c1"># You MUST have an async main function</span>
<span class="n">init_window</span><span class="p">(</span><span class="mi">500</span><span class="p">,</span> <span class="mi">500</span><span class="p">,</span> <span class="s2">&quot;Hello&quot;</span><span class="p">)</span>
<span class="n">platform</span><span class="o">.</span><span class="n">window</span><span class="o">.</span><span class="n">window_resize</span><span class="p">()</span> <span class="c1"># You MAY want to add this line</span>
<span class="k">while</span> <span class="ow">not</span> <span class="n">window_should_close</span><span class="p">():</span>
<span class="n">begin_drawing</span><span class="p">()</span>
<span class="n">clear_background</span><span class="p">(</span><span class="n">WHITE</span><span class="p">)</span>
<span class="n">draw_text</span><span class="p">(</span><span class="s2">&quot;Hello world&quot;</span><span class="p">,</span> <span class="mi">190</span><span class="p">,</span> <span class="mi">200</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="n">VIOLET</span><span class="p">)</span>
<span class="n">end_drawing</span><span class="p">()</span>
<span class="k">await</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="c1"># You MUST call this in your main loop</span>
<span class="n">close_window</span><span class="p">()</span>
async def main(): # You must have an async main function
init_window(500, 500, &quot;Hello&quot;)
platform.window.window_resize() # You must add this line
while not window_should_close():
begin_drawing()
clear_background(WHITE)
draw_text(&quot;Hello world&quot;, 190, 200, 20, VIOLET)
end_drawing()
await asyncio.sleep(0) # You must call this in your main loop
close_window()
<span class="n">asyncio</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">main</span><span class="p">())</span>
asyncio.run(main())
</pre></div>
</div>
<p>Then to create the web files and launch a web server:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>python3.12 -m pip install --user --upgrade pygbag
python3.12 -m pygbag --PYBUILD 3.12 --ume_block 0 --template noctx.tmpl --git my_project
python3.12 -m pygbag --PYBUILD 3.12 --ume_block 0 --template noctx.tmpl my_project
</pre></div>
</div>
<p>Point your browser to http://localhost:8000</p>
<p>Some features may not work, so you can disable them like this:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="n">platform</span><span class="o">.</span><span class="n">system</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">&quot;Emscripten&quot;</span><span class="p">:</span> <span class="c1"># audio may not work on current version of emscripten</span>
<span class="n">init_audio_device</span><span class="p">()</span>
</pre></div>
</div>
<p>This is all done by Pygbag rather than by me, so you should probably contact them with any issues.
Carefully read all their <a class="reference external" href="https://pygame-web.github.io/">documentation</a>.</p>
<p>It does work for most of <a class="reference external" href="https://electronstudio.github.io/raylib-python-cffi-pygbag-examples/">these examples</a></p>
</section>
<section id="app-showcase">
<h1>App showcase<a class="headerlink" href="#app-showcase" title="Link to this heading"></a></h1>
<p><a class="reference external" href="https://github.com/Emtyloc/tempest-raylib">Tempest-raylib</a></p>
<p><a class="reference external" href="https://github.com/bilbofroggins/KarabinerKeyboard">KarabinerKeyboard</a></p>
<p><a class="reference external" href="https://github.com/Yonokid/PyTaiko">PyTaiko</a></p>
<p><a class="reference external" href="https://github.com/StanislavPetrovV/DOOM-Clone">DOOM-Clone</a></p>
<p><a class="reference external" href="https://github.com/pkulev/tanki">Tanki</a></p>
<p><a class="reference external" href="https://pebaz.itch.io/alloy-bloxel-editor">Alloy Bloxel Editor</a></p>
<p><a class="reference external" href="https://github.com/Miou-zora/Eidolon">Eidolon</a></p>
<p>Add your app here!</p>
</section>
<section id="rlzero">

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Raspberry Pi &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
@ -47,7 +47,6 @@
<li class="toctree-l1"><a class="reference internal" href="README.html">Python Bindings for Raylib 5.5</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#quickstart">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#installation">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#backends">Backends</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#how-to-use">How to use</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#running-in-a-web-browser">Running in a web browser</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#app-showcase">App showcase</a></li>
@ -125,7 +124,7 @@ For full instructions on this, see <a class="reference external" href="https://g
</div>
<p>Then have pip compile and install the wheel:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">python3</span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="o">--</span><span class="k">break</span><span class="o">-</span><span class="n">system</span><span class="o">-</span><span class="n">packages</span> <span class="n">setuptools</span>
<span class="n">python3</span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="o">--</span><span class="n">no</span><span class="o">-</span><span class="n">cache</span><span class="o">-</span><span class="nb">dir</span> <span class="o">--</span><span class="n">no</span><span class="o">-</span><span class="n">binary</span> <span class="n">raylib</span> <span class="o">--</span><span class="n">upgrade</span> <span class="o">--</span><span class="n">force</span><span class="o">-</span><span class="n">reinstall</span> <span class="o">--</span><span class="k">break</span><span class="o">-</span><span class="n">system</span><span class="o">-</span><span class="n">packages</span> <span class="n">raylib</span><span class="o">==</span><span class="mf">5.5.0.0</span>
<span class="n">python3</span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="o">--</span><span class="n">no</span><span class="o">-</span><span class="n">cache</span><span class="o">-</span><span class="nb">dir</span> <span class="o">--</span><span class="n">no</span><span class="o">-</span><span class="n">binary</span> <span class="n">raylib</span> <span class="o">--</span><span class="n">upgrade</span> <span class="o">--</span><span class="n">force</span><span class="o">-</span><span class="n">reinstall</span> <span class="o">--</span><span class="k">break</span><span class="o">-</span><span class="n">system</span><span class="o">-</span><span class="n">packages</span> <span class="n">raylib</span><span class="o">==</span><span class="mf">5.0.0.4</span>
</pre></div>
</div>
</section>
@ -158,7 +157,7 @@ For full instructions on this, see <a class="reference external" href="https://g
</div>
<p>Then have pip compile and install the wheel:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">python3</span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="o">--</span><span class="k">break</span><span class="o">-</span><span class="n">system</span><span class="o">-</span><span class="n">packages</span> <span class="n">setuptools</span>
<span class="n">python3</span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="o">--</span><span class="n">no</span><span class="o">-</span><span class="n">cache</span><span class="o">-</span><span class="nb">dir</span> <span class="o">--</span><span class="n">no</span><span class="o">-</span><span class="n">binary</span> <span class="n">raylib</span> <span class="o">--</span><span class="n">upgrade</span> <span class="o">--</span><span class="n">force</span><span class="o">-</span><span class="n">reinstall</span> <span class="o">--</span><span class="k">break</span><span class="o">-</span><span class="n">system</span><span class="o">-</span><span class="n">packages</span> <span class="n">raylib</span><span class="o">==</span><span class="mf">5.5.0.0</span>
<span class="n">python3</span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="o">--</span><span class="n">no</span><span class="o">-</span><span class="n">cache</span><span class="o">-</span><span class="nb">dir</span> <span class="o">--</span><span class="n">no</span><span class="o">-</span><span class="n">binary</span> <span class="n">raylib</span> <span class="o">--</span><span class="n">upgrade</span> <span class="o">--</span><span class="n">force</span><span class="o">-</span><span class="n">reinstall</span> <span class="o">--</span><span class="k">break</span><span class="o">-</span><span class="n">system</span><span class="o">-</span><span class="n">packages</span> <span class="n">raylib</span><span class="o">==</span><span class="mf">5.0.0.4</span>
</pre></div>
</div>
<div class="admonition attention">

View file

@ -1,30 +1,22 @@
# Python Bindings for Raylib 5.5
## Libraries: raymath, raygui, rlgl, physac and GLFW
## Backends: Desktop, SDL, DRM, Web
## Platforms: Windows, Mac, Linux, Raspberry Pi, Web
![PyPI - Downloads](https://img.shields.io/pypi/dm/raylib)
Chatroom: [Discord](https://discord.gg/fKDwt85aX6)
HELP WANTED: [writing examples](https://github.com/electronstudio/raylib-python-cffi/issues/155)
Features:
* CFFI API static bindings.
New CFFI API static bindings.
* Automatically generated to be as close as possible to
original Raylib.
* Faster, fewer bugs and easier to maintain than ctypes.
* Commercial-friendly license.
* Docstrings and auto-completion.
* Type checking with Mypy
[Full documentation](http://electronstudio.github.io/raylib-python-cffi)
# Quickstart
`pip3 install raylib==5.5.0.2 --break-system-packages`
`pip3 install raylib==5.0.0.4`
```python
from pyray import *
init_window(800, 450, "Hello")
@ -38,19 +30,14 @@ close_window()
# Installation
If you are on a modern Linux you will probably want to create a venv:
python3 -m venv venv
source venv/bin/activate
Then make sure you have the latest pip installed:
First make sure you have the latest pip installed:
python3 -m pip install --upgrade pip
Then install
python3 -m pip install setuptools
python3 -m pip install raylib==5.5.0.2
python3 -m pip install raylib==5.0.0.4
On most platforms it should install a binary wheel. If yours isn't available then pip will attempt to build from
source, in which case you will need to have Raylib development libs installed, e.g.
@ -72,7 +59,7 @@ Older MacOS requires building from source but this is usually simple:
brew install pkg-config
brew install raylib
python3 -m pip install raylib==5.5.0.2
python3 -m pip install raylib==5.0.0.4
(I do have binaries for arm64 MacOS 11, 12 and 13 but I have no way of testing they work, so post an issue
if you want to test them.)
@ -89,8 +76,6 @@ so may not work on other boards.
[Using on Rasperry Pi](RPI.rst)
# Backends
## Dynamic binding version
There is now a separate dynamic version of this binding:
@ -100,8 +85,6 @@ There is now a separate dynamic version of this binding:
It works on some systems where the static version doesn't, [but be sure to read these caveats before using it](https://electronstudio.github.io/raylib-python-cffi/dynamic.html)
You can't have multiple raylib packages installed at once.
## SDL backend
This is not well tested but has better support for controllers:
@ -133,63 +116,53 @@ If it still doesn't work, [submit an issue](https://github.com/electronstudio/ra
# How to use
There are *two* modules in the raylib package, `raylib` and `pyray`. (There is no separate package for
pyray. Do *not* `pip install pyray`). You can use either or both:
There are two modules in the raylib package, `raylib` and `pyray`. (There is no separate package for
pyray). You can use either or both:
### If you are familiar with C coding and the Raylib C library and you want to use an exact copy of the C API
Use [the raylib module](https://electronstudio.github.io/raylib-python-cffi/raylib.html).
### If you prefer a more Pythonistic API
### If you prefer a more Pythonistic API
Use [the pyray module](https://electronstudio.github.io/raylib-python-cffi/pyray.html).
# Running in a web browser
[Pygbag](https://pypi.org/project/pygbag/) >=0.8.7 supports running in a web browser. Usually the latest git version
is recommended.
[Pygbag](https://pypi.org/project/pygbag/) >=0.8.7 supports running in a web browser.
Make a folder `my_project` with a file `main.py`:
```python
# /// script
# dependencies = [
# "cffi",
# "raylib"
# ]
# ///
import asyncio
import platform
from pyray import *
# /// script
# dependencies = [
# "cffi",
# "raylib"
# ]
# ///
import asyncio
import platform
from pyray import *
async def main(): # You MUST have an async main function
init_window(500, 500, "Hello")
platform.window.window_resize() # You MAY want to add this line
while not window_should_close():
begin_drawing()
clear_background(WHITE)
draw_text("Hello world", 190, 200, 20, VIOLET)
end_drawing()
await asyncio.sleep(0) # You MUST call this in your main loop
close_window()
async def main(): # You must have an async main function
init_window(500, 500, "Hello")
platform.window.window_resize() # You must add this line
while not window_should_close():
begin_drawing()
clear_background(WHITE)
draw_text("Hello world", 190, 200, 20, VIOLET)
end_drawing()
await asyncio.sleep(0) # You must call this in your main loop
close_window()
asyncio.run(main())
```
asyncio.run(main())
Then to create the web files and launch a web server:
python3.12 -m pip install --user --upgrade pygbag
python3.12 -m pygbag --PYBUILD 3.12 --ume_block 0 --template noctx.tmpl --git my_project
python3.12 -m pygbag --PYBUILD 3.12 --ume_block 0 --template noctx.tmpl my_project
Point your browser to http://localhost:8000
Some features may not work, so you can disable them like this:
```python
if platform.system() != "Emscripten": # audio may not work on current version of emscripten
init_audio_device()
```
This is all done by Pygbag rather than by me, so you should probably contact them with any issues.
Carefully read all their [documentation](https://pygame-web.github.io/).
@ -197,20 +170,10 @@ It does work for most of [these examples](https://electronstudio.github.io/rayli
# App showcase
[Tempest-raylib](https://github.com/Emtyloc/tempest-raylib)
[KarabinerKeyboard](https://github.com/bilbofroggins/KarabinerKeyboard)
[PyTaiko](https://github.com/Yonokid/PyTaiko)
[DOOM-Clone](https://github.com/StanislavPetrovV/DOOM-Clone)
[Tanki](https://github.com/pkulev/tanki)
[Alloy Bloxel Editor](https://pebaz.itch.io/alloy-bloxel-editor)
[Eidolon](https://github.com/Miou-zora/Eidolon)
Add your app here!
# RLZero

View file

@ -42,7 +42,7 @@ Then have pip compile and install the wheel:
::
python3 -m pip install --break-system-packages setuptools
python3 -m pip install --no-cache-dir --no-binary raylib --upgrade --force-reinstall --break-system-packages raylib==5.5.0.0
python3 -m pip install --no-cache-dir --no-binary raylib --upgrade --force-reinstall --break-system-packages raylib==5.0.0.4
Option 3: Compile Raylib from source DRM mode
---------------------------------------------
@ -85,7 +85,7 @@ Then have pip compile and install the wheel:
::
python3 -m pip install --break-system-packages setuptools
python3 -m pip install --no-cache-dir --no-binary raylib --upgrade --force-reinstall --break-system-packages raylib==5.5.0.0
python3 -m pip install --no-cache-dir --no-binary raylib --upgrade --force-reinstall --break-system-packages raylib==5.0.0.4

View file

@ -741,6 +741,14 @@ abbr, acronym {
cursor: help;
}
.translated {
background-color: rgba(207, 255, 207, 0.2)
}
.untranslated {
background-color: rgba(255, 207, 207, 0.2)
}
/* -- code displays --------------------------------------------------------- */
pre {

View file

@ -1,6 +1,6 @@
const themeFlyoutDisplay = "hidden";
const themeVersionSelector = true;
const themeLanguageSelector = true;
const themeVersionSelector = "True";
const themeLanguageSelector = "True";
if (themeFlyoutDisplay === "attached") {
function renderLanguages(config) {
@ -8,14 +8,10 @@ if (themeFlyoutDisplay === "attached") {
return "";
}
// Insert the current language to the options on the selector
let languages = config.projects.translations.concat(config.projects.current);
languages = languages.sort((a, b) => a.language.name.localeCompare(b.language.name));
const languagesHTML = `
<dl>
<dt>Languages</dt>
${languages
${config.projects.translations
.map(
(translation) => `
<dd ${translation.slug == config.projects.current.slug ? 'class="rtd-current-item"' : ""}>

View file

@ -6,26 +6,26 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
.highlight .hll { background-color: #ffffcc }
.highlight { background: #eeffcc; }
.highlight .c { color: #408090; font-style: italic } /* Comment */
.highlight .err { border: 1px solid #F00 } /* Error */
.highlight .err { border: 1px solid #FF0000 } /* Error */
.highlight .k { color: #007020; font-weight: bold } /* Keyword */
.highlight .o { color: #666 } /* Operator */
.highlight .o { color: #666666 } /* Operator */
.highlight .ch { color: #408090; font-style: italic } /* Comment.Hashbang */
.highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #007020 } /* Comment.Preproc */
.highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile */
.highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */
.highlight .cs { color: #408090; background-color: #FFF0F0 } /* Comment.Special */
.highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #F00 } /* Generic.Error */
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #00A000 } /* Generic.Inserted */
.highlight .go { color: #333 } /* Generic.Output */
.highlight .gp { color: #C65D09; font-weight: bold } /* Generic.Prompt */
.highlight .go { color: #333333 } /* Generic.Output */
.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #04D } /* Generic.Traceback */
.highlight .gt { color: #0044DD } /* Generic.Traceback */
.highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
@ -33,43 +33,43 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
.highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #902000 } /* Keyword.Type */
.highlight .m { color: #208050 } /* Literal.Number */
.highlight .s { color: #4070A0 } /* Literal.String */
.highlight .na { color: #4070A0 } /* Name.Attribute */
.highlight .s { color: #4070a0 } /* Literal.String */
.highlight .na { color: #4070a0 } /* Name.Attribute */
.highlight .nb { color: #007020 } /* Name.Builtin */
.highlight .nc { color: #0E84B5; font-weight: bold } /* Name.Class */
.highlight .no { color: #60ADD5 } /* Name.Constant */
.highlight .nd { color: #555; font-weight: bold } /* Name.Decorator */
.highlight .ni { color: #D55537; font-weight: bold } /* Name.Entity */
.highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
.highlight .no { color: #60add5 } /* Name.Constant */
.highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */
.highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */
.highlight .ne { color: #007020 } /* Name.Exception */
.highlight .nf { color: #06287E } /* Name.Function */
.highlight .nf { color: #06287e } /* Name.Function */
.highlight .nl { color: #002070; font-weight: bold } /* Name.Label */
.highlight .nn { color: #0E84B5; font-weight: bold } /* Name.Namespace */
.highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
.highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #BB60D5 } /* Name.Variable */
.highlight .nv { color: #bb60d5 } /* Name.Variable */
.highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */
.highlight .w { color: #BBB } /* Text.Whitespace */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #208050 } /* Literal.Number.Bin */
.highlight .mf { color: #208050 } /* Literal.Number.Float */
.highlight .mh { color: #208050 } /* Literal.Number.Hex */
.highlight .mi { color: #208050 } /* Literal.Number.Integer */
.highlight .mo { color: #208050 } /* Literal.Number.Oct */
.highlight .sa { color: #4070A0 } /* Literal.String.Affix */
.highlight .sb { color: #4070A0 } /* Literal.String.Backtick */
.highlight .sc { color: #4070A0 } /* Literal.String.Char */
.highlight .dl { color: #4070A0 } /* Literal.String.Delimiter */
.highlight .sd { color: #4070A0; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #4070A0 } /* Literal.String.Double */
.highlight .se { color: #4070A0; font-weight: bold } /* Literal.String.Escape */
.highlight .sh { color: #4070A0 } /* Literal.String.Heredoc */
.highlight .si { color: #70A0D0; font-style: italic } /* Literal.String.Interpol */
.highlight .sx { color: #C65D09 } /* Literal.String.Other */
.highlight .sa { color: #4070a0 } /* Literal.String.Affix */
.highlight .sb { color: #4070a0 } /* Literal.String.Backtick */
.highlight .sc { color: #4070a0 } /* Literal.String.Char */
.highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */
.highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #4070a0 } /* Literal.String.Double */
.highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
.highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */
.highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
.highlight .sx { color: #c65d09 } /* Literal.String.Other */
.highlight .sr { color: #235388 } /* Literal.String.Regex */
.highlight .s1 { color: #4070A0 } /* Literal.String.Single */
.highlight .s1 { color: #4070a0 } /* Literal.String.Single */
.highlight .ss { color: #517918 } /* Literal.String.Symbol */
.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #06287E } /* Name.Function.Magic */
.highlight .vc { color: #BB60D5 } /* Name.Variable.Class */
.highlight .vg { color: #BB60D5 } /* Name.Variable.Global */
.highlight .vi { color: #BB60D5 } /* Name.Variable.Instance */
.highlight .vm { color: #BB60D5 } /* Name.Variable.Magic */
.highlight .fm { color: #06287e } /* Name.Function.Magic */
.highlight .vc { color: #bb60d5 } /* Name.Variable.Class */
.highlight .vg { color: #bb60d5 } /* Name.Variable.Global */
.highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */
.highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */
.highlight .il { color: #208050 } /* Literal.Number.Integer.Long */

View file

@ -513,11 +513,9 @@ const Search = {
// perform the search on the required terms
searchTerms.forEach((word) => {
const files = [];
// find documents, if any, containing the query word in their text/title term indices
// use Object.hasOwnProperty to avoid mismatching against prototype properties
const arr = [
{ files: terms.hasOwnProperty(word) ? terms[word] : undefined, score: Scorer.term },
{ files: titleTerms.hasOwnProperty(word) ? titleTerms[word] : undefined, score: Scorer.title },
{ files: terms[word], score: Scorer.term },
{ files: titleTerms[word], score: Scorer.title },
];
// add support for partial matches
if (word.length > 2) {
@ -549,9 +547,8 @@ const Search = {
// set score for the word in each file
recordFiles.forEach((file) => {
if (!scoreMap.has(file)) scoreMap.set(file, new Map());
const fileScores = scoreMap.get(file);
fileScores.set(word, record.score);
if (!scoreMap.has(file)) scoreMap.set(file, {});
scoreMap.get(file)[word] = record.score;
});
});
@ -590,7 +587,7 @@ const Search = {
break;
// select one (max) score for the file.
const score = Math.max(...wordList.map((w) => scoreMap.get(file).get(w)));
const score = Math.max(...wordList.map((w) => scoreMap.get(file)[w]));
// add result to the result list
results.push([
docNames[file],

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dynamic Bindings &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
@ -48,7 +48,6 @@
<li class="toctree-l1"><a class="reference internal" href="README.html">Python Bindings for Raylib 5.5</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#quickstart">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#installation">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#backends">Backends</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#how-to-use">How to use</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#running-in-a-web-browser">Running in a web browser</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#app-showcase">App showcase</a></li>
@ -104,11 +103,11 @@ Therefore I personally recommend the static ones.
But the dynamic bindings have the advantage that you dont need to compile anything to install. You just need a Raylib DLL.</p>
</div>
<p>The API is exactly the same as the static one documented here. (Therefore you cant have both modules installed at once.) The only difference is you cant do:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">raylib</span><span class="w"> </span><span class="kn">import</span> <span class="o">*</span>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">raylib</span> <span class="kn">import</span> <span class="o">*</span>
</pre></div>
</div>
<p>Instead you have to do:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">raylib</span><span class="w"> </span><span class="kn">import</span> <span class="n">rl</span>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">raylib</span> <span class="kn">import</span> <span class="n">rl</span>
</pre></div>
</div>
<p>Then you access the functions with <code class="docutils literal notranslate"><span class="pre">rl.</span></code> prefix.</p>

View file

@ -6,7 +6,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Index &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
@ -45,7 +45,6 @@
<li class="toctree-l1"><a class="reference internal" href="README.html">Python Bindings for Raylib 5.5</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#quickstart">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#installation">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#backends">Backends</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#how-to-use">How to use</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#running-in-a-web-browser">Running in a web browser</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#app-showcase">App showcase</a></li>

View file

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Raylib Python &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
@ -47,7 +47,6 @@
<li class="toctree-l1"><a class="reference internal" href="README.html">Python Bindings for Raylib 5.5</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#quickstart">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#installation">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#backends">Backends</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#how-to-use">How to use</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#running-in-a-web-browser">Running in a web browser</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#app-showcase">App showcase</a></li>
@ -96,7 +95,6 @@
<li class="toctree-l1"><a class="reference internal" href="README.html">Python Bindings for Raylib 5.5</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#quickstart">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#installation">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#backends">Backends</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#how-to-use">How to use</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#running-in-a-web-browser">Running in a web browser</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#app-showcase">App showcase</a></li>

View file

@ -6,7 +6,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Python Module Index &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
@ -52,7 +52,6 @@
<li class="toctree-l1"><a class="reference internal" href="README.html">Python Bindings for Raylib 5.5</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#quickstart">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#installation">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#backends">Backends</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#how-to-use">How to use</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#running-in-a-web-browser">Running in a web browser</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#app-showcase">App showcase</a></li>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -6,7 +6,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Search &mdash; Raylib Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
@ -48,7 +48,6 @@
<li class="toctree-l1"><a class="reference internal" href="README.html">Python Bindings for Raylib 5.5</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#quickstart">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#installation">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#backends">Backends</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#how-to-use">How to use</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#running-in-a-web-browser">Running in a web browser</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#app-showcase">App showcase</a></li>

File diff suppressed because one or more lines are too long

View file

@ -22,10 +22,9 @@ import itertools
import os
import pathlib
import platform
import logging
from .version import __version__
logger = logging.getLogger(__name__)
MODULE = pathlib.Path(__file__).parent
def raylib_library_path():
@ -55,9 +54,9 @@ ffi.cdef(open(MODULE / "raylib_modified.h").read().replace('RLAPI ', ''))
try:
raylib_fname = raylib_library_path()
rl = ffi.dlopen(raylib_fname)
logger.warning('LOADED DYNAMICALLY SHARED LIB {} {}'.format(__version__, raylib_fname))
print('LOADED DYNAMICALLY SHARED LIB {} {}'.format(__version__, raylib_fname))
except Exception as e:
logger.exception(e)
print(e)
LIGHTGRAY =( 200, 200, 200, 255 )
GRAY =( 130, 130, 130, 255 )

File diff suppressed because it is too large Load diff

View file

@ -186,10 +186,12 @@ RAYGUI_TEXTFORMAT_MAX_SIZE: int = 256
PHYSAC_MAX_BODIES: int = 64
PHYSAC_MAX_MANIFOLDS: int = 4096
PHYSAC_MAX_VERTICES: int = 24
PHYSAC_CIRCLE_VERTICES: int = 24
PHYSAC_COLLISION_ITERATIONS: int = 20
PHYSAC_DEFAULT_CIRCLE_VERTICES: int = 24
PHYSAC_COLLISION_ITERATIONS: int = 100
PHYSAC_PENETRATION_ALLOWANCE: float = 0.05
PHYSAC_PENETRATION_CORRECTION: float = 0.4
PHYSAC_PI: float = 3.141592653589793
PHYSAC_DEG2RAD = PHYSAC_PI / 180.0
PHYSAC_FLT_MAX: float = 3.402823466e+38
PHYSAC_EPSILON: float = 1e-06
GLFW_VERSION_MAJOR: int = 3

View file

@ -1,7 +1,6 @@
from enum import IntEnum
class ConfigFlags(IntEnum):
"""System/Window config flags."""
FLAG_VSYNC_HINT = 64
FLAG_FULLSCREEN_MODE = 2
FLAG_WINDOW_RESIZABLE = 4
@ -20,7 +19,6 @@ class ConfigFlags(IntEnum):
FLAG_INTERLACED_HINT = 65536
class TraceLogLevel(IntEnum):
"""Trace log level."""
LOG_ALL = 0
LOG_TRACE = 1
LOG_DEBUG = 2
@ -31,7 +29,6 @@ class TraceLogLevel(IntEnum):
LOG_NONE = 7
class KeyboardKey(IntEnum):
"""Keyboard keys (US keyboard layout)."""
KEY_NULL = 0
KEY_APOSTROPHE = 39
KEY_COMMA = 44
@ -144,7 +141,6 @@ class KeyboardKey(IntEnum):
KEY_VOLUME_DOWN = 25
class MouseButton(IntEnum):
"""Mouse buttons."""
MOUSE_BUTTON_LEFT = 0
MOUSE_BUTTON_RIGHT = 1
MOUSE_BUTTON_MIDDLE = 2
@ -154,7 +150,6 @@ class MouseButton(IntEnum):
MOUSE_BUTTON_BACK = 6
class MouseCursor(IntEnum):
"""Mouse cursor."""
MOUSE_CURSOR_DEFAULT = 0
MOUSE_CURSOR_ARROW = 1
MOUSE_CURSOR_IBEAM = 2
@ -168,7 +163,6 @@ class MouseCursor(IntEnum):
MOUSE_CURSOR_NOT_ALLOWED = 10
class GamepadButton(IntEnum):
"""Gamepad buttons."""
GAMEPAD_BUTTON_UNKNOWN = 0
GAMEPAD_BUTTON_LEFT_FACE_UP = 1
GAMEPAD_BUTTON_LEFT_FACE_RIGHT = 2
@ -189,7 +183,6 @@ class GamepadButton(IntEnum):
GAMEPAD_BUTTON_RIGHT_THUMB = 17
class GamepadAxis(IntEnum):
"""Gamepad axis."""
GAMEPAD_AXIS_LEFT_X = 0
GAMEPAD_AXIS_LEFT_Y = 1
GAMEPAD_AXIS_RIGHT_X = 2
@ -198,7 +191,6 @@ class GamepadAxis(IntEnum):
GAMEPAD_AXIS_RIGHT_TRIGGER = 5
class MaterialMapIndex(IntEnum):
"""Material map index."""
MATERIAL_MAP_ALBEDO = 0
MATERIAL_MAP_METALNESS = 1
MATERIAL_MAP_NORMAL = 2
@ -212,7 +204,6 @@ class MaterialMapIndex(IntEnum):
MATERIAL_MAP_BRDF = 10
class ShaderLocationIndex(IntEnum):
"""Shader location index."""
SHADER_LOC_VERTEX_POSITION = 0
SHADER_LOC_VERTEX_TEXCOORD01 = 1
SHADER_LOC_VERTEX_TEXCOORD02 = 2
@ -244,7 +235,6 @@ class ShaderLocationIndex(IntEnum):
SHADER_LOC_BONE_MATRICES = 28
class ShaderUniformDataType(IntEnum):
"""Shader uniform data type."""
SHADER_UNIFORM_FLOAT = 0
SHADER_UNIFORM_VEC2 = 1
SHADER_UNIFORM_VEC3 = 2
@ -256,14 +246,12 @@ class ShaderUniformDataType(IntEnum):
SHADER_UNIFORM_SAMPLER2D = 8
class ShaderAttributeDataType(IntEnum):
"""Shader attribute data types."""
SHADER_ATTRIB_FLOAT = 0
SHADER_ATTRIB_VEC2 = 1
SHADER_ATTRIB_VEC3 = 2
SHADER_ATTRIB_VEC4 = 3
class PixelFormat(IntEnum):
"""Pixel formats."""
PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1
PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA = 2
PIXELFORMAT_UNCOMPRESSED_R5G6B5 = 3
@ -290,7 +278,6 @@ class PixelFormat(IntEnum):
PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA = 24
class TextureFilter(IntEnum):
"""Texture parameters: filter mode."""
TEXTURE_FILTER_POINT = 0
TEXTURE_FILTER_BILINEAR = 1
TEXTURE_FILTER_TRILINEAR = 2
@ -299,14 +286,12 @@ class TextureFilter(IntEnum):
TEXTURE_FILTER_ANISOTROPIC_16X = 5
class TextureWrap(IntEnum):
"""Texture parameters: wrap mode."""
TEXTURE_WRAP_REPEAT = 0
TEXTURE_WRAP_CLAMP = 1
TEXTURE_WRAP_MIRROR_REPEAT = 2
TEXTURE_WRAP_MIRROR_CLAMP = 3
class CubemapLayout(IntEnum):
"""Cubemap layouts."""
CUBEMAP_LAYOUT_AUTO_DETECT = 0
CUBEMAP_LAYOUT_LINE_VERTICAL = 1
CUBEMAP_LAYOUT_LINE_HORIZONTAL = 2
@ -314,13 +299,11 @@ class CubemapLayout(IntEnum):
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE = 4
class FontType(IntEnum):
"""Font type, defines generation method."""
FONT_DEFAULT = 0
FONT_BITMAP = 1
FONT_SDF = 2
class BlendMode(IntEnum):
"""Color blending modes (pre-defined)."""
BLEND_ALPHA = 0
BLEND_ADDITIVE = 1
BLEND_MULTIPLIED = 2
@ -331,7 +314,6 @@ class BlendMode(IntEnum):
BLEND_CUSTOM_SEPARATE = 7
class Gesture(IntEnum):
"""Gesture."""
GESTURE_NONE = 0
GESTURE_TAP = 1
GESTURE_DOUBLETAP = 2
@ -345,7 +327,6 @@ class Gesture(IntEnum):
GESTURE_PINCH_OUT = 512
class CameraMode(IntEnum):
"""Camera system modes."""
CAMERA_CUSTOM = 0
CAMERA_FREE = 1
CAMERA_ORBITAL = 2
@ -353,43 +334,36 @@ class CameraMode(IntEnum):
CAMERA_THIRD_PERSON = 4
class CameraProjection(IntEnum):
"""Camera projection."""
CAMERA_PERSPECTIVE = 0
CAMERA_ORTHOGRAPHIC = 1
class NPatchLayout(IntEnum):
"""N-patch layout."""
NPATCH_NINE_PATCH = 0
NPATCH_THREE_PATCH_VERTICAL = 1
NPATCH_THREE_PATCH_HORIZONTAL = 2
class GuiState(IntEnum):
"""Gui control state."""
STATE_NORMAL = 0
STATE_FOCUSED = 1
STATE_PRESSED = 2
STATE_DISABLED = 3
class GuiTextAlignment(IntEnum):
"""Gui control text alignment."""
TEXT_ALIGN_LEFT = 0
TEXT_ALIGN_CENTER = 1
TEXT_ALIGN_RIGHT = 2
class GuiTextAlignmentVertical(IntEnum):
"""Gui control text alignment vertical."""
TEXT_ALIGN_TOP = 0
TEXT_ALIGN_MIDDLE = 1
TEXT_ALIGN_BOTTOM = 2
class GuiTextWrapMode(IntEnum):
"""Gui control text wrap mode."""
TEXT_WRAP_NONE = 0
TEXT_WRAP_CHAR = 1
TEXT_WRAP_WORD = 2
class GuiControl(IntEnum):
"""Gui controls."""
DEFAULT = 0
LABEL = 1
BUTTON = 2
@ -408,7 +382,6 @@ class GuiControl(IntEnum):
STATUSBAR = 15
class GuiControlProperty(IntEnum):
"""Gui base properties for every control."""
BORDER_COLOR_NORMAL = 0
BASE_COLOR_NORMAL = 1
TEXT_COLOR_NORMAL = 2
@ -426,7 +399,6 @@ class GuiControlProperty(IntEnum):
TEXT_ALIGNMENT = 14
class GuiDefaultProperty(IntEnum):
"""DEFAULT extended properties."""
TEXT_SIZE = 16
TEXT_SPACING = 17
LINE_COLOR = 18
@ -436,20 +408,16 @@ class GuiDefaultProperty(IntEnum):
TEXT_WRAP_MODE = 22
class GuiToggleProperty(IntEnum):
"""Toggle/ToggleGroup."""
GROUP_PADDING = 16
class GuiSliderProperty(IntEnum):
"""Slider/SliderBar."""
SLIDER_WIDTH = 16
SLIDER_PADDING = 17
class GuiProgressBarProperty(IntEnum):
"""ProgressBar."""
PROGRESS_PADDING = 16
class GuiScrollBarProperty(IntEnum):
"""ScrollBar."""
ARROWS_SIZE = 16
ARROWS_VISIBLE = 17
SCROLL_SLIDER_PADDING = 18
@ -458,32 +426,26 @@ class GuiScrollBarProperty(IntEnum):
SCROLL_SPEED = 21
class GuiCheckBoxProperty(IntEnum):
"""CheckBox."""
CHECK_PADDING = 16
class GuiComboBoxProperty(IntEnum):
"""ComboBox."""
COMBO_BUTTON_WIDTH = 16
COMBO_BUTTON_SPACING = 17
class GuiDropdownBoxProperty(IntEnum):
"""DropdownBox."""
ARROW_PADDING = 16
DROPDOWN_ITEMS_SPACING = 17
DROPDOWN_ARROW_HIDDEN = 18
DROPDOWN_ROLL_UP = 19
class GuiTextBoxProperty(IntEnum):
"""TextBox/TextBoxMulti/ValueBox/Spinner."""
TEXT_READONLY = 16
class GuiSpinnerProperty(IntEnum):
"""Spinner."""
SPIN_BUTTON_WIDTH = 16
SPIN_BUTTON_SPACING = 17
class GuiListViewProperty(IntEnum):
"""ListView."""
LIST_ITEMS_HEIGHT = 16
LIST_ITEMS_SPACING = 17
SCROLLBAR_WIDTH = 18
@ -491,7 +453,6 @@ class GuiListViewProperty(IntEnum):
LIST_ITEMS_BORDER_WIDTH = 20
class GuiColorPickerProperty(IntEnum):
"""ColorPicker."""
COLOR_SELECTOR_SIZE = 16
HUEBAR_WIDTH = 17
HUEBAR_PADDING = 18
@ -499,7 +460,6 @@ class GuiColorPickerProperty(IntEnum):
HUEBAR_SELECTOR_OVERFLOW = 20
class GuiIconName(IntEnum):
"""."""
ICON_NONE = 0
ICON_FOLDER_FILE_OPEN = 1
ICON_FILE_SAVE_CLASSIC = 2

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1 +0,0 @@
../../raylib/raylib.h.modified

File diff suppressed because it is too large Load diff

View file

@ -1,101 +0,0 @@
"""checked with raylib-python-cffi 5.5.0.2
raylib [audio] example - Music playing (streaming)
Example complexity rating: [] 1/4
Example originally created with raylib 1.3, last time updated with raylib 4.0
Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
BSD-like license that allows static linking with closed source software
Copyright (c) 2015-2025 Ramon Santamaria (@raysan5)
This source has been converted from C raylib examples to Python.
"""
import pyray as rl
from pathlib import Path
THIS_DIR = Path(__file__).resolve().parent
# ------------------------------------------------------------------------------------
# Program main entry point
# ------------------------------------------------------------------------------------
def main():
# Initialization
# --------------------------------------------------------------------------------------
screen_width = 800
screen_height = 450
rl.init_window(
screen_width,
screen_height,
"raylib [audio] example - music playing (streaming)",
)
rl.init_audio_device() # Initialize audio device
music = rl.load_music_stream(str(THIS_DIR / "resources/country.mp3"))
rl.play_music_stream(music)
time_played = 0.0 # Time played normalized [0.0f..1.0f]
pause = False # Music playing paused
rl.set_target_fps(30) # Set our game to run at 30 frames-per-second
# --------------------------------------------------------------------------------------
# Main game loop
while not rl.window_should_close(): # Detect window close button or ESC key
# Update
# ----------------------------------------------------------------------------------
rl.update_music_stream(music) # Update music buffer with new stream data
# Restart music playing (stop and play)
if rl.is_key_pressed(rl.KEY_SPACE):
rl.stop_music_stream(music)
rl.play_music_stream(music)
# Pause/Resume music playing
if rl.is_key_pressed(rl.KEY_P):
pause = not pause
if pause:
rl.pause_music_stream(music)
else:
rl.resume_music_stream(music)
# Get normalized time played for current music stream
time_played = rl.get_music_time_played(music) / rl.get_music_time_length(music)
if time_played > 1.0:
time_played = 1.0 # Make sure time played is no longer than music
# ----------------------------------------------------------------------------------
# Draw
# ----------------------------------------------------------------------------------
rl.begin_drawing()
rl.clear_background(rl.RAYWHITE)
rl.draw_text("MUSIC SHOULD BE PLAYING!", 255, 150, 20, rl.LIGHTGRAY)
rl.draw_rectangle(200, 200, 400, 12, rl.LIGHTGRAY)
rl.draw_rectangle(200, 200, int(time_played * 400.0), 12, rl.MAROON)
rl.draw_rectangle_lines(200, 200, 400, 12, rl.GRAY)
rl.draw_text("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, rl.LIGHTGRAY)
rl.draw_text("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, rl.LIGHTGRAY)
rl.end_drawing()
# ----------------------------------------------------------------------------------
# De-Initialization
# --------------------------------------------------------------------------------------
rl.unload_music_stream(music) # Unload music stream buffers from RAM
rl.close_audio_device() # Close audio device (music streaming is automatically stopped)
rl.close_window() # Close window and OpenGL context
# --------------------------------------------------------------------------------------
if __name__ == "__main__":
main()

View file

@ -1,67 +0,0 @@
"""checked with raylib-python-cffi 5.5.0.2
raylib [audio] example - Sound loading and playing
Example complexity rating: [] 1/4
Example originally created with raylib 1.1, last time updated with raylib 3.5
Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
BSD-like license that allows static linking with closed source software
Copyright (c) 2014-2025 Ramon Santamaria (@raysan5)
This source has been converted from C raylib examples to Python.
"""
import pyray as rl
from pathlib import Path
# Get the directory where this script is located
THIS_DIR = Path(__file__).resolve().parent
# Initialization
# --------------------------------------------------------------------------------------
screen_width = 800
screen_height = 450
rl.init_window(
screen_width, screen_height, "raylib [audio] example - sound loading and playing"
)
rl.init_audio_device() # Initialize audio device
# Load WAV audio file using proper path resolution
fx_wav = rl.load_sound(str(THIS_DIR / "resources/sound.wav"))
# Load OGG audio file using proper path resolution
fx_ogg = rl.load_sound(str(THIS_DIR / "resources/target.ogg"))
rl.set_target_fps(60) # Set our game to run at 60 frames-per-second
# --------------------------------------------------------------------------------------
# Main game loop
while not rl.window_should_close(): # Detect window close button or ESC key
# Update
# ----------------------------------------------------------------------------------
if rl.is_key_pressed(rl.KeyboardKey.KEY_SPACE):
rl.play_sound(fx_wav) # Play WAV sound
if rl.is_key_pressed(rl.KeyboardKey.KEY_ENTER):
rl.play_sound(fx_ogg) # Play OGG sound
# ----------------------------------------------------------------------------------
# Draw
# ----------------------------------------------------------------------------------
rl.begin_drawing()
rl.clear_background(rl.RAYWHITE)
rl.draw_text("Press SPACE to PLAY the WAV sound!", 200, 180, 20, rl.LIGHTGRAY)
rl.draw_text("Press ENTER to PLAY the OGG sound!", 200, 220, 20, rl.LIGHTGRAY)
rl.end_drawing()
# ----------------------------------------------------------------------------------
# De-Initialization
# --------------------------------------------------------------------------------------
rl.unload_sound(fx_wav) # Unload sound data
rl.unload_sound(fx_ogg) # Unload sound data
rl.close_audio_device() # Close audio device
rl.close_window() # Close window and OpenGL context
# --------------------------------------------------------------------------------------

View file

@ -1,86 +0,0 @@
"""checked with raylib-python-cffi 5.5.0.2
raylib [audio] example - Playing sound multiple times
Example complexity rating: [] 2/4
Example originally created with raylib 4.6, last time updated with raylib 4.6
Example contributed by Jeffery Myers (@JeffM2501) and reviewed by Ramon Santamaria (@raysan5)
Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
BSD-like license that allows static linking with closed source software
Copyright (c) 2023-2025 Jeffery Myers (@JeffM2501)
This source has been converted from C raylib examples to Python.
"""
from typing import List
import pyray as rl
from pathlib import Path
# Get the directory where this script is located
THIS_DIR = Path(__file__).resolve().parent
MAX_SOUNDS = 10
sound_array: List[rl.Sound] = []
current_sound = 0
# Initialization
# --------------------------------------------------------------------------------------
screen_width = 800
screen_height = 450
rl.init_window(
screen_width, screen_height, "raylib [audio] example - playing sound multiple times"
)
rl.init_audio_device() # Initialize audio device
# Load the sound list
sound_array.append(
rl.load_sound(str(THIS_DIR / "resources/sound.wav"))
) # Load WAV audio file into the first slot as the 'source' sound
# this sound owns the sample data
for i in range(1, MAX_SOUNDS):
sound_array.append(
rl.load_sound_alias(sound_array[0])
) # Load an alias of the sound into slots 1-9
# These do not own the sound data, but can be played
current_sound = 0 # Set the sound list to the start
rl.set_target_fps(60) # Set our game to run at 60 frames-per-second
# --------------------------------------------------------------------------------------
# Main game loop
while not rl.window_should_close(): # Detect window close button or ESC key
# Update
# ----------------------------------------------------------------------------------
if rl.is_key_pressed(rl.KeyboardKey.KEY_SPACE):
rl.play_sound(sound_array[current_sound]) # Play the next open sound slot
current_sound += 1 # Increment the sound slot
if (
current_sound >= MAX_SOUNDS
): # If the sound slot is out of bounds, go back to 0
current_sound = 0
# Note: a better way would be to look at the list for the first sound that is not playing and use that slot
# ----------------------------------------------------------------------------------
# Draw
# ----------------------------------------------------------------------------------
rl.begin_drawing()
rl.clear_background(rl.RAYWHITE)
rl.draw_text("Press SPACE to PLAY a WAV sound!", 200, 180, 20, rl.LIGHTGRAY)
rl.end_drawing()
# ----------------------------------------------------------------------------------
# De-Initialization
# --------------------------------------------------------------------------------------
for i in range(1, MAX_SOUNDS):
rl.unload_sound_alias(sound_array[i]) # Unload sound aliases
rl.unload_sound(sound_array[0]) # Unload source sound data
rl.close_audio_device() # Close audio device
rl.close_window() # Close window and OpenGL context
# --------------------------------------------------------------------------------------

View file

@ -1,112 +0,0 @@
"""checked with raylib-python-cffi 5.5.0.2
raylib [audio] example - Playing spatialized 3D sound
Example complexity rating: [] 2/4
Example originally created with raylib 5.5, last time updated with raylib 5.5
Example contributed by Le Juez Victor (@Bigfoot71) and reviewed by Ramon Santamaria (@raysan5)
Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
BSD-like license that allows static linking with closed source software
Copyright (c) 2025 Le Juez Victor (@Bigfoot71)
This source has been converted from C raylib examples to Python.
"""
import pyray as rl
import math
from pathlib import Path
# Get the directory where this script is located
THIS_DIR = Path(__file__).resolve().parent
# Sound positioning function
def set_sound_position(listener, sound, position, max_dist):
# Calculate direction vector and distance between listener and sound source
direction = rl.vector3_subtract(position, listener.position)
distance = rl.vector3_length(direction)
# Apply logarithmic distance attenuation and clamp between 0-1
attenuation = 1.0 / (1.0 + (distance / max_dist))
attenuation = rl.clamp(attenuation, 0.0, 1.0)
# Calculate normalized vectors for spatial positioning
normalized_direction = rl.vector3_normalize(direction)
forward = rl.vector3_normalize(
rl.vector3_subtract(listener.target, listener.position)
)
right = rl.vector3_normalize(rl.vector3_cross_product(listener.up, forward))
# Reduce volume for sounds behind the listener
dot_product = rl.vector3_dot_product(forward, normalized_direction)
if dot_product < 0.0:
attenuation *= 1.0 + dot_product * 0.5
# Set stereo panning based on sound position relative to listener
pan = 0.5 + 0.5 * rl.vector3_dot_product(normalized_direction, right)
# Apply final sound properties
rl.set_sound_volume(sound, attenuation)
rl.set_sound_pan(sound, pan)
# Initialization
# --------------------------------------------------------------------------------------
screen_width = 800
screen_height = 450
rl.init_window(
screen_width, screen_height, "raylib [audio] example - Playing spatialized 3D sound"
)
rl.init_audio_device()
sound = rl.load_sound(str(THIS_DIR / "resources/coin.wav"))
camera = rl.Camera3D(
(0, 5, 5),
(0, 0, 0),
(0, 1, 0),
60.0,
rl.CameraProjection.CAMERA_PERSPECTIVE,
)
rl.disable_cursor()
rl.set_target_fps(60)
# --------------------------------------------------------------------------------------
# Main game loop
while not rl.window_should_close():
# Update
# ----------------------------------------------------------------------------------
rl.update_camera(camera, rl.CameraMode.CAMERA_FREE)
th = rl.get_time()
sphere_pos = rl.Vector3(5.0 * math.cos(th), 0.0, 5.0 * math.sin(th))
set_sound_position(camera, sound, sphere_pos, 20.0)
if not rl.is_sound_playing(sound):
rl.play_sound(sound)
# ----------------------------------------------------------------------------------
# Draw
# ----------------------------------------------------------------------------------
rl.begin_drawing()
rl.clear_background(rl.RAYWHITE)
rl.begin_mode_3d(camera)
rl.draw_grid(10, 2)
rl.draw_sphere(sphere_pos, 0.5, rl.RED)
rl.end_mode_3d()
rl.end_drawing()
# ----------------------------------------------------------------------------------
# De-Initialization
# --------------------------------------------------------------------------------------
rl.unload_sound(sound)
rl.close_audio_device() # Close audio device
rl.close_window() # Close window and OpenGL context
# --------------------------------------------------------------------------------------

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -25,10 +25,10 @@ SetTargetFPS(60)
while not WindowShouldClose():
# Update
# ----------------------------------------------------------------------
UpdatePhysics() # Update physics system
if IsKeyPressed(KEY_R): # Reset physics system
ClosePhysics()
InitPhysics()
ResetPhysics()
floor = CreatePhysicsBodyRectangle((SCREEN_WIDTH/2, SCREEN_HEIGHT), 500, 100, 10)
floor.enabled = False

View file

@ -1,78 +0,0 @@
# Tested with version: 5.5.0.2
# by @Lightnet
from pyray import *
currentFrame = 0
framesCounter = 0
framesSpeed = 8
# Initialization
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 450
MAX_FRAME_SPEED = 15
MIN_FRAME_SPEED = 1
init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [texture] example - sprite anim")
#need to set in case of animation snyc
set_target_fps(60) # Set our game to run at 60 frames-per-second
scarfy = load_texture("resources/scarfy.png") # Texture loading
frameRec = Rectangle(0.0, 0.0, scarfy.width/6, scarfy.height)
position = Vector2(350.0, 280.0)
# Main game loop
while not window_should_close(): # Detect window close button or ESC key
framesCounter += 1
if framesCounter >= 60/framesSpeed:
framesCounter = 0
currentFrame += 1
if currentFrame > 5:
currentFrame = 0
frameRec.x = float(currentFrame) * float(scarfy.width/6)
# Control speed animation
if (is_key_pressed(KeyboardKey.KEY_RIGHT)):
framesSpeed += 1
elif is_key_pressed(KeyboardKey.KEY_LEFT):
framesSpeed -= 1
if framesSpeed > MAX_FRAME_SPEED:
framesSpeed = MAX_FRAME_SPEED
elif framesSpeed < MIN_FRAME_SPEED:
framesSpeed = MIN_FRAME_SPEED
begin_drawing()
clear_background(RAYWHITE)
#draw sheet block
draw_rectangle_lines(15, 40, scarfy.width, scarfy.height, LIME)
#draw current frame render
draw_rectangle_lines(15 + int(frameRec.x), 40 + int(frameRec.y), int(frameRec.width), int(frameRec.height), RED)
draw_text("FRAME SPEED: ", 165, 210, 10, DARKGRAY)
draw_text(f" FPS {framesSpeed}", 575, 210, 10, DARKGRAY) #format string
draw_text("PRESS RIGHT/LEFT KEYS to CHANGE SPEED!", 290, 240, 10, DARKGRAY)
#display bar framesSpeed cap
for i in range(MAX_FRAME_SPEED):
if i < framesSpeed:
draw_rectangle(250 + 21*i, 205, 20, 20, RED)
draw_rectangle_lines(250 + 21*i, 205, 20, 20, MAROON)
#draw sprite sheet texture
draw_texture(scarfy, 15, 40, WHITE)
#draw sprite animation
draw_texture_rec(scarfy, frameRec, position,WHITE)
draw_text("(c) Scarfy sprite by Eiden Marsal", SCREEN_WIDTH - 200, SCREEN_HEIGHT - 20, 10, GRAY)
end_drawing()
# De-Initialization
unload_texture(scarfy)
close_window() # Close window and OpenGL context

2
physac

@ -1 +1 @@
Subproject commit 587b63926010593eedf29ef74e3aa22c1a507925
Subproject commit 4a8e17f263fb8e1150b3fbafc96f880c7d7a4833

View file

@ -126,7 +126,7 @@ def _make_struct_constructor_function(struct):
or isinstance(arg, (array, bytes, bytearray, memoryview)))):
arg = ffi.from_buffer(field[1].type, arg)
modified_args.append(arg)
s = ffi.new(f"{struct} *", modified_args)[0]
s = ffi.new(f"struct {struct} *", modified_args)[0]
global_weakkeydict[s] = modified_args
return s

File diff suppressed because it is too large Load diff

@ -1 +1 @@
Subproject commit 15afe89aff2fc7da96ab5de80bde7f6186971cde
Subproject commit 26548c10620c4ae6937cf8b506c777a006b33c16

View file

@ -13,22 +13,18 @@
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
import sys
import logging
logger = logging.getLogger(__name__)
try:
from ._raylib_cffi import ffi, lib as rl
except ModuleNotFoundError:
logger.error("*** ERROR LOADING NATIVE CODE ***")
logger.error("See https://github.com/electronstudio/raylib-python-cffi/issues/142")
logger.error("Your Python is: %s", str(sys.implementation))
print("\n*** ERROR LOADING NATIVE CODE ***\n")
print("See https://github.com/electronstudio/raylib-python-cffi/issues/142\n", file=sys.stderr)
print("Your Python is: "+str(sys.implementation)+"\n", file=sys.stderr)
raise
from raylib._raylib_cffi.lib import *
from raylib.colors import *
from raylib.defines import *
import cffi
from .version import __version__
logger.warning("RAYLIB STATIC %s LOADED", __version__)
print("RAYLIB STATIC "+__version__+" LOADED", file=sys.stderr)

File diff suppressed because it is too large Load diff

View file

@ -24,14 +24,8 @@ import platform
import sys
import subprocess
import time
from pathlib import Path
THIS_DIR = Path(__file__).resolve().parent
REPO_ROOT = THIS_DIR.parent
RAYLIB_PLATFORM = os.getenv("RAYLIB_PLATFORM", "Desktop")
ENABLE_WAYLAND_DRM_LEASING = os.getenv("ENABLE_WAYLAND_DRM_LEASING")
def check_raylib_installed():
return subprocess.run(['pkg-config', '--exists', 'raylib'], text=True, stdout=subprocess.PIPE).returncode == 0
@ -48,17 +42,6 @@ def get_the_lib_path():
return subprocess.run(['pkg-config', '--variable=libdir', 'raylib'], text=True,
stdout=subprocess.PIPE).stdout.strip()
def get_specified_libs(lib_target):
libs = subprocess.run(['pkg-config', '--libs', lib_target], text=True,
stdout=subprocess.PIPE).stdout.strip().split()
if libs == "":
raise ValueError(f"Failed to get specified libs ({lib_target})")
print(f"{lib_target}: {libs}")
return libs
def get_lib_flags():
return subprocess.run(['pkg-config', '--libs', 'raylib'], text=True,
stdout=subprocess.PIPE).stdout.strip().split()
@ -196,11 +179,7 @@ def build_unix():
if RAYLIB_PLATFORM=="SDL":
extra_link_args += ['-lX11','-lSDL2']
elif RAYLIB_PLATFORM=="DRM":
extra_link_args += get_specified_libs("egl")
extra_link_args += get_specified_libs("gbm")
if ENABLE_WAYLAND_DRM_LEASING != "":
extra_link_args += get_specified_libs("wayland-client")
extra_link_args += ['-lEGL', '-lgbm']
else:
extra_link_args += ['-lX11']
extra_compile_args = ["-Wno-incompatible-pointer-types", "-D_CFFI_NO_LIMITED_API"]
@ -221,13 +200,13 @@ def build_unix():
def build_windows():
print("BUILDING FOR WINDOWS")
ffibuilder.cdef((THIS_DIR / "raylib.h.modified").read_text())
ffibuilder.cdef(open("raylib/raylib.h.modified").read())
if RAYLIB_PLATFORM=="Desktop":
ffibuilder.cdef((THIS_DIR / "glfw3.h.modified").read_text())
ffibuilder.cdef((THIS_DIR / "rlgl.h.modified").read_text())
ffibuilder.cdef((THIS_DIR / "raygui.h.modified").read_text())
ffibuilder.cdef((THIS_DIR / "physac.h.modified").read_text())
ffibuilder.cdef((THIS_DIR / "raymath.h.modified").read_text())
ffibuilder.cdef(open("raylib/glfw3.h.modified").read())
ffibuilder.cdef(open("raylib/rlgl.h.modified").read())
ffibuilder.cdef(open("raylib/raygui.h.modified").read())
ffibuilder.cdef(open("raylib/physac.h.modified").read())
ffibuilder.cdef(open("raylib/raymath.h.modified").read())
ffi_includes = """
#include "raylib.h"
@ -245,7 +224,6 @@ def build_windows():
#define RAYGUI_SUPPORT_RICONS
#include "raygui.h"
#define PHYSAC_IMPLEMENTATION
#define PHYSAC_NO_THREADS
#include "physac.h"
"""
libraries = ['raylib', 'gdi32', 'shell32', 'user32', 'OpenGL32', 'winmm']
@ -258,10 +236,10 @@ def build_windows():
extra_compile_args=["/D_CFFI_NO_LIMITED_API"],
py_limited_api=False,
libraries=libraries,
include_dirs=[str(REPO_ROOT / 'raylib-c/src'),
str(REPO_ROOT / 'raylib-c/src/external/glfw/include'),
str(REPO_ROOT / 'raygui/src'),
str(REPO_ROOT / 'physac/src')],
include_dirs=['D:\\a\\raylib-python-cffi\\raylib-python-cffi\\raylib-c\\src',
'D:\\a\\raylib-python-cffi\\raylib-python-cffi\\raylib-c\\src\\external\\glfw\\include',
'D:\\a\\raylib-python-cffi\\raylib-python-cffi\\raygui\\src',
'D:\\a\\raylib-python-cffi\\raylib-python-cffi\\physac\\src'],
)

View file

@ -186,10 +186,12 @@ RAYGUI_TEXTFORMAT_MAX_SIZE: int = 256
PHYSAC_MAX_BODIES: int = 64
PHYSAC_MAX_MANIFOLDS: int = 4096
PHYSAC_MAX_VERTICES: int = 24
PHYSAC_CIRCLE_VERTICES: int = 24
PHYSAC_COLLISION_ITERATIONS: int = 20
PHYSAC_DEFAULT_CIRCLE_VERTICES: int = 24
PHYSAC_COLLISION_ITERATIONS: int = 100
PHYSAC_PENETRATION_ALLOWANCE: float = 0.05
PHYSAC_PENETRATION_CORRECTION: float = 0.4
PHYSAC_PI: float = 3.141592653589793
PHYSAC_DEG2RAD = PHYSAC_PI / 180.0
PHYSAC_FLT_MAX: float = 3.402823466e+38
PHYSAC_EPSILON: float = 1e-06
GLFW_VERSION_MAJOR: int = 3

View file

@ -1,7 +1,6 @@
from enum import IntEnum
class ConfigFlags(IntEnum):
"""System/Window config flags."""
FLAG_VSYNC_HINT = 64
FLAG_FULLSCREEN_MODE = 2
FLAG_WINDOW_RESIZABLE = 4
@ -20,7 +19,6 @@ class ConfigFlags(IntEnum):
FLAG_INTERLACED_HINT = 65536
class TraceLogLevel(IntEnum):
"""Trace log level."""
LOG_ALL = 0
LOG_TRACE = 1
LOG_DEBUG = 2
@ -31,7 +29,6 @@ class TraceLogLevel(IntEnum):
LOG_NONE = 7
class KeyboardKey(IntEnum):
"""Keyboard keys (US keyboard layout)."""
KEY_NULL = 0
KEY_APOSTROPHE = 39
KEY_COMMA = 44
@ -144,7 +141,6 @@ class KeyboardKey(IntEnum):
KEY_VOLUME_DOWN = 25
class MouseButton(IntEnum):
"""Mouse buttons."""
MOUSE_BUTTON_LEFT = 0
MOUSE_BUTTON_RIGHT = 1
MOUSE_BUTTON_MIDDLE = 2
@ -154,7 +150,6 @@ class MouseButton(IntEnum):
MOUSE_BUTTON_BACK = 6
class MouseCursor(IntEnum):
"""Mouse cursor."""
MOUSE_CURSOR_DEFAULT = 0
MOUSE_CURSOR_ARROW = 1
MOUSE_CURSOR_IBEAM = 2
@ -168,7 +163,6 @@ class MouseCursor(IntEnum):
MOUSE_CURSOR_NOT_ALLOWED = 10
class GamepadButton(IntEnum):
"""Gamepad buttons."""
GAMEPAD_BUTTON_UNKNOWN = 0
GAMEPAD_BUTTON_LEFT_FACE_UP = 1
GAMEPAD_BUTTON_LEFT_FACE_RIGHT = 2
@ -189,7 +183,6 @@ class GamepadButton(IntEnum):
GAMEPAD_BUTTON_RIGHT_THUMB = 17
class GamepadAxis(IntEnum):
"""Gamepad axis."""
GAMEPAD_AXIS_LEFT_X = 0
GAMEPAD_AXIS_LEFT_Y = 1
GAMEPAD_AXIS_RIGHT_X = 2
@ -198,7 +191,6 @@ class GamepadAxis(IntEnum):
GAMEPAD_AXIS_RIGHT_TRIGGER = 5
class MaterialMapIndex(IntEnum):
"""Material map index."""
MATERIAL_MAP_ALBEDO = 0
MATERIAL_MAP_METALNESS = 1
MATERIAL_MAP_NORMAL = 2
@ -212,7 +204,6 @@ class MaterialMapIndex(IntEnum):
MATERIAL_MAP_BRDF = 10
class ShaderLocationIndex(IntEnum):
"""Shader location index."""
SHADER_LOC_VERTEX_POSITION = 0
SHADER_LOC_VERTEX_TEXCOORD01 = 1
SHADER_LOC_VERTEX_TEXCOORD02 = 2
@ -244,7 +235,6 @@ class ShaderLocationIndex(IntEnum):
SHADER_LOC_BONE_MATRICES = 28
class ShaderUniformDataType(IntEnum):
"""Shader uniform data type."""
SHADER_UNIFORM_FLOAT = 0
SHADER_UNIFORM_VEC2 = 1
SHADER_UNIFORM_VEC3 = 2
@ -256,14 +246,12 @@ class ShaderUniformDataType(IntEnum):
SHADER_UNIFORM_SAMPLER2D = 8
class ShaderAttributeDataType(IntEnum):
"""Shader attribute data types."""
SHADER_ATTRIB_FLOAT = 0
SHADER_ATTRIB_VEC2 = 1
SHADER_ATTRIB_VEC3 = 2
SHADER_ATTRIB_VEC4 = 3
class PixelFormat(IntEnum):
"""Pixel formats."""
PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1
PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA = 2
PIXELFORMAT_UNCOMPRESSED_R5G6B5 = 3
@ -290,7 +278,6 @@ class PixelFormat(IntEnum):
PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA = 24
class TextureFilter(IntEnum):
"""Texture parameters: filter mode."""
TEXTURE_FILTER_POINT = 0
TEXTURE_FILTER_BILINEAR = 1
TEXTURE_FILTER_TRILINEAR = 2
@ -299,14 +286,12 @@ class TextureFilter(IntEnum):
TEXTURE_FILTER_ANISOTROPIC_16X = 5
class TextureWrap(IntEnum):
"""Texture parameters: wrap mode."""
TEXTURE_WRAP_REPEAT = 0
TEXTURE_WRAP_CLAMP = 1
TEXTURE_WRAP_MIRROR_REPEAT = 2
TEXTURE_WRAP_MIRROR_CLAMP = 3
class CubemapLayout(IntEnum):
"""Cubemap layouts."""
CUBEMAP_LAYOUT_AUTO_DETECT = 0
CUBEMAP_LAYOUT_LINE_VERTICAL = 1
CUBEMAP_LAYOUT_LINE_HORIZONTAL = 2
@ -314,13 +299,11 @@ class CubemapLayout(IntEnum):
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE = 4
class FontType(IntEnum):
"""Font type, defines generation method."""
FONT_DEFAULT = 0
FONT_BITMAP = 1
FONT_SDF = 2
class BlendMode(IntEnum):
"""Color blending modes (pre-defined)."""
BLEND_ALPHA = 0
BLEND_ADDITIVE = 1
BLEND_MULTIPLIED = 2
@ -331,7 +314,6 @@ class BlendMode(IntEnum):
BLEND_CUSTOM_SEPARATE = 7
class Gesture(IntEnum):
"""Gesture."""
GESTURE_NONE = 0
GESTURE_TAP = 1
GESTURE_DOUBLETAP = 2
@ -345,7 +327,6 @@ class Gesture(IntEnum):
GESTURE_PINCH_OUT = 512
class CameraMode(IntEnum):
"""Camera system modes."""
CAMERA_CUSTOM = 0
CAMERA_FREE = 1
CAMERA_ORBITAL = 2
@ -353,43 +334,36 @@ class CameraMode(IntEnum):
CAMERA_THIRD_PERSON = 4
class CameraProjection(IntEnum):
"""Camera projection."""
CAMERA_PERSPECTIVE = 0
CAMERA_ORTHOGRAPHIC = 1
class NPatchLayout(IntEnum):
"""N-patch layout."""
NPATCH_NINE_PATCH = 0
NPATCH_THREE_PATCH_VERTICAL = 1
NPATCH_THREE_PATCH_HORIZONTAL = 2
class GuiState(IntEnum):
"""Gui control state."""
STATE_NORMAL = 0
STATE_FOCUSED = 1
STATE_PRESSED = 2
STATE_DISABLED = 3
class GuiTextAlignment(IntEnum):
"""Gui control text alignment."""
TEXT_ALIGN_LEFT = 0
TEXT_ALIGN_CENTER = 1
TEXT_ALIGN_RIGHT = 2
class GuiTextAlignmentVertical(IntEnum):
"""Gui control text alignment vertical."""
TEXT_ALIGN_TOP = 0
TEXT_ALIGN_MIDDLE = 1
TEXT_ALIGN_BOTTOM = 2
class GuiTextWrapMode(IntEnum):
"""Gui control text wrap mode."""
TEXT_WRAP_NONE = 0
TEXT_WRAP_CHAR = 1
TEXT_WRAP_WORD = 2
class GuiControl(IntEnum):
"""Gui controls."""
DEFAULT = 0
LABEL = 1
BUTTON = 2
@ -408,7 +382,6 @@ class GuiControl(IntEnum):
STATUSBAR = 15
class GuiControlProperty(IntEnum):
"""Gui base properties for every control."""
BORDER_COLOR_NORMAL = 0
BASE_COLOR_NORMAL = 1
TEXT_COLOR_NORMAL = 2
@ -426,7 +399,6 @@ class GuiControlProperty(IntEnum):
TEXT_ALIGNMENT = 14
class GuiDefaultProperty(IntEnum):
"""DEFAULT extended properties."""
TEXT_SIZE = 16
TEXT_SPACING = 17
LINE_COLOR = 18
@ -436,20 +408,16 @@ class GuiDefaultProperty(IntEnum):
TEXT_WRAP_MODE = 22
class GuiToggleProperty(IntEnum):
"""Toggle/ToggleGroup."""
GROUP_PADDING = 16
class GuiSliderProperty(IntEnum):
"""Slider/SliderBar."""
SLIDER_WIDTH = 16
SLIDER_PADDING = 17
class GuiProgressBarProperty(IntEnum):
"""ProgressBar."""
PROGRESS_PADDING = 16
class GuiScrollBarProperty(IntEnum):
"""ScrollBar."""
ARROWS_SIZE = 16
ARROWS_VISIBLE = 17
SCROLL_SLIDER_PADDING = 18
@ -458,32 +426,26 @@ class GuiScrollBarProperty(IntEnum):
SCROLL_SPEED = 21
class GuiCheckBoxProperty(IntEnum):
"""CheckBox."""
CHECK_PADDING = 16
class GuiComboBoxProperty(IntEnum):
"""ComboBox."""
COMBO_BUTTON_WIDTH = 16
COMBO_BUTTON_SPACING = 17
class GuiDropdownBoxProperty(IntEnum):
"""DropdownBox."""
ARROW_PADDING = 16
DROPDOWN_ITEMS_SPACING = 17
DROPDOWN_ARROW_HIDDEN = 18
DROPDOWN_ROLL_UP = 19
class GuiTextBoxProperty(IntEnum):
"""TextBox/TextBoxMulti/ValueBox/Spinner."""
TEXT_READONLY = 16
class GuiSpinnerProperty(IntEnum):
"""Spinner."""
SPIN_BUTTON_WIDTH = 16
SPIN_BUTTON_SPACING = 17
class GuiListViewProperty(IntEnum):
"""ListView."""
LIST_ITEMS_HEIGHT = 16
LIST_ITEMS_SPACING = 17
SCROLLBAR_WIDTH = 18
@ -491,7 +453,6 @@ class GuiListViewProperty(IntEnum):
LIST_ITEMS_BORDER_WIDTH = 20
class GuiColorPickerProperty(IntEnum):
"""ColorPicker."""
COLOR_SELECTOR_SIZE = 16
HUEBAR_WIDTH = 17
HUEBAR_PADDING = 18
@ -499,7 +460,6 @@ class GuiColorPickerProperty(IntEnum):
HUEBAR_SELECTOR_OVERFLOW = 20
class GuiIconName(IntEnum):
"""."""
ICON_NONE = 0
ICON_FOLDER_FILE_OPEN = 1
ICON_FILE_SAVE_CLASSIC = 2

View file

@ -4,8 +4,8 @@
*
* DESCRIPTION:
*
* Physac is a small 2D physics library written in pure C. The engine uses a fixed time-step thread loop
* to simluate physics. A physics step contains the following phases: get collision information,
* Physac is a small 2D physics engine written in pure C. The engine uses a fixed time-step thread loop
* to simulate physics. A physics step contains the following phases: get collision information,
* apply dynamics, collision solving and position correction. It uses a very simple struct for physic
* bodies with a position vector to be used in any 3D rendering API.
*
@ -16,49 +16,41 @@
* If not defined, the library is in header only mode and can be included in other headers
* or source files without problems. But only ONE file should hold the implementation.
*
* #define PHYSAC_STATIC (defined by default)
* The generated implementation will stay private inside implementation file and all
* internal symbols and functions will only be visible inside that file.
*
* #define PHYSAC_NO_THREADS
* The generated implementation won't include pthread library and user must create a secondary thread to call PhysicsThread().
* It is so important that the thread where PhysicsThread() is called must not have v-sync or any other CPU limitation.
*
* #define PHYSAC_STANDALONE
* Avoid raylib.h header inclusion in this file. Data types defined on raylib are defined
* internally in the library and input management and drawing functions must be provided by
* the user (check library implementation for further details).
*
* #define PHYSAC_DEBUG
* Traces log messages when creating and destroying physics bodies and detects errors in physics
* calculations and reference exceptions; it is useful for debug purposes
* Show debug traces log messages about physic bodies creation/destruction, physic system errors,
* some calculations results and NULL reference exceptions.
*
* #define PHYSAC_AVOID_TIMMING_SYSTEM
* Disables internal timming system, used by UpdatePhysics() to launch timmed physic steps,
* it allows just running UpdatePhysics() automatically on a separate thread at a desired time step.
* In case physics steps update needs to be controlled by user with a custom timming mechanism,
* just define this flag and the internal timming mechanism will be avoided, in that case,
* timming libraries are neither required by the module.
*
* #define PHYSAC_MALLOC()
* #define PHYSAC_CALLOC()
* #define PHYSAC_FREE()
* You can define your own malloc/free implementation replacing stdlib.h malloc()/free() functions.
* Otherwise it will include stdlib.h and use the C standard library malloc()/free() function.
*
* COMPILATION:
*
* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations.
* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread)
* Use the following code to compile with GCC:
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s -static -lraylib -lopengl32 -lgdi32 -lwinmm -std=c99
*
* Use the following code to compile:
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s -static -lraylib -lpthread -lopengl32 -lgdi32 -lwinmm -std=c99
*
* VERY THANKS TO:
* - raysan5: helped with library design
* - ficoos: added support for Linux
* - R8D8: added support for Linux
* - jubalh: fixed implementation of time calculations
* - a3f: fixed implementation of time calculations
* - define-private-public: added support for OSX
* - pamarcos: fixed implementation of physics steps
* - noshbar: fixed some memory leaks
* VERSIONS HISTORY:
* 1.1 (20-Jan-2021) @raysan5: Library general revision
* Removed threading system (up to the user)
* Support MSVC C++ compilation using CLITERAL()
* Review DEBUG mechanism for TRACELOG() and all TRACELOG() messages
* Review internal variables/functions naming for consistency
* Allow option to avoid internal timming system, to allow app manage the steps
* 1.0 (12-Jun-2017) First release of the library
*
*
* LICENSE: zlib/libpng
*
* Copyright (c) 2016-2025 Victor Fisac (github: @victorfisac)
* Copyright (c) 2016-2022 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
@ -76,41 +68,39 @@
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
// #define PHYSAC_STATIC
// #define PHYSAC_NO_THREADS
// #define PHYSAC_STANDALONE
// #define PHYSAC_DEBUG
// Function specifiers in case library is build/used as a shared library (Windows)
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
// Allow custom memory allocators
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
// Types and Structures Definition
// NOTE: Below types are required for PHYSAC_STANDALONE usage
// Data Types Structure Definition
//----------------------------------------------------------------------------------
typedef enum PhysicsShapeType { PHYSICS_CIRCLE, PHYSICS_POLYGON } PhysicsShapeType;
typedef enum PhysicsShapeType { PHYSICS_CIRCLE = 0, PHYSICS_POLYGON } PhysicsShapeType;
// Previously defined to be used in PhysicsShape struct as circular dependencies
typedef struct PhysicsBodyData *PhysicsBody;
// Mat2 type (used for polygon shape rotation matrix)
typedef struct Mat2 {
// Matrix2x2 type (used for polygon shape rotation matrix)
typedef struct Matrix2x2 {
float m00;
float m01;
float m10;
float m11;
} Mat2;
typedef struct PolygonData {
unsigned int vertexCount; // Current used vertex and normals count
Vector2 positions[24]; // Polygon vertex positions vectors
Vector2 normals[24]; // Polygon vertex normals vectors
} PolygonData;
} Matrix2x2;
typedef struct PhysicsVertexData {
unsigned int vertexCount; // Vertex count (positions and normals)
Vector2 positions[24 /* Maximum number of vertex for polygons shapes*/]; // Vertex positions vectors
Vector2 normals[24 /* Maximum number of vertex for polygons shapes*/]; // Vertex normals vectors
} PhysicsVertexData;
typedef struct PhysicsShape {
PhysicsShapeType type; // Physics shape type (circle or polygon)
PhysicsBody body; // Shape physics body reference
float radius; // Circle shape radius (used for circle shapes)
Mat2 transform; // Vertices transform matrix 2x2
PolygonData vertexData; // Polygon shape vertices position and normals data (just used for polygon shapes)
PhysicsShapeType type; // Shape type (circle or polygon)
PhysicsBody body; // Shape physics body data pointer
PhysicsVertexData vertexData; // Shape vertices data (used for polygon shapes)
float radius; // Shape radius (used for circle shapes)
Matrix2x2 transform; // Vertices transform matrix 2x2
} PhysicsShape;
typedef struct PhysicsBodyData {
unsigned int id; // Reference unique identifier
unsigned int id; // Unique identifier
bool enabled; // Enabled dynamics state (collisions are calculated anyway)
Vector2 position; // Physics body shape pivot
Vector2 velocity; // Current linear velocity applied to position
@ -128,10 +118,10 @@ typedef struct PhysicsBodyData {
bool useGravity; // Apply gravity force to dynamics
bool isGrounded; // Physics grounded on other body state
bool freezeOrient; // Physics rotation constraint
PhysicsShape shape; // Physics body shape information (type, radius, vertices, normals)
PhysicsShape shape; // Physics body shape information (type, radius, vertices, transform)
} PhysicsBodyData;
typedef struct PhysicsManifoldData {
unsigned int id; // Reference unique identifier
unsigned int id; // Unique identifier
PhysicsBody bodyA; // Manifold first physics body reference
PhysicsBody bodyB; // Manifold second physics body reference
float penetration; // Depth of penetration from collision
@ -145,25 +135,29 @@ typedef struct PhysicsManifoldData {
//----------------------------------------------------------------------------------
// Module Functions Declaration
//----------------------------------------------------------------------------------
extern /* Functions visible from other files*/ void InitPhysics(void); // Initializes physics values, pointers and creates physics loop thread
extern /* Functions visible from other files*/ void RunPhysicsStep(void); // Run physics step, to be used if PHYSICS_NO_THREADS is set in your main loop
extern /* Functions visible from other files*/ void SetPhysicsTimeStep(double delta); // Sets physics fixed time step in milliseconds. 1.666666 by default
extern /* Functions visible from other files*/ bool IsPhysicsEnabled(void); // Returns true if physics thread is currently enabled
extern /* Functions visible from other files*/ void SetPhysicsGravity(float x, float y); // Sets physics global gravity force
extern /* Functions visible from other files*/ PhysicsBody CreatePhysicsBodyCircle(Vector2 pos, float radius, float density); // Creates a new circle physics body with generic parameters
extern /* Functions visible from other files*/ PhysicsBody CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density); // Creates a new rectangle physics body with generic parameters
extern /* Functions visible from other files*/ PhysicsBody CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density); // Creates a new polygon physics body with generic parameters
extern /* Functions visible from other files*/ void PhysicsAddForce(PhysicsBody body, Vector2 force); // Adds a force to a physics body
extern /* Functions visible from other files*/ void PhysicsAddTorque(PhysicsBody body, float amount); // Adds an angular force to a physics body
extern /* Functions visible from other files*/ void PhysicsShatter(PhysicsBody body, Vector2 position, float force); // Shatters a polygon shape physics body to little physics bodies with explosion force
extern /* Functions visible from other files*/ int GetPhysicsBodiesCount(void); // Returns the current amount of created physics bodies
extern /* Functions visible from other files*/ PhysicsBody GetPhysicsBody(int index); // Returns a physics body of the bodies pool at a specific index
extern /* Functions visible from other files*/ int GetPhysicsShapeType(int index); // Returns the physics body shape type (PHYSICS_CIRCLE or PHYSICS_POLYGON)
extern /* Functions visible from other files*/ int GetPhysicsShapeVerticesCount(int index); // Returns the amount of vertices of a physics body shape
extern /* Functions visible from other files*/ Vector2 GetPhysicsShapeVertex(PhysicsBody body, int vertex); // Returns transformed position of a body shape (body position + vertex transformed position)
extern /* Functions visible from other files*/ void SetPhysicsBodyRotation(PhysicsBody body, float radians); // Sets physics body shape transform based on radians parameter
extern /* Functions visible from other files*/ void DestroyPhysicsBody(PhysicsBody body); // Unitializes and destroy a physics body
extern /* Functions visible from other files*/ void ClosePhysics(void); // Unitializes physics pointers and closes physics loop thread
// Physics system management
void InitPhysics(void); // Initializes physics system
void UpdatePhysics(void); // Update physics system
void ResetPhysics(void); // Reset physics system (global variables)
void ClosePhysics(void); // Close physics system and unload used memory
void SetPhysicsTimeStep(double delta); // Sets physics fixed time step in milliseconds. 1.666666 by default
void SetPhysicsGravity(float x, float y); // Sets physics global gravity force
// Physic body creation/destroy
PhysicsBody CreatePhysicsBodyCircle(Vector2 pos, float radius, float density); // Creates a new circle physics body with generic parameters
PhysicsBody CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density); // Creates a new rectangle physics body with generic parameters
PhysicsBody CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density); // Creates a new polygon physics body with generic parameters
void DestroyPhysicsBody(PhysicsBody body); // Destroy a physics body
// Physic body forces
void PhysicsAddForce(PhysicsBody body, Vector2 force); // Adds a force to a physics body
void PhysicsAddTorque(PhysicsBody body, float amount); // Adds an angular force to a physics body
void PhysicsShatter(PhysicsBody body, Vector2 position, float force); // Shatters a polygon shape physics body to little physics bodies with explosion force
void SetPhysicsBodyRotation(PhysicsBody body, float radians); // Sets physics body shape transform based on radians parameter
// Query physics info
PhysicsBody GetPhysicsBody(int index); // Returns a physics body of the bodies pool at a specific index
int GetPhysicsBodiesCount(void); // Returns the current amount of created physics bodies
int GetPhysicsShapeType(int index); // Returns the physics body shape type (PHYSICS_CIRCLE or PHYSICS_POLYGON)
int GetPhysicsShapeVerticesCount(int index); // Returns the amount of vertices of a physics body shape
Vector2 GetPhysicsShapeVertex(PhysicsBody body, int vertex); // Returns transformed position of a body shape (body position + vertex transformed position)
/***********************************************************************************
*
* PHYSAC IMPLEMENTATION

View file

@ -3,7 +3,7 @@
* rlgl v5.0 - A multi-OpenGL abstraction layer with an immediate-mode style API
*
* DESCRIPTION:
* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0)
* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0, ES 3.0)
* that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...)
*
* ADDITIONAL NOTES:

View file

@ -12,20 +12,20 @@ VERSION = (HERE / "version.py").read_text().split()[-1].strip("\"'")
RAYLIB_PLATFORM = os.getenv("RAYLIB_PLATFORM", "Desktop")
if RAYLIB_PLATFORM == "SDL":
NAME = "_sdl"
NAME = "raylib_sdl"
elif RAYLIB_PLATFORM == "DRM":
NAME = "_drm"
NAME = "raylib_drm"
else:
NAME = ""
NAME = "raylib"
class BinaryDistribution(Distribution):
"""Distribution which always forces a binary package with platform name"""
def has_ext_modules(foo):
return True
# should be name="raylib"+NAME but then Github doesn't track dependants
# This call to setup() does all the work
setup(
name="raylib",
name=NAME,
version=VERSION,
description="Python CFFI bindings for Raylib",
long_description=README,
@ -41,6 +41,9 @@ setup(
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.7",
],
packages=["raylib", "pyray"],
include_package_data=True,

View file

@ -1,30 +0,0 @@
{
pkgs ? import <nixpkgs> { },
}: pkgs.mkShell {
buildInputs = with pkgs; [
python3
cmake
clang-tools
pkg-config
wayland-scanner
wayland
libGL
libgbm
libdrm
xorg.libXi
xorg.libXcursor
xorg.libXrandr
xorg.libXinerama
xorg.libX11
];
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath [ pkgs.xorg.libX11 pkgs.libGL ]}:$LD_LIBRARY_PATH"
if [ ! -d ".venv" ]; then
python3 -m venv .venv
fi
source .venv/bin/activate
'';
}

View file

@ -7,8 +7,6 @@ import pyray as pr
pr.init_window(800, 450, "Raylib texture test")
pr.set_target_fps(60)
test_typedef_init = pr.Texture2D() # Texture2D is typedef for Texture
image = pr.gen_image_color(800, 400, (0,0,0,255) )
texture = pr.load_texture_from_image(image)
pr.update_texture(texture, image.data)

View file

@ -1 +1 @@
__version__ = "5.5.0.2"
__version__ = "5.5.0.0"