Compare commits
89 commits
Author | SHA1 | Date | |
---|---|---|---|
|
6820db28c6 | ||
|
f2d9201159 | ||
|
581cda51dc | ||
|
4e0a89162b | ||
|
96d620382c | ||
|
1817fec006 | ||
|
cfad3eacaa | ||
|
e01bdb3b78 | ||
|
509771f482 | ||
|
3d8f36e9c7 | ||
|
9683c579c3 | ||
|
e97135eb8c | ||
|
5dafa4e99a | ||
|
be6cf57d85 | ||
|
62ff73d0e7 | ||
|
4670e271ca | ||
|
adbcdce416 | ||
|
3269b0cb9b | ||
|
d17d3abb92 | ||
|
b0da316441 | ||
|
2154d36b41 | ||
|
b3ff23e6cf | ||
|
fb3f3f9b22 | ||
|
b8231d23b8 | ||
|
29f5f42af7 | ||
|
b14d0a2b3c | ||
|
cadf3d1f0c | ||
|
3c7289c844 | ||
|
0bf9138122 | ||
|
447b17446f | ||
|
a11016ba34 | ||
|
7899b51bbd | ||
|
3314597eed | ||
|
391e600693 | ||
|
05ada5fa0d | ||
|
10692d5168 | ||
|
7e2da775ae | ||
|
35c457ef7d | ||
|
05c455b17f | ||
|
3b0238c61d | ||
|
05e71eae62 | ||
|
1b73f0f8b0 | ||
|
1f172355d3 | ||
|
e692b7ce99 | ||
|
7f05708aad | ||
|
30913ef51a | ||
|
afa5ae9463 | ||
|
a5cb5ab6ed | ||
|
c98bdcd961 | ||
|
65f89be6ee | ||
|
467263a43d | ||
|
2ffd22435a | ||
|
730c9d4643 | ||
|
4c4c17d0de | ||
|
cbdba24ff2 | ||
|
7793b056a0 | ||
|
5fc35c919d | ||
|
fb417dbf71 | ||
|
22f624d7ca | ||
|
19ab15d89e | ||
|
9d14fbfb23 | ||
|
192d2031a7 | ||
|
ac5b6b95e1 | ||
|
ea4b0a007d | ||
|
d0330043c1 | ||
|
edb2d55aa6 | ||
|
b3d05efd05 | ||
|
d693a846ce | ||
|
e2f8b4fb11 | ||
|
6286a2cf66 | ||
|
ecc3c08a45 | ||
|
7323343ada | ||
|
d8647daafa | ||
|
452881e916 | ||
|
c12365d448 | ||
|
4a787f1c71 | ||
|
55a0d150c4 | ||
|
957584a9d4 | ||
|
8db9563c53 | ||
|
216c4696f2 | ||
|
a9f2884f39 | ||
|
dad06219c3 | ||
|
0bf42b291e | ||
|
dd9916a8f8 | ||
|
0a0ceea1dd | ||
|
6b7cffe86f | ||
|
9b81a6d699 | ||
|
a48757b815 | ||
|
271c6e1aeb |
59 changed files with 11501 additions and 10891 deletions
|
@ -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
|
||||
|
|
46
.github/workflows/build.yml
vendored
46
.github/workflows/build.yml
vendored
|
@ -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
4
.gitmodules
vendored
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
||||
::
|
||||
|
|
97
README.md
97
README.md
|
@ -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
|
||||
|
||||

|
||||
|
||||
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
|
||||
|
|
4
RPI.rst
4
RPI.rst
|
@ -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
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
from pathlib import Path
|
||||
from raylib import rl, ffi
|
||||
from pyray import _underscore
|
||||
from inspect import ismethod, getmembers, isbuiltin
|
||||
import inflection, sys, json
|
||||
|
||||
|
@ -32,8 +31,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,18 +77,17 @@ 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
|
||||
reserved_words = ("in", "list", "tuple", "set", "dict", "from", "range", "min", "max", "any", "all", "len")
|
||||
|
||||
for name, attr in getmembers(rl):
|
||||
uname = _underscore(name)
|
||||
uname = inflection.underscore(name).replace('3_d', '_3d').replace('2_d', '_2d')
|
||||
if isbuiltin(attr) or str(type(attr)) == "<class '_cffi_backend.__FFIFunctionWrapper'>":
|
||||
json_object = known_functions.get(name, None)
|
||||
if json_object is None:
|
||||
|
@ -120,11 +117,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 +143,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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Building from source — 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>
|
||||
|
|
101
docs/README.html
101
docs/README.html
|
@ -7,7 +7,7 @@
|
|||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Python Bindings for Raylib 5.5 — 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">"Hello"</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 isn’t 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 doesn’t, <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 can’t 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 doesn’t 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 doesn’t 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> >=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> >=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"># "cffi",</span>
|
||||
<span class="c1"># "raylib"</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 = [
|
||||
# "cffi",
|
||||
# "raylib"
|
||||
# ]
|
||||
# ///
|
||||
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">"Hello"</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">"Hello world"</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, "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()
|
||||
|
||||
<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">"Emscripten"</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">
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Raspberry Pi — 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">
|
||||
|
|
|
@ -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
|
||||
|
||||

|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
||||
|
|
8
docs/_static/basic.css
vendored
8
docs/_static/basic.css
vendored
|
@ -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 {
|
||||
|
|
10
docs/_static/js/versions.js
vendored
10
docs/_static/js/versions.js
vendored
|
@ -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"' : ""}>
|
||||
|
|
66
docs/_static/pygments.css
vendored
66
docs/_static/pygments.css
vendored
|
@ -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 */
|
13
docs/_static/searchtools.js
vendored
13
docs/_static/searchtools.js
vendored
|
@ -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],
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Dynamic Bindings — 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 don’t 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 can’t have both modules installed at once.) The only difference is you can’t 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>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Index — 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>
|
||||
|
@ -10667,14 +10666,6 @@
|
|||
<li><a href="pyray.html#pyray.vector2_clamp">vector2_clamp() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector2_clamp_value">vector2_clamp_value() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector2_distance">vector2_distance() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector2_distance_sqr">vector2_distance_sqr() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector2_divide">vector2_divide() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector2_dot_product">vector2_dot_product() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector2_equals">vector2_equals() (in module pyray)</a>
|
||||
</li>
|
||||
|
@ -10799,14 +10790,6 @@
|
|||
<li><a href="pyray.html#pyray.vector3_cross_product">vector3_cross_product() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector3_cubic_hermite">vector3_cubic_hermite() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector3_distance">vector3_distance() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector3_distance_sqr">vector3_distance_sqr() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector3_divide">vector3_divide() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector3_dot_product">vector3_dot_product() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector3_equals">vector3_equals() (in module pyray)</a>
|
||||
</li>
|
||||
|
@ -10856,8 +10839,6 @@
|
|||
</li>
|
||||
<li><a href="pyray.html#pyray.vector3_to_float_v">vector3_to_float_v() (in module pyray)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="pyray.html#pyray.vector3_transform">vector3_transform() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector3_unproject">vector3_unproject() (in module pyray)</a>
|
||||
|
@ -10874,6 +10855,8 @@
|
|||
</li>
|
||||
<li><a href="raylib.html#raylib.Vector3Clamp">Vector3Clamp() (in module raylib)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="raylib.html#raylib.Vector3ClampValue">Vector3ClampValue() (in module raylib)</a>
|
||||
</li>
|
||||
<li><a href="raylib.html#raylib.Vector3CrossProduct">Vector3CrossProduct() (in module raylib)</a>
|
||||
|
@ -11035,6 +11018,22 @@
|
|||
<li><a href="raylib.html#raylib.Vector4SubtractValue">Vector4SubtractValue() (in module raylib)</a>
|
||||
</li>
|
||||
<li><a href="raylib.html#raylib.Vector4Zero">Vector4Zero() (in module raylib)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector_2distance">vector_2distance() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector_2distance_sqr">vector_2distance_sqr() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector_2divide">vector_2divide() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector_2dot_product">vector_2dot_product() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector_3distance">vector_3distance() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector_3distance_sqr">vector_3distance_sqr() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector_3divide">vector_3divide() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.vector_3dot_product">vector_3dot_product() (in module pyray)</a>
|
||||
</li>
|
||||
<li><a href="pyray.html#pyray.PhysicsBodyData.velocity">velocity (pyray.PhysicsBodyData attribute)</a>
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Raylib Python — 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>
|
||||
|
|
BIN
docs/objects.inv
BIN
docs/objects.inv
Binary file not shown.
|
@ -6,7 +6,7 @@
|
|||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Python Module Index — 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>
|
||||
|
|
3917
docs/pyray.html
3917
docs/pyray.html
File diff suppressed because one or more lines are too long
2538
docs/raylib.html
2538
docs/raylib.html
File diff suppressed because one or more lines are too long
|
@ -6,7 +6,7 @@
|
|||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Search — 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
|
@ -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
|
@ -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
|
||||
|
|
|
@ -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.
|
@ -1 +0,0 @@
|
|||
../../raylib/raylib.h.modified
|
1409
dynamic/raylib/raylib_modified.h
Normal file
1409
dynamic/raylib/raylib_modified.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -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()
|
|
@ -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
|
||||
# --------------------------------------------------------------------------------------
|
|
@ -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
|
||||
# --------------------------------------------------------------------------------------
|
|
@ -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.
|
@ -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
|
||||
|
|
|
@ -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
2
physac
|
@ -1 +1 @@
|
|||
Subproject commit 587b63926010593eedf29ef74e3aa22c1a507925
|
||||
Subproject commit 4a8e17f263fb8e1150b3fbafc96f880c7d7a4833
|
|
@ -29,8 +29,9 @@ current_module = __import__(__name__)
|
|||
|
||||
|
||||
def _underscore(word: str) -> str:
|
||||
word = re.sub('2D$', '_2d', word)
|
||||
word = re.sub('3D$', '_3d', word)
|
||||
"""
|
||||
from inflection
|
||||
"""
|
||||
word = re.sub(r"([A-Z]+)([A-Z][a-z])", r'\1_\2', word)
|
||||
word = re.sub(r"([a-z\d])([A-Z])", r'\1_\2', word)
|
||||
word = word.replace("-", "_")
|
||||
|
@ -126,7 +127,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
|
||||
|
||||
|
@ -135,7 +136,7 @@ def _make_struct_constructor_function(struct):
|
|||
|
||||
for name, attr in getmembers(rl):
|
||||
# print(name, attr)
|
||||
uname = _underscore(name)
|
||||
uname = _underscore(name).replace('3_d', '_3d').replace('2_d', '_2d')
|
||||
if isbuiltin(attr) or str(type(attr)) == "<class '_cffi_backend.__FFIFunctionWrapper'>" or str(
|
||||
type(attr)) == "<class '_cffi_backend._CDataBase'>":
|
||||
# print(attr.__call__)
|
||||
|
|
4493
pyray/__init__.pyi
4493
pyray/__init__.pyi
File diff suppressed because it is too large
Load diff
2
raylib-c
2
raylib-c
|
@ -1 +1 @@
|
|||
Subproject commit 15afe89aff2fc7da96ab5de80bde7f6186971cde
|
||||
Subproject commit 26548c10620c4ae6937cf8b506c777a006b33c16
|
|
@ -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)
|
||||
|
||||
|
|
4332
raylib/__init__.pyi
4332
raylib/__init__.pyi
File diff suppressed because it is too large
Load diff
|
@ -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'],
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
13
setup.py
13
setup.py
|
@ -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,
|
||||
|
|
30
shell.nix
30
shell.nix
|
@ -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
|
||||
'';
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -1 +1 @@
|
|||
__version__ = "5.5.0.2"
|
||||
__version__ = "5.5.0.0"
|
Reference in a new issue