Compare commits
84 commits
master
...
v5.5.0.0-d
Author | SHA1 | Date | |
---|---|---|---|
|
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 |
109 changed files with 16439 additions and 21203 deletions
|
@ -89,12 +89,6 @@ mac_task:
|
||||||
- env:
|
- env:
|
||||||
PY_VER: "3.11"
|
PY_VER: "3.11"
|
||||||
RAYLIB_PLATFORM: Desktop
|
RAYLIB_PLATFORM: Desktop
|
||||||
- env:
|
|
||||||
PY_VER: "3.11"
|
|
||||||
RAYLIB_PLATFORM: SDL
|
|
||||||
- env:
|
|
||||||
PY_VER: "3.12"
|
|
||||||
RAYLIB_PLATFORM: Desktop
|
|
||||||
- env:
|
- env:
|
||||||
PY_VER: "3.12"
|
PY_VER: "3.12"
|
||||||
RAYLIB_PLATFORM: SDL
|
RAYLIB_PLATFORM: SDL
|
||||||
|
@ -137,6 +131,7 @@ mac_task:
|
||||||
- sudo cp -r raylib-c/src/external/glfw/include/GLFW /usr/local/include/
|
- sudo cp -r raylib-c/src/external/glfw/include/GLFW /usr/local/include/
|
||||||
- sudo cp physac/src/physac.h /usr/local/include/
|
- sudo cp physac/src/physac.h /usr/local/include/
|
||||||
- sudo cp raygui/src/raygui.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 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 setuptools
|
||||||
- /opt/homebrew/bin/python${PY_VER} -m pip install --break-system-packages wheel
|
- /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:
|
jobs:
|
||||||
build-mac-intel:
|
build-mac-intel:
|
||||||
runs-on: macos-13
|
runs-on: macos-12
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
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']
|
raylib-platform: ['Desktop', 'SDL']
|
||||||
env:
|
env:
|
||||||
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
||||||
|
@ -93,9 +93,9 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Upload build Artifact wheel
|
- name: Upload build Artifact wheel
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v3.2.1
|
||||||
with:
|
with:
|
||||||
name: wheel-mac-${{ matrix.raylib-platform }}-${{ matrix.python-version }}
|
name: wheel
|
||||||
path: dist/*
|
path: dist/*
|
||||||
|
|
||||||
# build-mac-universal:
|
# build-mac-universal:
|
||||||
|
@ -182,12 +182,12 @@ jobs:
|
||||||
|
|
||||||
|
|
||||||
build-linux:
|
build-linux:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-20.04
|
||||||
strategy:
|
strategy:
|
||||||
# You can use PyPy versions in python-version.
|
# You can use PyPy versions in python-version.
|
||||||
# For example, pypy2 and pypy3
|
# For example, pypy2 and pypy3
|
||||||
matrix:
|
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']
|
raylib-platform: ['Desktop', 'SDL', 'DRM']
|
||||||
steps:
|
steps:
|
||||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||||
|
@ -256,9 +256,9 @@ jobs:
|
||||||
|
|
||||||
|
|
||||||
- name: Upload build Artifact wheel
|
- name: Upload build Artifact wheel
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v3.2.1
|
||||||
with:
|
with:
|
||||||
name: wheel-linux-${{ matrix.raylib-platform }}-${{ matrix.python-version }}
|
name: wheel
|
||||||
path: dist/*
|
path: dist/*
|
||||||
|
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ jobs:
|
||||||
# You can use PyPy versions in python-version.
|
# You can use PyPy versions in python-version.
|
||||||
# For example, pypy2 and pypy3
|
# For example, pypy2 and pypy3
|
||||||
matrix:
|
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']
|
raylib-platform: ['Desktop', 'SDL']
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
@ -299,7 +299,7 @@ jobs:
|
||||||
architecture: x64
|
architecture: x64
|
||||||
|
|
||||||
- name: Add msbuild to PATH
|
- name: Add msbuild to PATH
|
||||||
uses: microsoft/setup-msbuild@v2
|
uses: microsoft/setup-msbuild@v1.0.2
|
||||||
|
|
||||||
- name: Build raylib
|
- name: Build raylib
|
||||||
run: |
|
run: |
|
||||||
|
@ -345,13 +345,13 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Upload build Artifact wheel
|
- name: Upload build Artifact wheel
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v3.2.1
|
||||||
with:
|
with:
|
||||||
name: wheel-windows-${{ matrix.raylib-platform }}-${{ matrix.python-version }}
|
name: wheel
|
||||||
path: dist/*
|
path: dist/*
|
||||||
|
|
||||||
source-distro:
|
source-distro:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||||
|
@ -392,13 +392,13 @@ jobs:
|
||||||
python setup.py sdist
|
python setup.py sdist
|
||||||
|
|
||||||
- name: Upload build Artifact wheel
|
- name: Upload build Artifact wheel
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v3.2.1
|
||||||
with:
|
with:
|
||||||
name: wheel-source
|
name: wheel
|
||||||
path: dist/*
|
path: dist/*
|
||||||
|
|
||||||
dynamic-distro:
|
dynamic-distro:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||||
|
@ -424,17 +424,7 @@ jobs:
|
||||||
python setup.py sdist
|
python setup.py sdist
|
||||||
|
|
||||||
- name: Upload build Artifact wheel
|
- name: Upload build Artifact wheel
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v3.2.1
|
||||||
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
|
|
||||||
with:
|
with:
|
||||||
name: wheel
|
name: wheel
|
||||||
pattern: wheel-*
|
path: dynamic/dist/*
|
||||||
|
|
4
.gitmodules
vendored
4
.gitmodules
vendored
|
@ -1,9 +1,9 @@
|
||||||
[submodule "raylib-c"]
|
[submodule "raylib-c"]
|
||||||
path = raylib-c
|
path = raylib-c
|
||||||
url = https://git.terah.dev/UnrealXR/raylib.git
|
url = https://github.com/raysan5/raylib.git
|
||||||
[submodule "raygui"]
|
[submodule "raygui"]
|
||||||
path = raygui
|
path = raygui
|
||||||
url = https://github.com/raysan5/raygui.git
|
url = https://github.com/raysan5/raygui.git
|
||||||
[submodule "physac"]
|
[submodule "physac"]
|
||||||
path = 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
|
pip3 install wheel
|
||||||
python setup.py bdist_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:
|
Then install it:
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
|
@ -10,7 +10,6 @@ exclude raylib/*.c
|
||||||
exclude raylib/*.o
|
exclude raylib/*.o
|
||||||
include version.py
|
include version.py
|
||||||
exclude tests/*
|
exclude tests/*
|
||||||
include raylib/py.typed
|
|
||||||
include pyray/py.typed
|
|
||||||
|
|
||||||
|
|
||||||
|
|
61
README.md
61
README.md
|
@ -1,30 +1,22 @@
|
||||||
# Python Bindings for Raylib 5.5
|
# Python Bindings for Raylib 5.5
|
||||||
## Libraries: raymath, raygui, rlgl, physac and GLFW
|
## Libraries: raymath, raygui, rlgl, physac and GLFW
|
||||||
## Backends: Desktop, SDL, DRM, Web
|
## Backends: Desktop, SDL, DRM, Web
|
||||||
## Platforms: Windows, Mac, Linux, Raspberry Pi, Web
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Chatroom: [Discord](https://discord.gg/fKDwt85aX6)
|
Chatroom: [Discord](https://discord.gg/fKDwt85aX6)
|
||||||
|
|
||||||
HELP WANTED: [writing examples](https://github.com/electronstudio/raylib-python-cffi/issues/155)
|
New CFFI API static bindings.
|
||||||
|
|
||||||
Features:
|
|
||||||
|
|
||||||
* CFFI API static bindings.
|
|
||||||
* Automatically generated to be as close as possible to
|
* Automatically generated to be as close as possible to
|
||||||
original Raylib.
|
original Raylib.
|
||||||
* Faster, fewer bugs and easier to maintain than ctypes.
|
* Faster, fewer bugs and easier to maintain than ctypes.
|
||||||
* Commercial-friendly license.
|
* Commercial-friendly license.
|
||||||
* Docstrings and auto-completion.
|
* Docstrings and auto-completion.
|
||||||
* Type checking with Mypy
|
|
||||||
|
|
||||||
|
|
||||||
[Full documentation](http://electronstudio.github.io/raylib-python-cffi)
|
[Full documentation](http://electronstudio.github.io/raylib-python-cffi)
|
||||||
|
|
||||||
# Quickstart
|
# Quickstart
|
||||||
|
|
||||||
`pip3 install raylib==5.5.0.2 --break-system-packages`
|
`pip3 install raylib==5.0.0.4`
|
||||||
```python
|
```python
|
||||||
from pyray import *
|
from pyray import *
|
||||||
init_window(800, 450, "Hello")
|
init_window(800, 450, "Hello")
|
||||||
|
@ -38,19 +30,14 @@ close_window()
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
If you are on a modern Linux you will probably want to create a venv:
|
First make sure you have the latest pip installed:
|
||||||
|
|
||||||
python3 -m venv venv
|
|
||||||
source venv/bin/activate
|
|
||||||
|
|
||||||
Then make sure you have the latest pip installed:
|
|
||||||
|
|
||||||
python3 -m pip install --upgrade pip
|
python3 -m pip install --upgrade pip
|
||||||
|
|
||||||
Then install
|
Then install
|
||||||
|
|
||||||
python3 -m pip install setuptools
|
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
|
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.
|
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 pkg-config
|
||||||
brew install raylib
|
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
|
(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.)
|
if you want to test them.)
|
||||||
|
@ -89,8 +76,6 @@ so may not work on other boards.
|
||||||
|
|
||||||
[Using on Rasperry Pi](RPI.rst)
|
[Using on Rasperry Pi](RPI.rst)
|
||||||
|
|
||||||
# Backends
|
|
||||||
|
|
||||||
## Dynamic binding version
|
## Dynamic binding version
|
||||||
|
|
||||||
There is now a separate dynamic version of this binding:
|
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)
|
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
|
## SDL backend
|
||||||
|
|
||||||
This is not well tested but has better support for controllers:
|
This is not well tested but has better support for controllers:
|
||||||
|
@ -133,8 +116,8 @@ If it still doesn't work, [submit an issue](https://github.com/electronstudio/ra
|
||||||
|
|
||||||
# How to use
|
# How to use
|
||||||
|
|
||||||
There are *two* modules in the raylib package, `raylib` and `pyray`. (There is no separate package for
|
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:
|
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
|
### If you are familiar with C coding and the Raylib C library and you want to use an exact copy of the C API
|
||||||
|
|
||||||
|
@ -146,12 +129,10 @@ Use [the pyray module](https://electronstudio.github.io/raylib-python-cffi/pyray
|
||||||
|
|
||||||
# Running in a web browser
|
# 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
|
[Pygbag](https://pypi.org/project/pygbag/) >=0.8.7 supports running in a web browser.
|
||||||
is recommended.
|
|
||||||
|
|
||||||
Make a folder `my_project` with a file `main.py`:
|
Make a folder `my_project` with a file `main.py`:
|
||||||
|
|
||||||
```python
|
|
||||||
# /// script
|
# /// script
|
||||||
# dependencies = [
|
# dependencies = [
|
||||||
# "cffi",
|
# "cffi",
|
||||||
|
@ -162,34 +143,26 @@ import asyncio
|
||||||
import platform
|
import platform
|
||||||
from pyray import *
|
from pyray import *
|
||||||
|
|
||||||
async def main(): # You MUST have an async main function
|
async def main(): # You must have an async main function
|
||||||
init_window(500, 500, "Hello")
|
init_window(500, 500, "Hello")
|
||||||
platform.window.window_resize() # You MAY want to add this line
|
platform.window.window_resize() # You must add this line
|
||||||
while not window_should_close():
|
while not window_should_close():
|
||||||
begin_drawing()
|
begin_drawing()
|
||||||
clear_background(WHITE)
|
clear_background(WHITE)
|
||||||
draw_text("Hello world", 190, 200, 20, VIOLET)
|
draw_text("Hello world", 190, 200, 20, VIOLET)
|
||||||
end_drawing()
|
end_drawing()
|
||||||
await asyncio.sleep(0) # You MUST call this in your main loop
|
await asyncio.sleep(0) # You must call this in your main loop
|
||||||
close_window()
|
close_window()
|
||||||
|
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
||||||
```
|
|
||||||
|
|
||||||
Then to create the web files and launch a web server:
|
Then to create the web files and launch a web server:
|
||||||
|
|
||||||
python3.12 -m pip install --user --upgrade pygbag
|
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
|
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.
|
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/).
|
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
|
# 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)
|
[Tanki](https://github.com/pkulev/tanki)
|
||||||
|
|
||||||
[Alloy Bloxel Editor](https://pebaz.itch.io/alloy-bloxel-editor)
|
[Alloy Bloxel Editor](https://pebaz.itch.io/alloy-bloxel-editor)
|
||||||
|
|
||||||
[Eidolon](https://github.com/Miou-zora/Eidolon)
|
|
||||||
|
|
||||||
Add your app here!
|
Add your app here!
|
||||||
|
|
||||||
# RLZero
|
# 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 --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
|
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 --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']:
|
for e in js['enums']:
|
||||||
if e['name'] and e['values']:
|
if e['name'] and e['values']:
|
||||||
print ("class "+e['name']+"("+"IntEnum):")
|
print ("class "+e['name']+"("+"IntEnum):")
|
||||||
print(f' """{e['description']}."""')
|
|
||||||
for value in e['values']:
|
for value in e['values']:
|
||||||
print(" "+value['name']+" = "+str(value['value']))
|
print(" "+value['name']+" = "+str(value['value']))
|
||||||
print("")
|
print("")
|
||||||
|
@ -35,4 +34,3 @@ print("""from enum import IntEnum
|
||||||
process("raylib.json")
|
process("raylib.json")
|
||||||
process("raygui.json")
|
process("raygui.json")
|
||||||
process("glfw3.json")
|
process("glfw3.json")
|
||||||
process("physac.json")
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from raylib import rl, ffi
|
from raylib import rl, ffi
|
||||||
from pyray import _underscore
|
|
||||||
from inspect import ismethod, getmembers, isbuiltin
|
from inspect import ismethod, getmembers, isbuiltin
|
||||||
import inflection, sys, json
|
import inflection, sys, json
|
||||||
|
|
||||||
|
@ -30,13 +29,6 @@ for filename in (Path("raylib.json"), Path("raymath.json"), Path("rlgl.json"), P
|
||||||
for st in js["structs"]:
|
for st in js["structs"]:
|
||||||
if st["name"] not in known_structs:
|
if st["name"] not in known_structs:
|
||||||
known_structs[st["name"]] = st
|
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']}."""')
|
|
||||||
for value in e['values']:
|
|
||||||
print(" "+value['name']+" = "+str(value['value']))
|
|
||||||
print("")
|
|
||||||
|
|
||||||
|
|
||||||
def ctype_to_python_type(t):
|
def ctype_to_python_type(t):
|
||||||
|
@ -50,47 +42,34 @@ def ctype_to_python_type(t):
|
||||||
return "int"
|
return "int"
|
||||||
elif t == "uint64_t":
|
elif t == "uint64_t":
|
||||||
return "int"
|
return "int"
|
||||||
elif t == "short":
|
|
||||||
return "int"
|
|
||||||
elif t == "unsigned short":
|
|
||||||
return "int"
|
|
||||||
elif t == "double":
|
elif t == "double":
|
||||||
return "float"
|
return "float"
|
||||||
elif "char * *" in t:
|
elif "char * *" in t:
|
||||||
return "list[str]"
|
return "list[str]"
|
||||||
elif "char *" in t:
|
elif "char *" in t:
|
||||||
return "str"
|
return "str"
|
||||||
elif t == "char":
|
elif "char" in t:
|
||||||
return "str" # not sure about this one
|
return "str" # not sure about this one
|
||||||
elif t == "unsigned char":
|
|
||||||
return "int"
|
|
||||||
elif "*" in t:
|
elif "*" in t:
|
||||||
return "Any"
|
return "Any"
|
||||||
elif "[" in t:
|
|
||||||
return "list" # TODO FIXME type of items in the list
|
|
||||||
elif t.startswith("struct"):
|
elif t.startswith("struct"):
|
||||||
return t.replace("struct ", "")
|
return t.replace("struct ", "")
|
||||||
elif t.startswith("unsigned"):
|
elif t.startswith("unsigned"):
|
||||||
return t.replace("unsigned ", "")
|
return t.replace("unsigned ", "")
|
||||||
elif t.startswith("enum"):
|
|
||||||
return t.replace("enum ", "")
|
|
||||||
else:
|
else:
|
||||||
return t
|
return t
|
||||||
|
|
||||||
|
|
||||||
print("""from typing import Any
|
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
|
# 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")
|
reserved_words = ("in", "list", "tuple", "set", "dict", "from", "range", "min", "max", "any", "all", "len")
|
||||||
|
|
||||||
for name, attr in getmembers(rl):
|
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'>":
|
if isbuiltin(attr) or str(type(attr)) == "<class '_cffi_backend.__FFIFunctionWrapper'>":
|
||||||
json_object = known_functions.get(name, None)
|
json_object = known_functions.get(name, None)
|
||||||
if json_object is None:
|
if json_object is None:
|
||||||
|
@ -109,8 +88,6 @@ for name, attr in getmembers(rl):
|
||||||
if param_name in reserved_words:
|
if param_name in reserved_words:
|
||||||
param_name = param_name + "_" + str(i)
|
param_name = param_name + "_" + str(i)
|
||||||
param_type = ctype_to_python_type(arg.cname)
|
param_type = ctype_to_python_type(arg.cname)
|
||||||
if "struct" in arg.cname:
|
|
||||||
param_type += "|list|tuple"
|
|
||||||
sig += f"{param_name}: {param_type},"
|
sig += f"{param_name}: {param_type},"
|
||||||
|
|
||||||
return_type = ffi.typeof(attr).result.cname
|
return_type = ffi.typeof(attr).result.cname
|
||||||
|
@ -120,11 +97,8 @@ for name, attr in getmembers(rl):
|
||||||
if 'description' in json_object:
|
if 'description' in json_object:
|
||||||
description = json_object['description']
|
description = json_object['description']
|
||||||
|
|
||||||
if 'physics' in uname:
|
print(
|
||||||
print('@deprecated("Raylib no longer recommends the use of Physac library")')
|
f'def {uname}({sig}) -> {ctype_to_python_type(return_type)}:\n """{description}"""\n ...')
|
||||||
print(f'def {uname}({sig}) -> {ctype_to_python_type(return_type)}:')
|
|
||||||
print(f' """{description}."""')
|
|
||||||
print(f' ...')
|
|
||||||
|
|
||||||
elif str(type(attr)) == "<class '_cffi_backend._CDataBase'>":
|
elif str(type(attr)) == "<class '_cffi_backend._CDataBase'>":
|
||||||
return_type = ffi.typeof(attr).result.cname
|
return_type = ffi.typeof(attr).result.cname
|
||||||
|
@ -149,17 +123,14 @@ for struct in ffi.list_types()[0]:
|
||||||
print("weird empty struct, skipping " + struct, file=sys.stderr)
|
print("weird empty struct, skipping " + struct, file=sys.stderr)
|
||||||
continue
|
continue
|
||||||
print(f"class {struct}:")
|
print(f"class {struct}:")
|
||||||
print(f' """{known_structs[struct]['description']}."""')
|
print(f' """ struct """')
|
||||||
sig = ""
|
sig = ""
|
||||||
for arg in ffi.typeof(struct).fields:
|
for arg in ffi.typeof(struct).fields:
|
||||||
ptype = ctype_to_python_type(arg[1].type.cname)
|
sig += ", " + arg[0]
|
||||||
if arg[1].type.kind == "struct":
|
|
||||||
ptype += "|list|tuple"
|
|
||||||
sig += f", {arg[0]}: {ptype}|None = None"
|
|
||||||
print(f" def __init__(self{sig}):")
|
print(f" def __init__(self{sig}):")
|
||||||
|
|
||||||
for arg in ffi.typeof(struct).fields:
|
for arg in ffi.typeof(struct).fields:
|
||||||
print(f" self.{arg[0]}:{ctype_to_python_type(arg[1].type.cname)} = {arg[0]} # type: ignore")
|
print(f" self.{arg[0]}={arg[0]}")
|
||||||
|
|
||||||
# elif ffi.typeof(struct).kind == "enum":
|
# elif ffi.typeof(struct).kind == "enum":
|
||||||
# print(f"{struct}: int")
|
# print(f"{struct}: int")
|
||||||
|
|
|
@ -42,39 +42,30 @@ def ctype_to_python_type(t):
|
||||||
return "int"
|
return "int"
|
||||||
elif t == "uint64_t":
|
elif t == "uint64_t":
|
||||||
return "int"
|
return "int"
|
||||||
elif t == "short":
|
|
||||||
return "int"
|
|
||||||
elif t == "unsigned short":
|
|
||||||
return "int"
|
|
||||||
elif t == "double":
|
elif t == "double":
|
||||||
return "float"
|
return "float"
|
||||||
elif "char * *" in t:
|
elif "char * *" in t:
|
||||||
return "list[bytes]"
|
return "list[str]"
|
||||||
elif "char *" in t:
|
elif "char *" in t:
|
||||||
return "bytes"
|
return "str"
|
||||||
elif "char" in t:
|
elif "char" in t:
|
||||||
return "bytes" # not sure about this one
|
return "str" # not sure about this one
|
||||||
elif "*" in t:
|
elif "*" in t:
|
||||||
return "Any"
|
return "Any"
|
||||||
elif "[" in t:
|
|
||||||
return "list" # TODO FIXME type of items in the list
|
|
||||||
elif t.startswith("struct"):
|
elif t.startswith("struct"):
|
||||||
return t.replace("struct ", "")
|
return t.replace("struct ", "")
|
||||||
elif t.startswith("unsigned"):
|
elif t.startswith("unsigned"):
|
||||||
return t.replace("unsigned ", "")
|
return t.replace("unsigned ", "")
|
||||||
elif t.startswith("enum"):
|
|
||||||
return t.replace("enum ", "")
|
|
||||||
else:
|
else:
|
||||||
return t
|
return t
|
||||||
|
|
||||||
|
|
||||||
print("""from typing import Any
|
print("""from typing import Any
|
||||||
from warnings import deprecated
|
|
||||||
import _cffi_backend # type: ignore
|
import _cffi_backend
|
||||||
|
|
||||||
ffi: _cffi_backend.FFI
|
ffi: _cffi_backend.FFI
|
||||||
rl: _cffi_backend.Lib
|
rl: _cffi_backend.Lib
|
||||||
PhysicsShapeType = int
|
|
||||||
|
|
||||||
class struct: ...
|
class struct: ...
|
||||||
|
|
||||||
|
@ -105,8 +96,6 @@ for name, attr in getmembers(rl):
|
||||||
if param_name in reserved_words:
|
if param_name in reserved_words:
|
||||||
param_name = param_name + "_" + str(i)
|
param_name = param_name + "_" + str(i)
|
||||||
param_type = ctype_to_python_type(arg.cname)
|
param_type = ctype_to_python_type(arg.cname)
|
||||||
if "struct" in arg.cname:
|
|
||||||
param_type += "|list|tuple"
|
|
||||||
sig += f"{param_name}: {param_type},"
|
sig += f"{param_name}: {param_type},"
|
||||||
|
|
||||||
return_type = ffi.typeof(attr).result.cname
|
return_type = ffi.typeof(attr).result.cname
|
||||||
|
@ -115,12 +104,8 @@ for name, attr in getmembers(rl):
|
||||||
if 'description' in json_object:
|
if 'description' in json_object:
|
||||||
description = json_object['description']
|
description = json_object['description']
|
||||||
|
|
||||||
if 'Physics' in uname:
|
print(
|
||||||
print('@deprecated("Raylib no longer recommends the use of Physac library")')
|
f'def {uname}({sig}) -> {ctype_to_python_type(return_type)}:\n """{description}"""\n ...')
|
||||||
print(f'def {uname}({sig}) -> {ctype_to_python_type(return_type)}:')
|
|
||||||
print(f' """{description}."""')
|
|
||||||
print(f' ...')
|
|
||||||
|
|
||||||
|
|
||||||
elif str(type(attr)) == "<class '_cffi_backend._CDataBase'>":
|
elif str(type(attr)) == "<class '_cffi_backend._CDataBase'>":
|
||||||
return_type = ffi.typeof(attr).result.cname
|
return_type = ffi.typeof(attr).result.cname
|
||||||
|
@ -136,22 +121,17 @@ for struct in ffi.list_types()[0]:
|
||||||
# if ffi.typeof(struct).fields is None:
|
# if ffi.typeof(struct).fields is None:
|
||||||
# print("weird empty struct, skipping", file=sys.stderr)
|
# print("weird empty struct, skipping", file=sys.stderr)
|
||||||
# continue
|
# continue
|
||||||
print(f"class {struct}:")
|
print(f"{struct}: struct")
|
||||||
# sig = ""
|
# sig = ""
|
||||||
fields = ffi.typeof(struct).fields
|
# for arg in ffi.typeof(struct).fields:
|
||||||
if fields is not None:
|
# sig += ", " + arg[0]
|
||||||
#print(ffi.typeof(struct).fields)
|
|
||||||
#print(f" {arg}: {arg}")
|
|
||||||
# print(f" def __init__(self{sig}):")
|
# print(f" def __init__(self{sig}):")
|
||||||
#
|
#
|
||||||
for arg in ffi.typeof(struct).fields:
|
# for arg in ffi.typeof(struct).fields:
|
||||||
print(f" {arg[0]}: {ctype_to_python_type(arg[1].type.cname)}")
|
|
||||||
else:
|
|
||||||
print(" ...")
|
|
||||||
# print(f" self.{arg[0]}={arg[0]}")
|
# print(f" self.{arg[0]}={arg[0]}")
|
||||||
|
|
||||||
elif ffi.typeof(struct).kind == "enum":
|
elif ffi.typeof(struct).kind == "enum":
|
||||||
print(f"{struct} = int")
|
print(f"{struct}: int")
|
||||||
else:
|
else:
|
||||||
print("WARNING: SKIPPING UNKNOWN TYPE", ffi.typeof(struct), file=sys.stderr)
|
print("WARNING: SKIPPING UNKNOWN TYPE", ffi.typeof(struct), file=sys.stderr)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Sphinx build info version 1
|
# 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.
|
# 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
|
tags: 645f666f9bcd5a90fca523b33c5a78b7
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Building from source — Raylib Python documentation</title>
|
<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/css/theme.css?v=e59714d7" />
|
||||||
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
|
<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">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#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#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#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#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>
|
<li class="toctree-l1"><a class="reference internal" href="README.html#app-showcase">App showcase</a></li>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Python Bindings for Raylib 5.5 — Raylib Python documentation</title>
|
<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/css/theme.css?v=e59714d7" />
|
||||||
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
|
<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-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="#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="#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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li class="toctree-l1"><a class="reference internal" href="#quickstart">Quickstart</a></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="#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="#linux">Linux</a></li>
|
||||||
<li class="toctree-l2"><a class="reference internal" href="#raspberry-pi">Raspberry Pi</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="#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="#sdl-backend">SDL backend</a></li>
|
||||||
<li class="toctree-l2"><a class="reference internal" href="#drm-backend">DRM backend</a></li>
|
<li class="toctree-l2"><a class="reference internal" href="#drm-backend">DRM backend</a></li>
|
||||||
|
@ -120,29 +116,22 @@
|
||||||
</section>
|
</section>
|
||||||
<section id="backends-desktop-sdl-drm-web">
|
<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>
|
<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>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>New CFFI API static bindings.</p>
|
||||||
<p>Features:</p>
|
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li><p>CFFI API static bindings.</p></li>
|
|
||||||
<li><p>Automatically generated to be as close as possible to
|
<li><p>Automatically generated to be as close as possible to
|
||||||
original Raylib.</p></li>
|
original Raylib.</p></li>
|
||||||
<li><p>Faster, fewer bugs and easier to maintain than ctypes.</p></li>
|
<li><p>Faster, fewer bugs and easier to maintain than ctypes.</p></li>
|
||||||
<li><p>Commercial-friendly license.</p></li>
|
<li><p>Commercial-friendly license.</p></li>
|
||||||
<li><p>Docstrings and auto-completion.</p></li>
|
<li><p>Docstrings and auto-completion.</p></li>
|
||||||
<li><p>Type checking with Mypy</p></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
<p><a class="reference external" href="http://electronstudio.github.io/raylib-python-cffi">Full documentation</a></p>
|
<p><a class="reference external" href="http://electronstudio.github.io/raylib-python-cffi">Full documentation</a></p>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
<section id="quickstart">
|
<section id="quickstart">
|
||||||
<h1>Quickstart<a class="headerlink" href="#quickstart" title="Link to this heading"></a></h1>
|
<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>
|
<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="w"> </span><span class="nn">pyray</span><span class="w"> </span><span class="kn">import</span> <span class="o">*</span>
|
<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="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="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">begin_drawing</span><span class="p">()</span>
|
||||||
|
@ -155,18 +144,13 @@ original Raylib.</p></li>
|
||||||
</section>
|
</section>
|
||||||
<section id="installation">
|
<section id="installation">
|
||||||
<h1>Installation<a class="headerlink" href="#installation" title="Link to this heading"></a></h1>
|
<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>
|
<p>First make sure you have the latest pip installed:</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>
|
|
||||||
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>python3 -m pip install --upgrade pip
|
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>python3 -m pip install --upgrade pip
|
||||||
</pre></div>
|
</pre></div>
|
||||||
</div>
|
</div>
|
||||||
<p>Then install</p>
|
<p>Then install</p>
|
||||||
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>python3 -m pip install setuptools
|
<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>
|
</pre></div>
|
||||||
</div>
|
</div>
|
||||||
<p>On most platforms it should install a binary wheel. If yours isn’t available then pip will attempt to build from
|
<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>
|
<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
|
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>brew install pkg-config
|
||||||
brew install raylib
|
brew install raylib
|
||||||
python3 -m pip install raylib==5.5.0.2
|
python3 -m pip install raylib==5.0.0.4
|
||||||
</pre></div>
|
</pre></div>
|
||||||
</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
|
<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>
|
||||||
<section id="raspberry-pi">
|
<section id="raspberry-pi">
|
||||||
<h2>Raspberry Pi<a class="headerlink" href="#raspberry-pi" title="Link to this heading"></a></h2>
|
<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>
|
|
||||||
<section id="backends">
|
|
||||||
<h1>Backends<a class="headerlink" href="#backends" title="Link to this heading"></a></h1>
|
|
||||||
<section id="dynamic-binding-version">
|
<section id="dynamic-binding-version">
|
||||||
<h2>Dynamic binding version<a class="headerlink" href="#dynamic-binding-version" title="Link to this heading"></a></h2>
|
<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>
|
<p>There is now a separate dynamic version of this binding:</p>
|
||||||
|
@ -215,7 +196,6 @@ python3 -m pip install raylib_dynamic
|
||||||
</pre></div>
|
</pre></div>
|
||||||
</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>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>
|
||||||
<section id="sdl-backend">
|
<section id="sdl-backend">
|
||||||
<h2>SDL backend<a class="headerlink" href="#sdl-backend" title="Link to this heading"></a></h2>
|
<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>
|
||||||
<section id="problems">
|
<section id="problems">
|
||||||
<h2>Problems?<a class="headerlink" href="#problems" title="Link to this heading"></a></h2>
|
<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>
|
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>
|
<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>
|
for issues that are not Python-specific.</p>
|
||||||
|
@ -246,8 +226,8 @@ for issues that are not Python-specific.</p>
|
||||||
</section>
|
</section>
|
||||||
<section id="how-to-use">
|
<section id="how-to-use">
|
||||||
<h1>How to use<a class="headerlink" href="#how-to-use" title="Link to this heading"></a></h1>
|
<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
|
<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. 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>
|
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">
|
<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>
|
<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>
|
<p>Use <a class="reference external" href="https://electronstudio.github.io/raylib-python-cffi/raylib.html">the raylib module</a>.</p>
|
||||||
|
@ -259,57 +239,46 @@ pyray. Do <em>not</em> <code class="docutils literal notranslate"><span class="
|
||||||
</section>
|
</section>
|
||||||
<section id="running-in-a-web-browser">
|
<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>
|
<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
|
<p><a class="reference external" href="https://pypi.org/project/pygbag/">Pygbag</a> >=0.8.7 supports running in a web browser.</p>
|
||||||
is recommended.</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>
|
<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>
|
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span># /// script
|
||||||
<span class="c1"># dependencies = [</span>
|
# dependencies = [
|
||||||
<span class="c1"># "cffi",</span>
|
# "cffi",
|
||||||
<span class="c1"># "raylib"</span>
|
# "raylib"
|
||||||
<span class="c1"># ]</span>
|
# ]
|
||||||
<span class="c1"># ///</span>
|
# ///
|
||||||
<span class="kn">import</span><span class="w"> </span><span class="nn">asyncio</span>
|
import asyncio
|
||||||
<span class="kn">import</span><span class="w"> </span><span class="nn">platform</span>
|
import platform
|
||||||
<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>
|
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>
|
async def main(): # You must have an async main function
|
||||||
<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>
|
init_window(500, 500, "Hello")
|
||||||
<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>
|
platform.window.window_resize() # You must add this line
|
||||||
<span class="k">while</span> <span class="ow">not</span> <span class="n">window_should_close</span><span class="p">():</span>
|
while not window_should_close():
|
||||||
<span class="n">begin_drawing</span><span class="p">()</span>
|
begin_drawing()
|
||||||
<span class="n">clear_background</span><span class="p">(</span><span class="n">WHITE</span><span class="p">)</span>
|
clear_background(WHITE)
|
||||||
<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>
|
draw_text("Hello world", 190, 200, 20, VIOLET)
|
||||||
<span class="n">end_drawing</span><span class="p">()</span>
|
end_drawing()
|
||||||
<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>
|
await asyncio.sleep(0) # You must call this in your main loop
|
||||||
<span class="n">close_window</span><span class="p">()</span>
|
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>
|
</pre></div>
|
||||||
</div>
|
</div>
|
||||||
<p>Then to create the web files and launch a web server:</p>
|
<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
|
<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>
|
</pre></div>
|
||||||
</div>
|
</div>
|
||||||
<p>Point your browser to http://localhost:8000</p>
|
<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.
|
<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>
|
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>
|
<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>
|
||||||
<section id="app-showcase">
|
<section id="app-showcase">
|
||||||
<h1>App showcase<a class="headerlink" href="#app-showcase" title="Link to this heading"></a></h1>
|
<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://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://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>
|
<p>Add your app here!</p>
|
||||||
</section>
|
</section>
|
||||||
<section id="rlzero">
|
<section id="rlzero">
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Raspberry Pi — Raylib Python documentation</title>
|
<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/css/theme.css?v=e59714d7" />
|
||||||
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
|
<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">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#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#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#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#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>
|
<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>
|
</div>
|
||||||
<p>Then have pip compile and install the wheel:</p>
|
<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>
|
<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>
|
</pre></div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
@ -158,7 +157,7 @@ For full instructions on this, see <a class="reference external" href="https://g
|
||||||
</div>
|
</div>
|
||||||
<p>Then have pip compile and install the wheel:</p>
|
<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>
|
<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>
|
</pre></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="admonition attention">
|
<div class="admonition attention">
|
||||||
|
|
|
@ -1,30 +1,22 @@
|
||||||
# Python Bindings for Raylib 5.5
|
# Python Bindings for Raylib 5.5
|
||||||
## Libraries: raymath, raygui, rlgl, physac and GLFW
|
## Libraries: raymath, raygui, rlgl, physac and GLFW
|
||||||
## Backends: Desktop, SDL, DRM, Web
|
## Backends: Desktop, SDL, DRM, Web
|
||||||
## Platforms: Windows, Mac, Linux, Raspberry Pi, Web
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Chatroom: [Discord](https://discord.gg/fKDwt85aX6)
|
Chatroom: [Discord](https://discord.gg/fKDwt85aX6)
|
||||||
|
|
||||||
HELP WANTED: [writing examples](https://github.com/electronstudio/raylib-python-cffi/issues/155)
|
New CFFI API static bindings.
|
||||||
|
|
||||||
Features:
|
|
||||||
|
|
||||||
* CFFI API static bindings.
|
|
||||||
* Automatically generated to be as close as possible to
|
* Automatically generated to be as close as possible to
|
||||||
original Raylib.
|
original Raylib.
|
||||||
* Faster, fewer bugs and easier to maintain than ctypes.
|
* Faster, fewer bugs and easier to maintain than ctypes.
|
||||||
* Commercial-friendly license.
|
* Commercial-friendly license.
|
||||||
* Docstrings and auto-completion.
|
* Docstrings and auto-completion.
|
||||||
* Type checking with Mypy
|
|
||||||
|
|
||||||
|
|
||||||
[Full documentation](http://electronstudio.github.io/raylib-python-cffi)
|
[Full documentation](http://electronstudio.github.io/raylib-python-cffi)
|
||||||
|
|
||||||
# Quickstart
|
# Quickstart
|
||||||
|
|
||||||
`pip3 install raylib==5.5.0.2 --break-system-packages`
|
`pip3 install raylib==5.0.0.4`
|
||||||
```python
|
```python
|
||||||
from pyray import *
|
from pyray import *
|
||||||
init_window(800, 450, "Hello")
|
init_window(800, 450, "Hello")
|
||||||
|
@ -38,19 +30,14 @@ close_window()
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
If you are on a modern Linux you will probably want to create a venv:
|
First make sure you have the latest pip installed:
|
||||||
|
|
||||||
python3 -m venv venv
|
|
||||||
source venv/bin/activate
|
|
||||||
|
|
||||||
Then make sure you have the latest pip installed:
|
|
||||||
|
|
||||||
python3 -m pip install --upgrade pip
|
python3 -m pip install --upgrade pip
|
||||||
|
|
||||||
Then install
|
Then install
|
||||||
|
|
||||||
python3 -m pip install setuptools
|
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
|
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.
|
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 pkg-config
|
||||||
brew install raylib
|
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
|
(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.)
|
if you want to test them.)
|
||||||
|
@ -89,8 +76,6 @@ so may not work on other boards.
|
||||||
|
|
||||||
[Using on Rasperry Pi](RPI.rst)
|
[Using on Rasperry Pi](RPI.rst)
|
||||||
|
|
||||||
# Backends
|
|
||||||
|
|
||||||
## Dynamic binding version
|
## Dynamic binding version
|
||||||
|
|
||||||
There is now a separate dynamic version of this binding:
|
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)
|
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
|
## SDL backend
|
||||||
|
|
||||||
This is not well tested but has better support for controllers:
|
This is not well tested but has better support for controllers:
|
||||||
|
@ -133,8 +116,8 @@ If it still doesn't work, [submit an issue](https://github.com/electronstudio/ra
|
||||||
|
|
||||||
# How to use
|
# How to use
|
||||||
|
|
||||||
There are *two* modules in the raylib package, `raylib` and `pyray`. (There is no separate package for
|
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:
|
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
|
### If you are familiar with C coding and the Raylib C library and you want to use an exact copy of the C API
|
||||||
|
|
||||||
|
@ -146,12 +129,10 @@ Use [the pyray module](https://electronstudio.github.io/raylib-python-cffi/pyray
|
||||||
|
|
||||||
# Running in a web browser
|
# 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
|
[Pygbag](https://pypi.org/project/pygbag/) >=0.8.7 supports running in a web browser.
|
||||||
is recommended.
|
|
||||||
|
|
||||||
Make a folder `my_project` with a file `main.py`:
|
Make a folder `my_project` with a file `main.py`:
|
||||||
|
|
||||||
```python
|
|
||||||
# /// script
|
# /// script
|
||||||
# dependencies = [
|
# dependencies = [
|
||||||
# "cffi",
|
# "cffi",
|
||||||
|
@ -162,34 +143,26 @@ import asyncio
|
||||||
import platform
|
import platform
|
||||||
from pyray import *
|
from pyray import *
|
||||||
|
|
||||||
async def main(): # You MUST have an async main function
|
async def main(): # You must have an async main function
|
||||||
init_window(500, 500, "Hello")
|
init_window(500, 500, "Hello")
|
||||||
platform.window.window_resize() # You MAY want to add this line
|
platform.window.window_resize() # You must add this line
|
||||||
while not window_should_close():
|
while not window_should_close():
|
||||||
begin_drawing()
|
begin_drawing()
|
||||||
clear_background(WHITE)
|
clear_background(WHITE)
|
||||||
draw_text("Hello world", 190, 200, 20, VIOLET)
|
draw_text("Hello world", 190, 200, 20, VIOLET)
|
||||||
end_drawing()
|
end_drawing()
|
||||||
await asyncio.sleep(0) # You MUST call this in your main loop
|
await asyncio.sleep(0) # You must call this in your main loop
|
||||||
close_window()
|
close_window()
|
||||||
|
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
||||||
```
|
|
||||||
|
|
||||||
Then to create the web files and launch a web server:
|
Then to create the web files and launch a web server:
|
||||||
|
|
||||||
python3.12 -m pip install --user --upgrade pygbag
|
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
|
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.
|
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/).
|
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
|
# 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)
|
[Tanki](https://github.com/pkulev/tanki)
|
||||||
|
|
||||||
[Alloy Bloxel Editor](https://pebaz.itch.io/alloy-bloxel-editor)
|
[Alloy Bloxel Editor](https://pebaz.itch.io/alloy-bloxel-editor)
|
||||||
|
|
||||||
[Eidolon](https://github.com/Miou-zora/Eidolon)
|
|
||||||
|
|
||||||
Add your app here!
|
Add your app here!
|
||||||
|
|
||||||
# RLZero
|
# 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 --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
|
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 --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;
|
cursor: help;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.translated {
|
||||||
|
background-color: rgba(207, 255, 207, 0.2)
|
||||||
|
}
|
||||||
|
|
||||||
|
.untranslated {
|
||||||
|
background-color: rgba(255, 207, 207, 0.2)
|
||||||
|
}
|
||||||
|
|
||||||
/* -- code displays --------------------------------------------------------- */
|
/* -- code displays --------------------------------------------------------- */
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
|
|
10
docs/_static/js/versions.js
vendored
10
docs/_static/js/versions.js
vendored
|
@ -1,6 +1,6 @@
|
||||||
const themeFlyoutDisplay = "hidden";
|
const themeFlyoutDisplay = "hidden";
|
||||||
const themeVersionSelector = true;
|
const themeVersionSelector = "True";
|
||||||
const themeLanguageSelector = true;
|
const themeLanguageSelector = "True";
|
||||||
|
|
||||||
if (themeFlyoutDisplay === "attached") {
|
if (themeFlyoutDisplay === "attached") {
|
||||||
function renderLanguages(config) {
|
function renderLanguages(config) {
|
||||||
|
@ -8,14 +8,10 @@ if (themeFlyoutDisplay === "attached") {
|
||||||
return "";
|
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 = `
|
const languagesHTML = `
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Languages</dt>
|
<dt>Languages</dt>
|
||||||
${languages
|
${config.projects.translations
|
||||||
.map(
|
.map(
|
||||||
(translation) => `
|
(translation) => `
|
||||||
<dd ${translation.slug == config.projects.current.slug ? 'class="rtd-current-item"' : ""}>
|
<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 .hll { background-color: #ffffcc }
|
||||||
.highlight { background: #eeffcc; }
|
.highlight { background: #eeffcc; }
|
||||||
.highlight .c { color: #408090; font-style: italic } /* Comment */
|
.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 .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 .ch { color: #408090; font-style: italic } /* Comment.Hashbang */
|
||||||
.highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */
|
.highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */
|
||||||
.highlight .cp { color: #007020 } /* Comment.Preproc */
|
.highlight .cp { color: #007020 } /* Comment.Preproc */
|
||||||
.highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile */
|
.highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile */
|
||||||
.highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */
|
.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 .gd { color: #A00000 } /* Generic.Deleted */
|
||||||
.highlight .ge { font-style: italic } /* Generic.Emph */
|
.highlight .ge { font-style: italic } /* Generic.Emph */
|
||||||
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
|
.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 .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
||||||
.highlight .gi { color: #00A000 } /* Generic.Inserted */
|
.highlight .gi { color: #00A000 } /* Generic.Inserted */
|
||||||
.highlight .go { color: #333 } /* Generic.Output */
|
.highlight .go { color: #333333 } /* Generic.Output */
|
||||||
.highlight .gp { color: #C65D09; font-weight: bold } /* Generic.Prompt */
|
.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
|
||||||
.highlight .gs { font-weight: bold } /* Generic.Strong */
|
.highlight .gs { font-weight: bold } /* Generic.Strong */
|
||||||
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
.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 .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
|
||||||
.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
|
.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
|
||||||
.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
|
.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 .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
|
||||||
.highlight .kt { color: #902000 } /* Keyword.Type */
|
.highlight .kt { color: #902000 } /* Keyword.Type */
|
||||||
.highlight .m { color: #208050 } /* Literal.Number */
|
.highlight .m { color: #208050 } /* Literal.Number */
|
||||||
.highlight .s { color: #4070A0 } /* Literal.String */
|
.highlight .s { color: #4070a0 } /* Literal.String */
|
||||||
.highlight .na { color: #4070A0 } /* Name.Attribute */
|
.highlight .na { color: #4070a0 } /* Name.Attribute */
|
||||||
.highlight .nb { color: #007020 } /* Name.Builtin */
|
.highlight .nb { color: #007020 } /* Name.Builtin */
|
||||||
.highlight .nc { color: #0E84B5; font-weight: bold } /* Name.Class */
|
.highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
|
||||||
.highlight .no { color: #60ADD5 } /* Name.Constant */
|
.highlight .no { color: #60add5 } /* Name.Constant */
|
||||||
.highlight .nd { color: #555; font-weight: bold } /* Name.Decorator */
|
.highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */
|
||||||
.highlight .ni { color: #D55537; font-weight: bold } /* Name.Entity */
|
.highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */
|
||||||
.highlight .ne { color: #007020 } /* Name.Exception */
|
.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 .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 .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 .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 .mb { color: #208050 } /* Literal.Number.Bin */
|
||||||
.highlight .mf { color: #208050 } /* Literal.Number.Float */
|
.highlight .mf { color: #208050 } /* Literal.Number.Float */
|
||||||
.highlight .mh { color: #208050 } /* Literal.Number.Hex */
|
.highlight .mh { color: #208050 } /* Literal.Number.Hex */
|
||||||
.highlight .mi { color: #208050 } /* Literal.Number.Integer */
|
.highlight .mi { color: #208050 } /* Literal.Number.Integer */
|
||||||
.highlight .mo { color: #208050 } /* Literal.Number.Oct */
|
.highlight .mo { color: #208050 } /* Literal.Number.Oct */
|
||||||
.highlight .sa { color: #4070A0 } /* Literal.String.Affix */
|
.highlight .sa { color: #4070a0 } /* Literal.String.Affix */
|
||||||
.highlight .sb { color: #4070A0 } /* Literal.String.Backtick */
|
.highlight .sb { color: #4070a0 } /* Literal.String.Backtick */
|
||||||
.highlight .sc { color: #4070A0 } /* Literal.String.Char */
|
.highlight .sc { color: #4070a0 } /* Literal.String.Char */
|
||||||
.highlight .dl { color: #4070A0 } /* Literal.String.Delimiter */
|
.highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */
|
||||||
.highlight .sd { color: #4070A0; font-style: italic } /* Literal.String.Doc */
|
.highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
|
||||||
.highlight .s2 { color: #4070A0 } /* Literal.String.Double */
|
.highlight .s2 { color: #4070a0 } /* Literal.String.Double */
|
||||||
.highlight .se { color: #4070A0; font-weight: bold } /* Literal.String.Escape */
|
.highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
|
||||||
.highlight .sh { color: #4070A0 } /* Literal.String.Heredoc */
|
.highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */
|
||||||
.highlight .si { color: #70A0D0; font-style: italic } /* Literal.String.Interpol */
|
.highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
|
||||||
.highlight .sx { color: #C65D09 } /* Literal.String.Other */
|
.highlight .sx { color: #c65d09 } /* Literal.String.Other */
|
||||||
.highlight .sr { color: #235388 } /* Literal.String.Regex */
|
.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 .ss { color: #517918 } /* Literal.String.Symbol */
|
||||||
.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */
|
.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */
|
||||||
.highlight .fm { color: #06287E } /* Name.Function.Magic */
|
.highlight .fm { color: #06287e } /* Name.Function.Magic */
|
||||||
.highlight .vc { color: #BB60D5 } /* Name.Variable.Class */
|
.highlight .vc { color: #bb60d5 } /* Name.Variable.Class */
|
||||||
.highlight .vg { color: #BB60D5 } /* Name.Variable.Global */
|
.highlight .vg { color: #bb60d5 } /* Name.Variable.Global */
|
||||||
.highlight .vi { color: #BB60D5 } /* Name.Variable.Instance */
|
.highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */
|
||||||
.highlight .vm { color: #BB60D5 } /* Name.Variable.Magic */
|
.highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */
|
||||||
.highlight .il { color: #208050 } /* Literal.Number.Integer.Long */
|
.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
|
// perform the search on the required terms
|
||||||
searchTerms.forEach((word) => {
|
searchTerms.forEach((word) => {
|
||||||
const files = [];
|
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 = [
|
const arr = [
|
||||||
{ files: terms.hasOwnProperty(word) ? terms[word] : undefined, score: Scorer.term },
|
{ files: terms[word], score: Scorer.term },
|
||||||
{ files: titleTerms.hasOwnProperty(word) ? titleTerms[word] : undefined, score: Scorer.title },
|
{ files: titleTerms[word], score: Scorer.title },
|
||||||
];
|
];
|
||||||
// add support for partial matches
|
// add support for partial matches
|
||||||
if (word.length > 2) {
|
if (word.length > 2) {
|
||||||
|
@ -549,9 +547,8 @@ const Search = {
|
||||||
|
|
||||||
// set score for the word in each file
|
// set score for the word in each file
|
||||||
recordFiles.forEach((file) => {
|
recordFiles.forEach((file) => {
|
||||||
if (!scoreMap.has(file)) scoreMap.set(file, new Map());
|
if (!scoreMap.has(file)) scoreMap.set(file, {});
|
||||||
const fileScores = scoreMap.get(file);
|
scoreMap.get(file)[word] = record.score;
|
||||||
fileScores.set(word, record.score);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -590,7 +587,7 @@ const Search = {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// select one (max) score for the file.
|
// 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
|
// add result to the result list
|
||||||
results.push([
|
results.push([
|
||||||
docNames[file],
|
docNames[file],
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Dynamic Bindings — Raylib Python documentation</title>
|
<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/css/theme.css?v=e59714d7" />
|
||||||
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
|
<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">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#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#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#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#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>
|
<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>
|
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>
|
</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>
|
<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>
|
</pre></div>
|
||||||
</div>
|
</div>
|
||||||
<p>Instead you have to do:</p>
|
<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>
|
</pre></div>
|
||||||
</div>
|
</div>
|
||||||
<p>Then you access the functions with <code class="docutils literal notranslate"><span class="pre">rl.</span></code> prefix.</p>
|
<p>Then you access the functions with <code class="docutils literal notranslate"><span class="pre">rl.</span></code> prefix.</p>
|
||||||
|
|
1579
docs/genindex.html
1579
docs/genindex.html
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Raylib Python — Raylib Python documentation</title>
|
<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/css/theme.css?v=e59714d7" />
|
||||||
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
|
<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">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#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#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#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#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>
|
<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">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#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#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#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#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>
|
<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 charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Python Module Index — Raylib Python documentation</title>
|
<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/css/theme.css?v=e59714d7" />
|
||||||
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
|
<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">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#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#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#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#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>
|
<li class="toctree-l1"><a class="reference internal" href="README.html#app-showcase">App showcase</a></li>
|
||||||
|
|
5271
docs/pyray.html
5271
docs/pyray.html
File diff suppressed because one or more lines are too long
6420
docs/raylib.html
6420
docs/raylib.html
File diff suppressed because one or more lines are too long
|
@ -6,7 +6,7 @@
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Search — Raylib Python documentation</title>
|
<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/css/theme.css?v=e59714d7" />
|
||||||
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=4ae1632d" />
|
<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">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#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#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#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#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>
|
<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
|
@ -9,5 +9,3 @@ include version.py
|
||||||
exclude raylib/*.a
|
exclude raylib/*.a
|
||||||
exclude raylib/*.c
|
exclude raylib/*.c
|
||||||
exclude raylib/*.o
|
exclude raylib/*.o
|
||||||
include raylib/py.typed
|
|
||||||
include pyray/py.typed
|
|
|
@ -22,10 +22,9 @@ import itertools
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import platform
|
import platform
|
||||||
import logging
|
|
||||||
from .version import __version__
|
from .version import __version__
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
MODULE = pathlib.Path(__file__).parent
|
MODULE = pathlib.Path(__file__).parent
|
||||||
|
|
||||||
def raylib_library_path():
|
def raylib_library_path():
|
||||||
|
@ -55,9 +54,9 @@ ffi.cdef(open(MODULE / "raylib_modified.h").read().replace('RLAPI ', ''))
|
||||||
try:
|
try:
|
||||||
raylib_fname = raylib_library_path()
|
raylib_fname = raylib_library_path()
|
||||||
rl = ffi.dlopen(raylib_fname)
|
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:
|
except Exception as e:
|
||||||
logger.exception(e)
|
print(e)
|
||||||
|
|
||||||
LIGHTGRAY =( 200, 200, 200, 255 )
|
LIGHTGRAY =( 200, 200, 200, 255 )
|
||||||
GRAY =( 130, 130, 130, 255 )
|
GRAY =( 130, 130, 130, 255 )
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@ import raylib
|
||||||
RAYLIB_VERSION_MAJOR: int = 5
|
RAYLIB_VERSION_MAJOR: int = 5
|
||||||
RAYLIB_VERSION_MINOR: int = 5
|
RAYLIB_VERSION_MINOR: int = 5
|
||||||
RAYLIB_VERSION_PATCH: int = 0
|
RAYLIB_VERSION_PATCH: int = 0
|
||||||
RAYLIB_VERSION: str = "5.5"
|
RAYLIB_VERSION: str = "5.5-dev"
|
||||||
PI: float = 3.141592653589793
|
PI: float = 3.141592653589793
|
||||||
DEG2RAD = PI / 180.0
|
DEG2RAD = PI / 180.0
|
||||||
RAD2DEG = 180.0 / PI
|
RAD2DEG = 180.0 / PI
|
||||||
|
@ -14,7 +14,10 @@ MATERIAL_MAP_DIFFUSE = raylib.MATERIAL_MAP_ALBEDO
|
||||||
MATERIAL_MAP_SPECULAR = raylib.MATERIAL_MAP_METALNESS
|
MATERIAL_MAP_SPECULAR = raylib.MATERIAL_MAP_METALNESS
|
||||||
SHADER_LOC_MAP_DIFFUSE = raylib.SHADER_LOC_MAP_ALBEDO
|
SHADER_LOC_MAP_DIFFUSE = raylib.SHADER_LOC_MAP_ALBEDO
|
||||||
SHADER_LOC_MAP_SPECULAR = raylib.SHADER_LOC_MAP_METALNESS
|
SHADER_LOC_MAP_SPECULAR = raylib.SHADER_LOC_MAP_METALNESS
|
||||||
|
PI: float = 3.141592653589793
|
||||||
EPSILON: float = 1e-06
|
EPSILON: float = 1e-06
|
||||||
|
DEG2RAD = PI / 180.0
|
||||||
|
RAD2DEG = 180.0 / PI
|
||||||
RLGL_VERSION: str = "5.0"
|
RLGL_VERSION: str = "5.0"
|
||||||
RL_DEFAULT_BATCH_BUFFER_ELEMENTS: int = 8192
|
RL_DEFAULT_BATCH_BUFFER_ELEMENTS: int = 8192
|
||||||
RL_DEFAULT_BATCH_BUFFERS: int = 1
|
RL_DEFAULT_BATCH_BUFFERS: int = 1
|
||||||
|
@ -99,6 +102,9 @@ RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS: int = 7
|
||||||
RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS: int = 8
|
RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS: int = 8
|
||||||
RL_SHADER_LOC_MAP_DIFFUSE = raylib.RL_SHADER_LOC_MAP_ALBEDO
|
RL_SHADER_LOC_MAP_DIFFUSE = raylib.RL_SHADER_LOC_MAP_ALBEDO
|
||||||
RL_SHADER_LOC_MAP_SPECULAR = raylib.RL_SHADER_LOC_MAP_METALNESS
|
RL_SHADER_LOC_MAP_SPECULAR = raylib.RL_SHADER_LOC_MAP_METALNESS
|
||||||
|
PI: float = 3.141592653589793
|
||||||
|
DEG2RAD = PI / 180.0
|
||||||
|
RAD2DEG = 180.0 / PI
|
||||||
GL_SHADING_LANGUAGE_VERSION: int = 35724
|
GL_SHADING_LANGUAGE_VERSION: int = 35724
|
||||||
GL_COMPRESSED_RGB_S3TC_DXT1_EXT: int = 33776
|
GL_COMPRESSED_RGB_S3TC_DXT1_EXT: int = 33776
|
||||||
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: int = 33777
|
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: int = 33777
|
||||||
|
@ -186,10 +192,12 @@ RAYGUI_TEXTFORMAT_MAX_SIZE: int = 256
|
||||||
PHYSAC_MAX_BODIES: int = 64
|
PHYSAC_MAX_BODIES: int = 64
|
||||||
PHYSAC_MAX_MANIFOLDS: int = 4096
|
PHYSAC_MAX_MANIFOLDS: int = 4096
|
||||||
PHYSAC_MAX_VERTICES: int = 24
|
PHYSAC_MAX_VERTICES: int = 24
|
||||||
PHYSAC_CIRCLE_VERTICES: int = 24
|
PHYSAC_DEFAULT_CIRCLE_VERTICES: int = 24
|
||||||
PHYSAC_COLLISION_ITERATIONS: int = 20
|
PHYSAC_COLLISION_ITERATIONS: int = 100
|
||||||
PHYSAC_PENETRATION_ALLOWANCE: float = 0.05
|
PHYSAC_PENETRATION_ALLOWANCE: float = 0.05
|
||||||
PHYSAC_PENETRATION_CORRECTION: float = 0.4
|
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_FLT_MAX: float = 3.402823466e+38
|
||||||
PHYSAC_EPSILON: float = 1e-06
|
PHYSAC_EPSILON: float = 1e-06
|
||||||
GLFW_VERSION_MAJOR: int = 3
|
GLFW_VERSION_MAJOR: int = 3
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
|
|
||||||
class ConfigFlags(IntEnum):
|
class ConfigFlags(IntEnum):
|
||||||
"""System/Window config flags."""
|
|
||||||
FLAG_VSYNC_HINT = 64
|
FLAG_VSYNC_HINT = 64
|
||||||
FLAG_FULLSCREEN_MODE = 2
|
FLAG_FULLSCREEN_MODE = 2
|
||||||
FLAG_WINDOW_RESIZABLE = 4
|
FLAG_WINDOW_RESIZABLE = 4
|
||||||
|
@ -20,7 +19,6 @@ class ConfigFlags(IntEnum):
|
||||||
FLAG_INTERLACED_HINT = 65536
|
FLAG_INTERLACED_HINT = 65536
|
||||||
|
|
||||||
class TraceLogLevel(IntEnum):
|
class TraceLogLevel(IntEnum):
|
||||||
"""Trace log level."""
|
|
||||||
LOG_ALL = 0
|
LOG_ALL = 0
|
||||||
LOG_TRACE = 1
|
LOG_TRACE = 1
|
||||||
LOG_DEBUG = 2
|
LOG_DEBUG = 2
|
||||||
|
@ -31,7 +29,6 @@ class TraceLogLevel(IntEnum):
|
||||||
LOG_NONE = 7
|
LOG_NONE = 7
|
||||||
|
|
||||||
class KeyboardKey(IntEnum):
|
class KeyboardKey(IntEnum):
|
||||||
"""Keyboard keys (US keyboard layout)."""
|
|
||||||
KEY_NULL = 0
|
KEY_NULL = 0
|
||||||
KEY_APOSTROPHE = 39
|
KEY_APOSTROPHE = 39
|
||||||
KEY_COMMA = 44
|
KEY_COMMA = 44
|
||||||
|
@ -144,7 +141,6 @@ class KeyboardKey(IntEnum):
|
||||||
KEY_VOLUME_DOWN = 25
|
KEY_VOLUME_DOWN = 25
|
||||||
|
|
||||||
class MouseButton(IntEnum):
|
class MouseButton(IntEnum):
|
||||||
"""Mouse buttons."""
|
|
||||||
MOUSE_BUTTON_LEFT = 0
|
MOUSE_BUTTON_LEFT = 0
|
||||||
MOUSE_BUTTON_RIGHT = 1
|
MOUSE_BUTTON_RIGHT = 1
|
||||||
MOUSE_BUTTON_MIDDLE = 2
|
MOUSE_BUTTON_MIDDLE = 2
|
||||||
|
@ -154,7 +150,6 @@ class MouseButton(IntEnum):
|
||||||
MOUSE_BUTTON_BACK = 6
|
MOUSE_BUTTON_BACK = 6
|
||||||
|
|
||||||
class MouseCursor(IntEnum):
|
class MouseCursor(IntEnum):
|
||||||
"""Mouse cursor."""
|
|
||||||
MOUSE_CURSOR_DEFAULT = 0
|
MOUSE_CURSOR_DEFAULT = 0
|
||||||
MOUSE_CURSOR_ARROW = 1
|
MOUSE_CURSOR_ARROW = 1
|
||||||
MOUSE_CURSOR_IBEAM = 2
|
MOUSE_CURSOR_IBEAM = 2
|
||||||
|
@ -168,7 +163,6 @@ class MouseCursor(IntEnum):
|
||||||
MOUSE_CURSOR_NOT_ALLOWED = 10
|
MOUSE_CURSOR_NOT_ALLOWED = 10
|
||||||
|
|
||||||
class GamepadButton(IntEnum):
|
class GamepadButton(IntEnum):
|
||||||
"""Gamepad buttons."""
|
|
||||||
GAMEPAD_BUTTON_UNKNOWN = 0
|
GAMEPAD_BUTTON_UNKNOWN = 0
|
||||||
GAMEPAD_BUTTON_LEFT_FACE_UP = 1
|
GAMEPAD_BUTTON_LEFT_FACE_UP = 1
|
||||||
GAMEPAD_BUTTON_LEFT_FACE_RIGHT = 2
|
GAMEPAD_BUTTON_LEFT_FACE_RIGHT = 2
|
||||||
|
@ -189,7 +183,6 @@ class GamepadButton(IntEnum):
|
||||||
GAMEPAD_BUTTON_RIGHT_THUMB = 17
|
GAMEPAD_BUTTON_RIGHT_THUMB = 17
|
||||||
|
|
||||||
class GamepadAxis(IntEnum):
|
class GamepadAxis(IntEnum):
|
||||||
"""Gamepad axis."""
|
|
||||||
GAMEPAD_AXIS_LEFT_X = 0
|
GAMEPAD_AXIS_LEFT_X = 0
|
||||||
GAMEPAD_AXIS_LEFT_Y = 1
|
GAMEPAD_AXIS_LEFT_Y = 1
|
||||||
GAMEPAD_AXIS_RIGHT_X = 2
|
GAMEPAD_AXIS_RIGHT_X = 2
|
||||||
|
@ -198,7 +191,6 @@ class GamepadAxis(IntEnum):
|
||||||
GAMEPAD_AXIS_RIGHT_TRIGGER = 5
|
GAMEPAD_AXIS_RIGHT_TRIGGER = 5
|
||||||
|
|
||||||
class MaterialMapIndex(IntEnum):
|
class MaterialMapIndex(IntEnum):
|
||||||
"""Material map index."""
|
|
||||||
MATERIAL_MAP_ALBEDO = 0
|
MATERIAL_MAP_ALBEDO = 0
|
||||||
MATERIAL_MAP_METALNESS = 1
|
MATERIAL_MAP_METALNESS = 1
|
||||||
MATERIAL_MAP_NORMAL = 2
|
MATERIAL_MAP_NORMAL = 2
|
||||||
|
@ -212,7 +204,6 @@ class MaterialMapIndex(IntEnum):
|
||||||
MATERIAL_MAP_BRDF = 10
|
MATERIAL_MAP_BRDF = 10
|
||||||
|
|
||||||
class ShaderLocationIndex(IntEnum):
|
class ShaderLocationIndex(IntEnum):
|
||||||
"""Shader location index."""
|
|
||||||
SHADER_LOC_VERTEX_POSITION = 0
|
SHADER_LOC_VERTEX_POSITION = 0
|
||||||
SHADER_LOC_VERTEX_TEXCOORD01 = 1
|
SHADER_LOC_VERTEX_TEXCOORD01 = 1
|
||||||
SHADER_LOC_VERTEX_TEXCOORD02 = 2
|
SHADER_LOC_VERTEX_TEXCOORD02 = 2
|
||||||
|
@ -244,7 +235,6 @@ class ShaderLocationIndex(IntEnum):
|
||||||
SHADER_LOC_BONE_MATRICES = 28
|
SHADER_LOC_BONE_MATRICES = 28
|
||||||
|
|
||||||
class ShaderUniformDataType(IntEnum):
|
class ShaderUniformDataType(IntEnum):
|
||||||
"""Shader uniform data type."""
|
|
||||||
SHADER_UNIFORM_FLOAT = 0
|
SHADER_UNIFORM_FLOAT = 0
|
||||||
SHADER_UNIFORM_VEC2 = 1
|
SHADER_UNIFORM_VEC2 = 1
|
||||||
SHADER_UNIFORM_VEC3 = 2
|
SHADER_UNIFORM_VEC3 = 2
|
||||||
|
@ -256,14 +246,12 @@ class ShaderUniformDataType(IntEnum):
|
||||||
SHADER_UNIFORM_SAMPLER2D = 8
|
SHADER_UNIFORM_SAMPLER2D = 8
|
||||||
|
|
||||||
class ShaderAttributeDataType(IntEnum):
|
class ShaderAttributeDataType(IntEnum):
|
||||||
"""Shader attribute data types."""
|
|
||||||
SHADER_ATTRIB_FLOAT = 0
|
SHADER_ATTRIB_FLOAT = 0
|
||||||
SHADER_ATTRIB_VEC2 = 1
|
SHADER_ATTRIB_VEC2 = 1
|
||||||
SHADER_ATTRIB_VEC3 = 2
|
SHADER_ATTRIB_VEC3 = 2
|
||||||
SHADER_ATTRIB_VEC4 = 3
|
SHADER_ATTRIB_VEC4 = 3
|
||||||
|
|
||||||
class PixelFormat(IntEnum):
|
class PixelFormat(IntEnum):
|
||||||
"""Pixel formats."""
|
|
||||||
PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1
|
PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1
|
||||||
PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA = 2
|
PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA = 2
|
||||||
PIXELFORMAT_UNCOMPRESSED_R5G6B5 = 3
|
PIXELFORMAT_UNCOMPRESSED_R5G6B5 = 3
|
||||||
|
@ -290,7 +278,6 @@ class PixelFormat(IntEnum):
|
||||||
PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA = 24
|
PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA = 24
|
||||||
|
|
||||||
class TextureFilter(IntEnum):
|
class TextureFilter(IntEnum):
|
||||||
"""Texture parameters: filter mode."""
|
|
||||||
TEXTURE_FILTER_POINT = 0
|
TEXTURE_FILTER_POINT = 0
|
||||||
TEXTURE_FILTER_BILINEAR = 1
|
TEXTURE_FILTER_BILINEAR = 1
|
||||||
TEXTURE_FILTER_TRILINEAR = 2
|
TEXTURE_FILTER_TRILINEAR = 2
|
||||||
|
@ -299,28 +286,25 @@ class TextureFilter(IntEnum):
|
||||||
TEXTURE_FILTER_ANISOTROPIC_16X = 5
|
TEXTURE_FILTER_ANISOTROPIC_16X = 5
|
||||||
|
|
||||||
class TextureWrap(IntEnum):
|
class TextureWrap(IntEnum):
|
||||||
"""Texture parameters: wrap mode."""
|
|
||||||
TEXTURE_WRAP_REPEAT = 0
|
TEXTURE_WRAP_REPEAT = 0
|
||||||
TEXTURE_WRAP_CLAMP = 1
|
TEXTURE_WRAP_CLAMP = 1
|
||||||
TEXTURE_WRAP_MIRROR_REPEAT = 2
|
TEXTURE_WRAP_MIRROR_REPEAT = 2
|
||||||
TEXTURE_WRAP_MIRROR_CLAMP = 3
|
TEXTURE_WRAP_MIRROR_CLAMP = 3
|
||||||
|
|
||||||
class CubemapLayout(IntEnum):
|
class CubemapLayout(IntEnum):
|
||||||
"""Cubemap layouts."""
|
|
||||||
CUBEMAP_LAYOUT_AUTO_DETECT = 0
|
CUBEMAP_LAYOUT_AUTO_DETECT = 0
|
||||||
CUBEMAP_LAYOUT_LINE_VERTICAL = 1
|
CUBEMAP_LAYOUT_LINE_VERTICAL = 1
|
||||||
CUBEMAP_LAYOUT_LINE_HORIZONTAL = 2
|
CUBEMAP_LAYOUT_LINE_HORIZONTAL = 2
|
||||||
CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR = 3
|
CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR = 3
|
||||||
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE = 4
|
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE = 4
|
||||||
|
CUBEMAP_LAYOUT_PANORAMA = 5
|
||||||
|
|
||||||
class FontType(IntEnum):
|
class FontType(IntEnum):
|
||||||
"""Font type, defines generation method."""
|
|
||||||
FONT_DEFAULT = 0
|
FONT_DEFAULT = 0
|
||||||
FONT_BITMAP = 1
|
FONT_BITMAP = 1
|
||||||
FONT_SDF = 2
|
FONT_SDF = 2
|
||||||
|
|
||||||
class BlendMode(IntEnum):
|
class BlendMode(IntEnum):
|
||||||
"""Color blending modes (pre-defined)."""
|
|
||||||
BLEND_ALPHA = 0
|
BLEND_ALPHA = 0
|
||||||
BLEND_ADDITIVE = 1
|
BLEND_ADDITIVE = 1
|
||||||
BLEND_MULTIPLIED = 2
|
BLEND_MULTIPLIED = 2
|
||||||
|
@ -331,7 +315,6 @@ class BlendMode(IntEnum):
|
||||||
BLEND_CUSTOM_SEPARATE = 7
|
BLEND_CUSTOM_SEPARATE = 7
|
||||||
|
|
||||||
class Gesture(IntEnum):
|
class Gesture(IntEnum):
|
||||||
"""Gesture."""
|
|
||||||
GESTURE_NONE = 0
|
GESTURE_NONE = 0
|
||||||
GESTURE_TAP = 1
|
GESTURE_TAP = 1
|
||||||
GESTURE_DOUBLETAP = 2
|
GESTURE_DOUBLETAP = 2
|
||||||
|
@ -345,7 +328,6 @@ class Gesture(IntEnum):
|
||||||
GESTURE_PINCH_OUT = 512
|
GESTURE_PINCH_OUT = 512
|
||||||
|
|
||||||
class CameraMode(IntEnum):
|
class CameraMode(IntEnum):
|
||||||
"""Camera system modes."""
|
|
||||||
CAMERA_CUSTOM = 0
|
CAMERA_CUSTOM = 0
|
||||||
CAMERA_FREE = 1
|
CAMERA_FREE = 1
|
||||||
CAMERA_ORBITAL = 2
|
CAMERA_ORBITAL = 2
|
||||||
|
@ -353,43 +335,36 @@ class CameraMode(IntEnum):
|
||||||
CAMERA_THIRD_PERSON = 4
|
CAMERA_THIRD_PERSON = 4
|
||||||
|
|
||||||
class CameraProjection(IntEnum):
|
class CameraProjection(IntEnum):
|
||||||
"""Camera projection."""
|
|
||||||
CAMERA_PERSPECTIVE = 0
|
CAMERA_PERSPECTIVE = 0
|
||||||
CAMERA_ORTHOGRAPHIC = 1
|
CAMERA_ORTHOGRAPHIC = 1
|
||||||
|
|
||||||
class NPatchLayout(IntEnum):
|
class NPatchLayout(IntEnum):
|
||||||
"""N-patch layout."""
|
|
||||||
NPATCH_NINE_PATCH = 0
|
NPATCH_NINE_PATCH = 0
|
||||||
NPATCH_THREE_PATCH_VERTICAL = 1
|
NPATCH_THREE_PATCH_VERTICAL = 1
|
||||||
NPATCH_THREE_PATCH_HORIZONTAL = 2
|
NPATCH_THREE_PATCH_HORIZONTAL = 2
|
||||||
|
|
||||||
class GuiState(IntEnum):
|
class GuiState(IntEnum):
|
||||||
"""Gui control state."""
|
|
||||||
STATE_NORMAL = 0
|
STATE_NORMAL = 0
|
||||||
STATE_FOCUSED = 1
|
STATE_FOCUSED = 1
|
||||||
STATE_PRESSED = 2
|
STATE_PRESSED = 2
|
||||||
STATE_DISABLED = 3
|
STATE_DISABLED = 3
|
||||||
|
|
||||||
class GuiTextAlignment(IntEnum):
|
class GuiTextAlignment(IntEnum):
|
||||||
"""Gui control text alignment."""
|
|
||||||
TEXT_ALIGN_LEFT = 0
|
TEXT_ALIGN_LEFT = 0
|
||||||
TEXT_ALIGN_CENTER = 1
|
TEXT_ALIGN_CENTER = 1
|
||||||
TEXT_ALIGN_RIGHT = 2
|
TEXT_ALIGN_RIGHT = 2
|
||||||
|
|
||||||
class GuiTextAlignmentVertical(IntEnum):
|
class GuiTextAlignmentVertical(IntEnum):
|
||||||
"""Gui control text alignment vertical."""
|
|
||||||
TEXT_ALIGN_TOP = 0
|
TEXT_ALIGN_TOP = 0
|
||||||
TEXT_ALIGN_MIDDLE = 1
|
TEXT_ALIGN_MIDDLE = 1
|
||||||
TEXT_ALIGN_BOTTOM = 2
|
TEXT_ALIGN_BOTTOM = 2
|
||||||
|
|
||||||
class GuiTextWrapMode(IntEnum):
|
class GuiTextWrapMode(IntEnum):
|
||||||
"""Gui control text wrap mode."""
|
|
||||||
TEXT_WRAP_NONE = 0
|
TEXT_WRAP_NONE = 0
|
||||||
TEXT_WRAP_CHAR = 1
|
TEXT_WRAP_CHAR = 1
|
||||||
TEXT_WRAP_WORD = 2
|
TEXT_WRAP_WORD = 2
|
||||||
|
|
||||||
class GuiControl(IntEnum):
|
class GuiControl(IntEnum):
|
||||||
"""Gui controls."""
|
|
||||||
DEFAULT = 0
|
DEFAULT = 0
|
||||||
LABEL = 1
|
LABEL = 1
|
||||||
BUTTON = 2
|
BUTTON = 2
|
||||||
|
@ -408,7 +383,6 @@ class GuiControl(IntEnum):
|
||||||
STATUSBAR = 15
|
STATUSBAR = 15
|
||||||
|
|
||||||
class GuiControlProperty(IntEnum):
|
class GuiControlProperty(IntEnum):
|
||||||
"""Gui base properties for every control."""
|
|
||||||
BORDER_COLOR_NORMAL = 0
|
BORDER_COLOR_NORMAL = 0
|
||||||
BASE_COLOR_NORMAL = 1
|
BASE_COLOR_NORMAL = 1
|
||||||
TEXT_COLOR_NORMAL = 2
|
TEXT_COLOR_NORMAL = 2
|
||||||
|
@ -426,7 +400,6 @@ class GuiControlProperty(IntEnum):
|
||||||
TEXT_ALIGNMENT = 14
|
TEXT_ALIGNMENT = 14
|
||||||
|
|
||||||
class GuiDefaultProperty(IntEnum):
|
class GuiDefaultProperty(IntEnum):
|
||||||
"""DEFAULT extended properties."""
|
|
||||||
TEXT_SIZE = 16
|
TEXT_SIZE = 16
|
||||||
TEXT_SPACING = 17
|
TEXT_SPACING = 17
|
||||||
LINE_COLOR = 18
|
LINE_COLOR = 18
|
||||||
|
@ -436,20 +409,16 @@ class GuiDefaultProperty(IntEnum):
|
||||||
TEXT_WRAP_MODE = 22
|
TEXT_WRAP_MODE = 22
|
||||||
|
|
||||||
class GuiToggleProperty(IntEnum):
|
class GuiToggleProperty(IntEnum):
|
||||||
"""Toggle/ToggleGroup."""
|
|
||||||
GROUP_PADDING = 16
|
GROUP_PADDING = 16
|
||||||
|
|
||||||
class GuiSliderProperty(IntEnum):
|
class GuiSliderProperty(IntEnum):
|
||||||
"""Slider/SliderBar."""
|
|
||||||
SLIDER_WIDTH = 16
|
SLIDER_WIDTH = 16
|
||||||
SLIDER_PADDING = 17
|
SLIDER_PADDING = 17
|
||||||
|
|
||||||
class GuiProgressBarProperty(IntEnum):
|
class GuiProgressBarProperty(IntEnum):
|
||||||
"""ProgressBar."""
|
|
||||||
PROGRESS_PADDING = 16
|
PROGRESS_PADDING = 16
|
||||||
|
|
||||||
class GuiScrollBarProperty(IntEnum):
|
class GuiScrollBarProperty(IntEnum):
|
||||||
"""ScrollBar."""
|
|
||||||
ARROWS_SIZE = 16
|
ARROWS_SIZE = 16
|
||||||
ARROWS_VISIBLE = 17
|
ARROWS_VISIBLE = 17
|
||||||
SCROLL_SLIDER_PADDING = 18
|
SCROLL_SLIDER_PADDING = 18
|
||||||
|
@ -458,32 +427,26 @@ class GuiScrollBarProperty(IntEnum):
|
||||||
SCROLL_SPEED = 21
|
SCROLL_SPEED = 21
|
||||||
|
|
||||||
class GuiCheckBoxProperty(IntEnum):
|
class GuiCheckBoxProperty(IntEnum):
|
||||||
"""CheckBox."""
|
|
||||||
CHECK_PADDING = 16
|
CHECK_PADDING = 16
|
||||||
|
|
||||||
class GuiComboBoxProperty(IntEnum):
|
class GuiComboBoxProperty(IntEnum):
|
||||||
"""ComboBox."""
|
|
||||||
COMBO_BUTTON_WIDTH = 16
|
COMBO_BUTTON_WIDTH = 16
|
||||||
COMBO_BUTTON_SPACING = 17
|
COMBO_BUTTON_SPACING = 17
|
||||||
|
|
||||||
class GuiDropdownBoxProperty(IntEnum):
|
class GuiDropdownBoxProperty(IntEnum):
|
||||||
"""DropdownBox."""
|
|
||||||
ARROW_PADDING = 16
|
ARROW_PADDING = 16
|
||||||
DROPDOWN_ITEMS_SPACING = 17
|
DROPDOWN_ITEMS_SPACING = 17
|
||||||
DROPDOWN_ARROW_HIDDEN = 18
|
DROPDOWN_ARROW_HIDDEN = 18
|
||||||
DROPDOWN_ROLL_UP = 19
|
DROPDOWN_ROLL_UP = 19
|
||||||
|
|
||||||
class GuiTextBoxProperty(IntEnum):
|
class GuiTextBoxProperty(IntEnum):
|
||||||
"""TextBox/TextBoxMulti/ValueBox/Spinner."""
|
|
||||||
TEXT_READONLY = 16
|
TEXT_READONLY = 16
|
||||||
|
|
||||||
class GuiSpinnerProperty(IntEnum):
|
class GuiSpinnerProperty(IntEnum):
|
||||||
"""Spinner."""
|
|
||||||
SPIN_BUTTON_WIDTH = 16
|
SPIN_BUTTON_WIDTH = 16
|
||||||
SPIN_BUTTON_SPACING = 17
|
SPIN_BUTTON_SPACING = 17
|
||||||
|
|
||||||
class GuiListViewProperty(IntEnum):
|
class GuiListViewProperty(IntEnum):
|
||||||
"""ListView."""
|
|
||||||
LIST_ITEMS_HEIGHT = 16
|
LIST_ITEMS_HEIGHT = 16
|
||||||
LIST_ITEMS_SPACING = 17
|
LIST_ITEMS_SPACING = 17
|
||||||
SCROLLBAR_WIDTH = 18
|
SCROLLBAR_WIDTH = 18
|
||||||
|
@ -491,7 +454,6 @@ class GuiListViewProperty(IntEnum):
|
||||||
LIST_ITEMS_BORDER_WIDTH = 20
|
LIST_ITEMS_BORDER_WIDTH = 20
|
||||||
|
|
||||||
class GuiColorPickerProperty(IntEnum):
|
class GuiColorPickerProperty(IntEnum):
|
||||||
"""ColorPicker."""
|
|
||||||
COLOR_SELECTOR_SIZE = 16
|
COLOR_SELECTOR_SIZE = 16
|
||||||
HUEBAR_WIDTH = 17
|
HUEBAR_WIDTH = 17
|
||||||
HUEBAR_PADDING = 18
|
HUEBAR_PADDING = 18
|
||||||
|
@ -499,7 +461,6 @@ class GuiColorPickerProperty(IntEnum):
|
||||||
HUEBAR_SELECTOR_OVERFLOW = 20
|
HUEBAR_SELECTOR_OVERFLOW = 20
|
||||||
|
|
||||||
class GuiIconName(IntEnum):
|
class GuiIconName(IntEnum):
|
||||||
"""."""
|
|
||||||
ICON_NONE = 0
|
ICON_NONE = 0
|
||||||
ICON_FOLDER_FILE_OPEN = 1
|
ICON_FOLDER_FILE_OPEN = 1
|
||||||
ICON_FILE_SAVE_CLASSIC = 2
|
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
|
@ -6,6 +6,26 @@ raylib [audio] example - playing
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import pyray
|
import pyray
|
||||||
import raylib as rl
|
import raylib as rl
|
||||||
|
from raylib.colors import (
|
||||||
|
RAYWHITE,
|
||||||
|
ORANGE,
|
||||||
|
RED,
|
||||||
|
GOLD,
|
||||||
|
LIME,
|
||||||
|
BLUE,
|
||||||
|
VIOLET,
|
||||||
|
BROWN,
|
||||||
|
LIGHTGRAY,
|
||||||
|
PINK,
|
||||||
|
YELLOW,
|
||||||
|
GREEN,
|
||||||
|
SKYBLUE,
|
||||||
|
PURPLE,
|
||||||
|
BEIGE,
|
||||||
|
MAROON,
|
||||||
|
GRAY,
|
||||||
|
BLACK
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
MAX_CIRCLES=64
|
MAX_CIRCLES=64
|
||||||
|
@ -13,11 +33,12 @@ MAX_CIRCLES=64
|
||||||
|
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
class CircleWave:
|
class CircleWave:
|
||||||
position: pyray.Vector2
|
position: 'rl.Vector2'
|
||||||
radius: float
|
radius: float
|
||||||
alpha: float
|
alpha: float
|
||||||
speed: float
|
speed: float
|
||||||
color: pyray.Color
|
color: 'rl.Color'
|
||||||
|
|
||||||
|
|
||||||
screenWidth = 800
|
screenWidth = 800
|
||||||
screenHeight = 450
|
screenHeight = 450
|
||||||
|
@ -28,8 +49,8 @@ rl.InitWindow(screenWidth, screenHeight, b"raylib [audio] example - module playi
|
||||||
|
|
||||||
rl.InitAudioDevice() # Initialize audio device
|
rl.InitAudioDevice() # Initialize audio device
|
||||||
|
|
||||||
colors = [pyray.ORANGE, pyray.RED, pyray.GOLD, pyray.LIME, pyray.BLUE, pyray.VIOLET, pyray.BROWN, pyray.LIGHTGRAY, pyray.PINK,
|
colors = [ ORANGE, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK,
|
||||||
pyray.YELLOW, pyray.GREEN, pyray.SKYBLUE, pyray.PURPLE, pyray.BEIGE]
|
YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE ]
|
||||||
|
|
||||||
# Creates some circles for visual effect
|
# Creates some circles for visual effect
|
||||||
circles = []
|
circles = []
|
||||||
|
@ -120,23 +141,23 @@ while not rl.WindowShouldClose(): # Detect window close button or ESC key
|
||||||
#----------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------
|
||||||
pyray.begin_drawing()
|
pyray.begin_drawing()
|
||||||
|
|
||||||
pyray.clear_background(pyray.RAYWHITE)
|
pyray.clear_background(RAYWHITE)
|
||||||
|
|
||||||
for i in range(MAX_CIRCLES):
|
for i in range(MAX_CIRCLES):
|
||||||
pyray.draw_circle_v(circles[i].position, circles[i].radius, pyray.fade(circles[i].color, circles[i].alpha))
|
pyray.draw_circle_v(circles[i].position, circles[i].radius, rl.Fade(circles[i].color, circles[i].alpha))
|
||||||
|
|
||||||
# Draw time bar
|
# Draw time bar
|
||||||
pyray.draw_rectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, pyray.LIGHTGRAY)
|
pyray.draw_rectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, LIGHTGRAY)
|
||||||
pyray.draw_rectangle(20, screenHeight - 20 - 12, int(timePlayed), 12, pyray.MAROON)
|
pyray.draw_rectangle(20, screenHeight - 20 - 12, int(timePlayed), 12, MAROON)
|
||||||
pyray.draw_rectangle_lines(20, screenHeight - 20 - 12, screenWidth - 40, 12, pyray.GRAY)
|
pyray.draw_rectangle_lines(20, screenHeight - 20 - 12, screenWidth - 40, 12, GRAY)
|
||||||
|
|
||||||
# Draw help instructions
|
# Draw help instructions
|
||||||
pyray.draw_rectangle(20, 20, 425, 145, pyray.RAYWHITE)
|
pyray.draw_rectangle(20, 20, 425, 145, RAYWHITE)
|
||||||
pyray.draw_rectangle_lines(20, 20, 425, 145, pyray.GRAY)
|
pyray.draw_rectangle_lines(20, 20, 425, 145, GRAY)
|
||||||
pyray.draw_text("PRESS SPACE TO RESTART MUSIC", 40, 40, 20, pyray.BLACK)
|
pyray.draw_text("PRESS SPACE TO RESTART MUSIC", 40, 40, 20, BLACK)
|
||||||
pyray.draw_text("PRESS P TO PAUSE/RESUME", 40, 70, 20, pyray.BLACK)
|
pyray.draw_text("PRESS P TO PAUSE/RESUME", 40, 70, 20, BLACK)
|
||||||
pyray.draw_text("PRESS UP/DOWN TO CHANGE SPEED", 40, 100, 20, pyray.BLACK)
|
pyray.draw_text("PRESS UP/DOWN TO CHANGE SPEED", 40, 100, 20, BLACK)
|
||||||
pyray.draw_text(f"SPEED: {pitch}", 40, 130, 20, pyray.MAROON)
|
pyray.draw_text(f"SPEED: {pitch}", 40, 130, 20, MAROON)
|
||||||
|
|
||||||
pyray.end_drawing()
|
pyray.end_drawing()
|
||||||
#----------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -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.
|
@ -57,18 +57,18 @@ while not pyray.window_should_close(): # Detect window close button or ESC key
|
||||||
# Update
|
# Update
|
||||||
|
|
||||||
# Player movement
|
# Player movement
|
||||||
if pyray.is_key_down(pyray.KeyboardKey.KEY_RIGHT):
|
if pyray.is_key_down(pyray.KEY_RIGHT):
|
||||||
player.x += 2
|
player.x += 2
|
||||||
elif pyray.is_key_down(pyray.KeyboardKey.KEY_LEFT):
|
elif pyray.is_key_down(pyray.KEY_LEFT):
|
||||||
player.x -= 2
|
player.x -= 2
|
||||||
|
|
||||||
# Camera target follows player
|
# Camera target follows player
|
||||||
camera.target = pyray.Vector2(player.x + 20, player.y + 20)
|
camera.target = pyray.Vector2(player.x + 20, player.y + 20)
|
||||||
|
|
||||||
# Camera rotation controls
|
# Camera rotation controls
|
||||||
if pyray.is_key_down(pyray.KeyboardKey.KEY_A):
|
if pyray.is_key_down(pyray.KEY_A):
|
||||||
camera.rotation -= 1
|
camera.rotation -= 1
|
||||||
elif pyray.is_key_down(pyray.KeyboardKey.KEY_S):
|
elif pyray.is_key_down(pyray.KEY_S):
|
||||||
camera.rotation += 1
|
camera.rotation += 1
|
||||||
|
|
||||||
# Limit camera rotation to 80 degrees (-40 to 40)
|
# Limit camera rotation to 80 degrees (-40 to 40)
|
||||||
|
@ -86,7 +86,7 @@ while not pyray.window_should_close(): # Detect window close button or ESC key
|
||||||
camera.zoom = 0.1
|
camera.zoom = 0.1
|
||||||
|
|
||||||
# Camera reset (zoom and rotation)
|
# Camera reset (zoom and rotation)
|
||||||
if pyray.is_key_pressed(pyray.KeyboardKey.KEY_R):
|
if pyray.is_key_pressed(pyray.KEY_R):
|
||||||
camera.zoom = 1.0
|
camera.zoom = 1.0
|
||||||
camera.rotation = 0.0
|
camera.rotation = 0.0
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,15 @@ pyray.set_target_fps(60)
|
||||||
|
|
||||||
camera = pyray.Camera2D()
|
camera = pyray.Camera2D()
|
||||||
|
|
||||||
|
camera = pyray.Camera2D()
|
||||||
camera.zoom = 1.0
|
camera.zoom = 1.0
|
||||||
|
|
||||||
pyray.set_target_fps(60)
|
pyray.set_target_fps(60);
|
||||||
|
|
||||||
# main game loop
|
# main game loop
|
||||||
while not pyray.window_should_close():
|
while not pyray.window_should_close():
|
||||||
# update
|
# update
|
||||||
if pyray.is_mouse_button_down(pyray.MouseButton.MOUSE_BUTTON_RIGHT):
|
if pyray.is_mouse_button_down(pyray.MOUSE_BUTTON_RIGHT):
|
||||||
delta = pyray.get_mouse_delta()
|
delta = pyray.get_mouse_delta()
|
||||||
delta = pyray.vector2_scale(delta, -1.0 / camera.zoom)
|
delta = pyray.vector2_scale(delta, -1.0 / camera.zoom)
|
||||||
camera.target = pyray.vector2_add(camera.target, delta)
|
camera.target = pyray.vector2_add(camera.target, delta)
|
||||||
|
@ -57,7 +58,7 @@ while not pyray.window_should_close():
|
||||||
|
|
||||||
pyray.end_mode_2d()
|
pyray.end_mode_2d()
|
||||||
|
|
||||||
pyray.draw_text("Mouse right button drag to move, mouse wheel to zoom", 10, 10, 20, pyray.WHITE)
|
pyray.draw_text("Mouse right button drag to move, mouse wheel to zoom", 10, 10, 20, pyray.WHITE);
|
||||||
|
|
||||||
pyray.end_drawing()
|
pyray.end_drawing()
|
||||||
|
|
||||||
|
|
|
@ -62,11 +62,11 @@ class EnvItem:
|
||||||
|
|
||||||
|
|
||||||
def update_player(player, env_items, delta):
|
def update_player(player, env_items, delta):
|
||||||
if pyray.is_key_down(pyray.KeyboardKey.KEY_LEFT):
|
if pyray.is_key_down(pyray.KEY_LEFT):
|
||||||
player.position.x -= PLAYER_HOR_SPD * delta
|
player.position.x -= PLAYER_HOR_SPD * delta
|
||||||
if pyray.is_key_down(pyray.KeyboardKey.KEY_RIGHT):
|
if pyray.is_key_down(pyray.KEY_RIGHT):
|
||||||
player.position.x += PLAYER_HOR_SPD * delta
|
player.position.x += PLAYER_HOR_SPD * delta
|
||||||
if pyray.is_key_down(pyray.KeyboardKey.KEY_SPACE) and player.can_jump:
|
if pyray.is_key_down(pyray.KEY_SPACE) and player.can_jump:
|
||||||
player.speed = -PLAYER_JUMP_SPD
|
player.speed = -PLAYER_JUMP_SPD
|
||||||
player.can_jump = False
|
player.can_jump = False
|
||||||
|
|
||||||
|
@ -264,11 +264,11 @@ while not pyray.window_should_close(): # Detect window close button or ESC key
|
||||||
elif camera.zoom < 0.25:
|
elif camera.zoom < 0.25:
|
||||||
camera.zoom = 0.25
|
camera.zoom = 0.25
|
||||||
|
|
||||||
if pyray.is_key_pressed(pyray.KeyboardKey.KEY_R):
|
if pyray.is_key_pressed(pyray.KEY_R):
|
||||||
camera.zoom = 1.0
|
camera.zoom = 1.0
|
||||||
player.position = pyray.Vector2(400, 280)
|
player.position = pyray.Vector2(400, 280)
|
||||||
|
|
||||||
if pyray.is_key_pressed(pyray.KeyboardKey.KEY_C):
|
if pyray.is_key_pressed(pyray.KEY_C):
|
||||||
camera_option = (camera_option + 1) % camera_updaters_length
|
camera_option = (camera_option + 1) % camera_updaters_length
|
||||||
|
|
||||||
# Call update camera function by its pointer
|
# Call update camera function by its pointer
|
||||||
|
|
|
@ -10,7 +10,7 @@ MAX_COLUMNS = 20
|
||||||
SCREEN_WIDTH = 800
|
SCREEN_WIDTH = 800
|
||||||
SCREEN_HEIGHT = 450
|
SCREEN_HEIGHT = 450
|
||||||
|
|
||||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [core] example - 3d camera first person")
|
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, b"raylib [core] example - 3d camera first person")
|
||||||
|
|
||||||
# Define the camera to look into our 3d world (position, target, up vector)
|
# Define the camera to look into our 3d world (position, target, up vector)
|
||||||
camera = pyray.Camera3D()
|
camera = pyray.Camera3D()
|
||||||
|
@ -18,24 +18,24 @@ camera.position = pyray.Vector3(4.0, 2.0, 4.0)
|
||||||
camera.target = pyray.Vector3(0.0, 1.8, 0.0)
|
camera.target = pyray.Vector3(0.0, 1.8, 0.0)
|
||||||
camera.up = pyray.Vector3(0.0, 1.0, 0.0)
|
camera.up = pyray.Vector3(0.0, 1.0, 0.0)
|
||||||
camera.fovy = 60.0
|
camera.fovy = 60.0
|
||||||
camera.projection = pyray.CameraProjection.CAMERA_PERSPECTIVE
|
camera.projection = pyray.CAMERA_PERSPECTIVE
|
||||||
|
|
||||||
# Generates some random columns
|
# Generates some random columns
|
||||||
heights = []
|
heights = [None] * MAX_COLUMNS
|
||||||
positions = []
|
positions = [None] * MAX_COLUMNS
|
||||||
colors = []
|
colors = [None] * MAX_COLUMNS
|
||||||
|
|
||||||
for i in range(MAX_COLUMNS):
|
for i in range(MAX_COLUMNS):
|
||||||
heights.append(pyray.get_random_value(1, 12) * 1.0)
|
heights[i] = pyray.get_random_value(1, 12) * 1.0
|
||||||
positions.append(pyray.Vector3(pyray.get_random_value(-15, 15) * 1.0, heights[i]/2.0 * 1.0, pyray.get_random_value(-15, 15) * 1.0))
|
positions[i] = pyray.Vector3(pyray.get_random_value(-15, 15) * 1.0, heights[i]/2.0 * 1.0, pyray.get_random_value(-15, 15) * 1.0)
|
||||||
colors.append(pyray.Color(pyray.get_random_value(20, 255), pyray.get_random_value(10, 55), 30, 255))
|
colors[i] = pyray.Color(pyray.get_random_value(20, 255), pyray.get_random_value(10, 55), 30, 255)
|
||||||
|
|
||||||
|
|
||||||
pyray.set_target_fps(60)
|
pyray.set_target_fps(60)
|
||||||
|
|
||||||
while not pyray.window_should_close():
|
while not pyray.window_should_close():
|
||||||
|
|
||||||
pyray.update_camera(camera, pyray.CameraMode.CAMERA_FIRST_PERSON)
|
pyray.update_camera(camera, pyray.CAMERA_FIRST_PERSON)
|
||||||
|
|
||||||
pyray.begin_drawing()
|
pyray.begin_drawing()
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
# Update
|
# Update
|
||||||
update_camera(camera, CameraMode.CAMERA_FREE)
|
update_camera(camera, CameraMode.CAMERA_FREE)
|
||||||
|
|
||||||
if is_key_pressed(KeyboardKey.KEY_Z):
|
if is_key_pressed(KEY_Z):
|
||||||
camera.target = Vector3(0.0, 0.0, 0.0)
|
camera.target = Vector3(0.0, 0.0, 0.0)
|
||||||
|
|
||||||
# Draw
|
# Draw
|
||||||
|
|
|
@ -40,7 +40,7 @@ while not pyray.window_should_close():
|
||||||
|
|
||||||
pyray.end_mode_3d()
|
pyray.end_mode_3d()
|
||||||
|
|
||||||
pyray.draw_text("Welcome to the third dimension!", 10, 40, 20, pyray.DARKGRAY)
|
pyray.draw_text("Welcome to the third dimension!", 10, 40, 20, pyray.DARKGRAY);
|
||||||
|
|
||||||
pyray.draw_fps(10, 10)
|
pyray.draw_fps(10, 10)
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,13 @@ def main():
|
||||||
if frame_count > 120:
|
if frame_count > 120:
|
||||||
current_screen = GameScreen.TITLE
|
current_screen = GameScreen.TITLE
|
||||||
elif current_screen == GameScreen.TITLE:
|
elif current_screen == GameScreen.TITLE:
|
||||||
if is_key_pressed(KeyboardKey.KEY_ENTER) or is_gesture_detected(Gesture.GESTURE_TAP):
|
if is_key_pressed(KEY_ENTER) or is_gesture_detected(GESTURE_TAP):
|
||||||
current_screen = GameScreen.GAMEPLAY
|
current_screen = GameScreen.GAMEPLAY
|
||||||
elif current_screen == GameScreen.GAMEPLAY:
|
elif current_screen == GameScreen.GAMEPLAY:
|
||||||
if is_key_pressed(KeyboardKey.KEY_ENTER) or is_gesture_detected(Gesture.GESTURE_TAP):
|
if is_key_pressed(KEY_ENTER) or is_gesture_detected(GESTURE_TAP):
|
||||||
current_screen = GameScreen.ENDING
|
current_screen = GameScreen.ENDING
|
||||||
elif current_screen == GameScreen.ENDING:
|
elif current_screen == GameScreen.ENDING:
|
||||||
if is_key_pressed(KeyboardKey.KEY_ENTER) or is_gesture_detected(Gesture.GESTURE_TAP):
|
if is_key_pressed(KEY_ENTER) or is_gesture_detected(GESTURE_TAP):
|
||||||
current_screen = GameScreen.TITLE
|
current_screen = GameScreen.TITLE
|
||||||
|
|
||||||
begin_drawing()
|
begin_drawing()
|
||||||
|
|
|
@ -11,6 +11,12 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import pyray
|
import pyray
|
||||||
|
from raylib.colors import (
|
||||||
|
RAYWHITE,
|
||||||
|
DARKGRAY,
|
||||||
|
LIGHTGRAY,
|
||||||
|
GRAY
|
||||||
|
)
|
||||||
|
|
||||||
screenWidth = 800
|
screenWidth = 800
|
||||||
screenHeight = 450
|
screenHeight = 450
|
||||||
|
@ -30,21 +36,21 @@ while not pyray.window_should_close():
|
||||||
|
|
||||||
pyray.begin_drawing()
|
pyray.begin_drawing()
|
||||||
|
|
||||||
pyray.clear_background(pyray.RAYWHITE)
|
pyray.clear_background(RAYWHITE)
|
||||||
|
|
||||||
if droppedFiles.count == 0:
|
if droppedFiles.count == 0:
|
||||||
pyray.draw_text("Drop your files to this window!", 100, 40, 20, pyray.DARKGRAY)
|
pyray.draw_text("Drop your files to this window!", 100, 40, 20, DARKGRAY)
|
||||||
else:
|
else:
|
||||||
pyray.draw_text("Dropped files:", 100, 40, 20, pyray.DARKGRAY)
|
pyray.draw_text("Dropped files:", 100, 40, 20, DARKGRAY)
|
||||||
|
|
||||||
for i in range(0, droppedFiles.count):
|
for i in range(0, droppedFiles.count):
|
||||||
if i % 2 == 0:
|
if i % 2 == 0:
|
||||||
pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(pyray.LIGHTGRAY, 0.5))
|
pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(LIGHTGRAY, 0.5))
|
||||||
else:
|
else:
|
||||||
pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(pyray.LIGHTGRAY, 0.3))
|
pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(LIGHTGRAY, 0.3))
|
||||||
pyray.draw_text(droppedFiles.paths[i], 120, 100 + 40*i, 10, pyray.GRAY)
|
pyray.draw_text(droppedFiles.paths[i], 120, 100 + 40*i, 10, GRAY)
|
||||||
|
|
||||||
pyray.draw_text("Drop new files...", 100, 110 + 40*droppedFiles.count, 20, pyray.DARKGRAY)
|
pyray.draw_text("Drop new files...", 100, 110 + 40*droppedFiles.count, 20, DARKGRAY)
|
||||||
pyray.end_drawing()
|
pyray.end_drawing()
|
||||||
|
|
||||||
# De-Initialization
|
# De-Initialization
|
||||||
|
|
|
@ -4,6 +4,13 @@ raylib [core] example - Input Gestures Detection
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import pyray
|
import pyray
|
||||||
|
from raylib.colors import (
|
||||||
|
RAYWHITE,
|
||||||
|
LIGHTGRAY,
|
||||||
|
DARKGRAY,
|
||||||
|
MAROON,
|
||||||
|
GRAY,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,20 +26,20 @@ touch_area = pyray.Rectangle(220, 10, SCREEN_WIDTH - 230, SCREEN_HEIGHT - 20)
|
||||||
|
|
||||||
gesture_strings = []
|
gesture_strings = []
|
||||||
|
|
||||||
current_gesture = pyray.Gesture.GESTURE_NONE
|
current_gesture = pyray.GESTURE_NONE
|
||||||
last_gesture = pyray.Gesture.GESTURE_NONE
|
last_gesture = pyray.GESTURE_NONE
|
||||||
|
|
||||||
GESTURE_LABELS = {
|
GESTURE_LABELS = {
|
||||||
pyray.Gesture.GESTURE_TAP: 'GESTURE TAP',
|
pyray.GESTURE_TAP: 'GESTURE TAP',
|
||||||
pyray.Gesture.GESTURE_DOUBLETAP: 'GESTURE DOUBLETAP',
|
pyray.GESTURE_DOUBLETAP: 'GESTURE DOUBLETAP',
|
||||||
pyray.Gesture.GESTURE_HOLD: 'GESTURE HOLD',
|
pyray.GESTURE_HOLD: 'GESTURE HOLD',
|
||||||
pyray.Gesture.GESTURE_DRAG: 'GESTURE DRAG',
|
pyray.GESTURE_DRAG: 'GESTURE DRAG',
|
||||||
pyray.Gesture.GESTURE_SWIPE_RIGHT: 'GESTURE SWIPE RIGHT',
|
pyray.GESTURE_SWIPE_RIGHT: 'GESTURE SWIPE RIGHT',
|
||||||
pyray.Gesture.GESTURE_SWIPE_LEFT: 'GESTURE SWIPE LEFT',
|
pyray.GESTURE_SWIPE_LEFT: 'GESTURE SWIPE LEFT',
|
||||||
pyray.Gesture.GESTURE_SWIPE_UP: 'GESTURE SWIPE UP',
|
pyray.GESTURE_SWIPE_UP: 'GESTURE SWIPE UP',
|
||||||
pyray.Gesture.GESTURE_SWIPE_DOWN: 'GESTURE SWIPE DOWN',
|
pyray.GESTURE_SWIPE_DOWN: 'GESTURE SWIPE DOWN',
|
||||||
pyray.Gesture.GESTURE_PINCH_IN: 'GESTURE PINCH IN',
|
pyray.GESTURE_PINCH_IN: 'GESTURE PINCH IN',
|
||||||
pyray.Gesture.GESTURE_PINCH_OUT: 'GESTURE PINCH OUT',
|
pyray.GESTURE_PINCH_OUT: 'GESTURE PINCH OUT',
|
||||||
}
|
}
|
||||||
|
|
||||||
pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second
|
pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second
|
||||||
|
@ -47,7 +54,7 @@ while not pyray.window_should_close(): # Detect window close button or ESC key
|
||||||
|
|
||||||
if (
|
if (
|
||||||
pyray.check_collision_point_rec(touch_position, touch_area)
|
pyray.check_collision_point_rec(touch_position, touch_area)
|
||||||
and current_gesture != pyray.Gesture.GESTURE_NONE
|
and current_gesture != pyray.GESTURE_NONE
|
||||||
):
|
):
|
||||||
if current_gesture != last_gesture:
|
if current_gesture != last_gesture:
|
||||||
gesture_strings.append(GESTURE_LABELS[current_gesture])
|
gesture_strings.append(GESTURE_LABELS[current_gesture])
|
||||||
|
@ -59,34 +66,34 @@ while not pyray.window_should_close(): # Detect window close button or ESC key
|
||||||
# Draw
|
# Draw
|
||||||
pyray.begin_drawing()
|
pyray.begin_drawing()
|
||||||
|
|
||||||
pyray.clear_background(pyray.RAYWHITE)
|
pyray.clear_background(RAYWHITE)
|
||||||
|
|
||||||
pyray.draw_rectangle_rec(touch_area, pyray.GRAY)
|
pyray.draw_rectangle_rec(touch_area, GRAY)
|
||||||
pyray.draw_rectangle(225, 15, SCREEN_WIDTH - 240, SCREEN_HEIGHT - 30,
|
pyray.draw_rectangle(225, 15, SCREEN_WIDTH - 240, SCREEN_HEIGHT - 30,
|
||||||
pyray.RAYWHITE)
|
RAYWHITE)
|
||||||
pyray.draw_text(
|
pyray.draw_text(
|
||||||
'GESTURES TEST AREA',
|
'GESTURES TEST AREA',
|
||||||
SCREEN_WIDTH - 270, SCREEN_HEIGHT - 40, 20, pyray.fade(pyray.GRAY, 0.5)
|
SCREEN_WIDTH - 270, SCREEN_HEIGHT - 40, 20, pyray.fade(GRAY, 0.5)
|
||||||
)
|
)
|
||||||
|
|
||||||
for i, val in enumerate(gesture_strings):
|
for i, val in enumerate(gesture_strings):
|
||||||
if i % 2 == 0:
|
if i % 2 == 0:
|
||||||
pyray.draw_rectangle(
|
pyray.draw_rectangle(
|
||||||
10, 30 + 20 * i, 200, 20, pyray.fade(pyray.LIGHTGRAY, 0.5))
|
10, 30 + 20 * i, 200, 20, pyray.fade(LIGHTGRAY, 0.5))
|
||||||
else:
|
else:
|
||||||
pyray.draw_rectangle(
|
pyray.draw_rectangle(
|
||||||
10, 30 + 20 * i, 200, 20, pyray.fade(pyray.LIGHTGRAY, 0.3))
|
10, 30 + 20 * i, 200, 20, pyray.fade(LIGHTGRAY, 0.3))
|
||||||
|
|
||||||
if i < len(gesture_strings) - 1:
|
if i < len(gesture_strings) - 1:
|
||||||
pyray.draw_text(val, 35, 36 + 20 * i, 10, pyray.DARKGRAY)
|
pyray.draw_text(val, 35, 36 + 20 * i, 10, DARKGRAY)
|
||||||
else:
|
else:
|
||||||
pyray.draw_text(val, 35, 36 + 20 * i, 10, pyray.MAROON)
|
pyray.draw_text(val, 35, 36 + 20 * i, 10, MAROON)
|
||||||
|
|
||||||
pyray.draw_rectangle_lines(10, 29, 200, SCREEN_HEIGHT - 50, pyray.GRAY)
|
pyray.draw_rectangle_lines(10, 29, 200, SCREEN_HEIGHT - 50, GRAY)
|
||||||
pyray.draw_text('DETECTED GESTURES', 50, 15, 10, pyray.GRAY)
|
pyray.draw_text('DETECTED GESTURES', 50, 15, 10, GRAY)
|
||||||
|
|
||||||
if current_gesture != pyray.Gesture.GESTURE_NONE:
|
if current_gesture != pyray.GESTURE_NONE:
|
||||||
pyray.draw_circle_v(touch_position, 30, pyray.MAROON)
|
pyray.draw_circle_v(touch_position, 30, MAROON)
|
||||||
|
|
||||||
pyray.end_drawing()
|
pyray.end_drawing()
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,13 @@ pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second
|
||||||
# Main game loop
|
# Main game loop
|
||||||
while not pyray.window_should_close(): # Detect window close button or ESC key
|
while not pyray.window_should_close(): # Detect window close button or ESC key
|
||||||
# Update
|
# Update
|
||||||
if pyray.is_key_down(pyray.KeyboardKey.KEY_RIGHT):
|
if pyray.is_key_down(pyray.KEY_RIGHT):
|
||||||
ball_position.x += 2
|
ball_position.x += 2
|
||||||
if pyray.is_key_down(pyray.KeyboardKey.KEY_LEFT):
|
if pyray.is_key_down(pyray.KEY_LEFT):
|
||||||
ball_position.x -= 2
|
ball_position.x -= 2
|
||||||
if pyray.is_key_down(pyray.KeyboardKey.KEY_UP):
|
if pyray.is_key_down(pyray.KEY_UP):
|
||||||
ball_position.y -= 2
|
ball_position.y -= 2
|
||||||
if pyray.is_key_down(pyray.KeyboardKey.KEY_DOWN):
|
if pyray.is_key_down(pyray.KEY_DOWN):
|
||||||
ball_position.y += 2
|
ball_position.y += 2
|
||||||
|
|
||||||
# Draw
|
# Draw
|
||||||
|
|
|
@ -22,19 +22,19 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
# Update
|
# Update
|
||||||
ball_position = get_mouse_position()
|
ball_position = get_mouse_position()
|
||||||
|
|
||||||
if is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_LEFT):
|
if is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
|
||||||
ball_color = MAROON
|
ball_color = MAROON
|
||||||
elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_MIDDLE):
|
elif is_mouse_button_pressed(MOUSE_BUTTON_MIDDLE):
|
||||||
ball_color = LIME
|
ball_color = LIME
|
||||||
elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_RIGHT):
|
elif is_mouse_button_pressed(MOUSE_BUTTON_RIGHT):
|
||||||
ball_color = DARKBLUE
|
ball_color = DARKBLUE
|
||||||
elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_SIDE):
|
elif is_mouse_button_pressed(MOUSE_BUTTON_SIDE):
|
||||||
ball_color = PURPLE
|
ball_color = PURPLE
|
||||||
elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_EXTRA):
|
elif is_mouse_button_pressed(MOUSE_BUTTON_EXTRA):
|
||||||
ball_color = YELLOW
|
ball_color = YELLOW
|
||||||
elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_FORWARD):
|
elif is_mouse_button_pressed(MOUSE_BUTTON_FORWARD):
|
||||||
ball_color = ORANGE
|
ball_color = ORANGE
|
||||||
elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_BACK):
|
elif is_mouse_button_pressed(MOUSE_BUTTON_BACK):
|
||||||
ball_color = BEIGE
|
ball_color = BEIGE
|
||||||
# Draw
|
# Draw
|
||||||
begin_drawing()
|
begin_drawing()
|
||||||
|
|
|
@ -23,7 +23,7 @@ set_target_fps(60) # Set our game to run at 60 frames-per-second
|
||||||
while not window_should_close(): # Detect window close button or ESC key
|
while not window_should_close(): # Detect window close button or ESC key
|
||||||
# Update
|
# Update
|
||||||
# ----------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------
|
||||||
if is_key_pressed(KeyboardKey.KEY_S):
|
if is_key_pressed(KEY_S):
|
||||||
scissorMode = not scissorMode
|
scissorMode = not scissorMode
|
||||||
|
|
||||||
# Centre the scissor area around the mouse position
|
# Centre the scissor area around the mouse position
|
||||||
|
|
|
@ -18,7 +18,7 @@ worldSpaceCamera.zoom = 1.0
|
||||||
screenSpaceCamera = Camera2D([0]) # Smoothing camera
|
screenSpaceCamera = Camera2D([0]) # Smoothing camera
|
||||||
screenSpaceCamera.zoom = 1.0
|
screenSpaceCamera.zoom = 1.0
|
||||||
|
|
||||||
target = load_render_texture(virtualScreenWidth, virtualScreenHeight) # This is where we'll draw all our objects.
|
target = load_render_texture(virtualScreenWidth, virtualScreenHeight); # This is where we'll draw all our objects.
|
||||||
|
|
||||||
rec01 = Rectangle(70.0, 35.0, 20.0, 20.0)
|
rec01 = Rectangle(70.0, 35.0, 20.0, 20.0)
|
||||||
rec02 = Rectangle(90.0, 55.0, 30.0, 10.0)
|
rec02 = Rectangle(90.0, 55.0, 30.0, 10.0)
|
||||||
|
@ -42,7 +42,7 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
|
|
||||||
# Update
|
# Update
|
||||||
|
|
||||||
rotation += 60.0 *get_frame_time() # Rotate the rectangles, 60 degrees per second
|
rotation += 60.0 *get_frame_time(); # Rotate the rectangles, 60 degrees per second
|
||||||
|
|
||||||
# Make the camera move to demonstrate the effect
|
# Make the camera move to demonstrate the effect
|
||||||
cameraX = (math.sin(get_time())*50.0) - 10.0
|
cameraX = (math.sin(get_time())*50.0) - 10.0
|
||||||
|
|
|
@ -66,21 +66,21 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
|
|
||||||
# Move Player1 forward and backwards (no turning)
|
# Move Player1 forward and backwards (no turning)
|
||||||
|
|
||||||
if is_key_down(KeyboardKey.KEY_W):
|
if is_key_down(KEY_W):
|
||||||
cameraPlayer1.position.z += offsetThisFrame
|
cameraPlayer1.position.z += offsetThisFrame
|
||||||
cameraPlayer1.target.z += offsetThisFrame
|
cameraPlayer1.target.z += offsetThisFrame
|
||||||
|
|
||||||
elif is_key_down(KeyboardKey.KEY_S):
|
elif is_key_down(KEY_S):
|
||||||
|
|
||||||
cameraPlayer1.position.z -= offsetThisFrame
|
cameraPlayer1.position.z -= offsetThisFrame
|
||||||
cameraPlayer1.target.z -= offsetThisFrame
|
cameraPlayer1.target.z -= offsetThisFrame
|
||||||
|
|
||||||
# Move Player2 forward and backwards (no turning)
|
# Move Player2 forward and backwards (no turning)
|
||||||
if is_key_down(KeyboardKey.KEY_UP):
|
if is_key_down(KEY_UP):
|
||||||
cameraPlayer2.position.x += offsetThisFrame
|
cameraPlayer2.position.x += offsetThisFrame
|
||||||
cameraPlayer2.target.x += offsetThisFrame
|
cameraPlayer2.target.x += offsetThisFrame
|
||||||
|
|
||||||
elif is_key_down(KeyboardKey.KEY_DOWN):
|
elif is_key_down(KEY_DOWN):
|
||||||
cameraPlayer2.position
|
cameraPlayer2.position
|
||||||
cameraPlayer2.position.x -= offsetThisFrame
|
cameraPlayer2.position.x -= offsetThisFrame
|
||||||
cameraPlayer2.target.x -= offsetThisFrame
|
cameraPlayer2.target.x -= offsetThisFrame
|
||||||
|
|
|
@ -17,6 +17,7 @@ device = pyray.VrDeviceInfo(
|
||||||
1200, # Vertical resolution in pixels
|
1200, # Vertical resolution in pixels
|
||||||
0.133793, # Horizontal size in meters
|
0.133793, # Horizontal size in meters
|
||||||
0.0669, # Vertical size in meters
|
0.0669, # Vertical size in meters
|
||||||
|
0.04678, # Screen center in meters
|
||||||
0.041, # Distance between eye and display in meters
|
0.041, # Distance between eye and display in meters
|
||||||
0.07, # Lens separation distance in meters
|
0.07, # Lens separation distance in meters
|
||||||
0.07, # IPD (distance between pupils) in meters
|
0.07, # IPD (distance between pupils) in meters
|
||||||
|
@ -34,15 +35,15 @@ config = pyray.load_vr_stereo_config(device)
|
||||||
distortion = pyray.load_shader(pyray.ffi.NULL, f"resources/distortion{GLSL_VERSION}.fs")
|
distortion = pyray.load_shader(pyray.ffi.NULL, f"resources/distortion{GLSL_VERSION}.fs")
|
||||||
|
|
||||||
# Update distortion shader with lens and distortion-scale parameters
|
# Update distortion shader with lens and distortion-scale parameters
|
||||||
pyray.set_shader_value(distortion, 2, pyray.ffi.new('char []', b"leftLensCenter"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2)
|
pyray.set_shader_value(distortion, 2, pyray.ffi.new('char []', b"leftLensCenter"), pyray.SHADER_UNIFORM_VEC2)
|
||||||
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightLensCenter"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2)
|
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightLensCenter"), pyray.SHADER_UNIFORM_VEC2)
|
||||||
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"leftScreenCenter"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2)
|
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"leftScreenCenter"), pyray.SHADER_UNIFORM_VEC2)
|
||||||
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightScreenCenter"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2)
|
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightScreenCenter"), pyray.SHADER_UNIFORM_VEC2)
|
||||||
|
|
||||||
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scale"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2)
|
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scale"), pyray.SHADER_UNIFORM_VEC2)
|
||||||
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scaleIn"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2)
|
pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scaleIn"), pyray.SHADER_UNIFORM_VEC2)
|
||||||
pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"deviceWarpParam"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC4)
|
pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"deviceWarpParam"), pyray.SHADER_UNIFORM_VEC4)
|
||||||
pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"chromaAbParam"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC4)
|
pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"chromaAbParam"), pyray.SHADER_UNIFORM_VEC4)
|
||||||
|
|
||||||
# Initialize framebuffer for stereo rendering
|
# Initialize framebuffer for stereo rendering
|
||||||
# NOTE: Screen size should match HMD aspect ratio
|
# NOTE: Screen size should match HMD aspect ratio
|
||||||
|
@ -58,7 +59,7 @@ camera = pyray.Camera3D(
|
||||||
pyray.Vector3(0.0, 2.0, 0.0), # Camera looking at point
|
pyray.Vector3(0.0, 2.0, 0.0), # Camera looking at point
|
||||||
pyray.Vector3(0.0, 1.0, 0.0), # Camera up vector
|
pyray.Vector3(0.0, 1.0, 0.0), # Camera up vector
|
||||||
60.0, # Camera field-of-view Y
|
60.0, # Camera field-of-view Y
|
||||||
pyray.CameraProjection.CAMERA_PERSPECTIVE # Camera projection type
|
pyray.CAMERA_PERSPECTIVE # Camera projection type
|
||||||
)
|
)
|
||||||
|
|
||||||
cubePosition = pyray.Vector3(0.0, 0.0, 0.0)
|
cubePosition = pyray.Vector3(0.0, 0.0, 0.0)
|
||||||
|
@ -70,7 +71,7 @@ pyray.set_target_fps(90) # Set our game to run at 90 frames-per-sec
|
||||||
# Main game loop
|
# Main game loop
|
||||||
while not pyray.window_should_close(): # Detect window close button or ESC key
|
while not pyray.window_should_close(): # Detect window close button or ESC key
|
||||||
# Update
|
# Update
|
||||||
pyray.update_camera(camera, pyray.CameraMode.CAMERA_FIRST_PERSON)
|
pyray.update_camera(camera, pyray.CAMERA_FIRST_PERSON)
|
||||||
|
|
||||||
# Draw
|
# Draw
|
||||||
pyray.begin_texture_mode(target)
|
pyray.begin_texture_mode(target)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import pyray
|
||||||
screen_width = 800
|
screen_width = 800
|
||||||
screen_height = 450
|
screen_height = 450
|
||||||
|
|
||||||
init_window(screen_width, screen_height, "raylib [core] example - window flags")
|
init_window(screen_width, screen_height, b"raylib [core] example - window flags")
|
||||||
|
|
||||||
ball_position = Vector2(get_screen_width() / 2.0, get_screen_height() / 2.0)
|
ball_position = Vector2(get_screen_width() / 2.0, get_screen_height() / 2.0)
|
||||||
ball_speed = Vector2(5.0, 4.0)
|
ball_speed = Vector2(5.0, 4.0)
|
||||||
|
@ -18,71 +18,71 @@ frames_counter = 0
|
||||||
while not window_should_close(): # Detect window close button or ESC key
|
while not window_should_close(): # Detect window close button or ESC key
|
||||||
# Update
|
# Update
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
if is_key_pressed(pyray.KeyboardKey.KEY_F):
|
if is_key_pressed(pyray.KEY_F):
|
||||||
toggle_fullscreen()
|
toggle_fullscreen()
|
||||||
|
|
||||||
if is_key_pressed(pyray.KeyboardKey.KEY_R):
|
if is_key_pressed(pyray.KEY_R):
|
||||||
if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_RESIZABLE):
|
if is_window_state(pyray.FLAG_WINDOW_RESIZABLE):
|
||||||
clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_RESIZABLE)
|
clear_window_state(pyray.FLAG_WINDOW_RESIZABLE)
|
||||||
else:
|
else:
|
||||||
set_window_state(pyray.ConfigFlags.FLAG_WINDOW_RESIZABLE)
|
set_window_state(pyray.FLAG_WINDOW_RESIZABLE)
|
||||||
|
|
||||||
if is_key_pressed(pyray.KeyboardKey.KEY_D):
|
if is_key_pressed(pyray.KEY_D):
|
||||||
if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNDECORATED):
|
if is_window_state(pyray.FLAG_WINDOW_UNDECORATED):
|
||||||
clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNDECORATED)
|
clear_window_state(pyray.FLAG_WINDOW_UNDECORATED)
|
||||||
else:
|
else:
|
||||||
set_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNDECORATED)
|
set_window_state(pyray.FLAG_WINDOW_UNDECORATED)
|
||||||
|
|
||||||
if is_key_pressed(pyray.KeyboardKey.KEY_H):
|
if is_key_pressed(pyray.KEY_H):
|
||||||
if not is_window_state(pyray.ConfigFlags.FLAG_WINDOW_HIDDEN):
|
if not is_window_state(pyray.FLAG_WINDOW_HIDDEN):
|
||||||
set_window_state(pyray.ConfigFlags.FLAG_WINDOW_HIDDEN)
|
set_window_state(pyray.FLAG_WINDOW_HIDDEN)
|
||||||
frames_counter = 0
|
frames_counter = 0
|
||||||
|
|
||||||
if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_HIDDEN):
|
if is_window_state(pyray.FLAG_WINDOW_HIDDEN):
|
||||||
frames_counter += 1
|
frames_counter += 1
|
||||||
if frames_counter >= 240:
|
if frames_counter >= 240:
|
||||||
clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_HIDDEN) # Show window after 3 seconds
|
clear_window_state(pyray.FLAG_WINDOW_HIDDEN) # Show window after 3 seconds
|
||||||
|
|
||||||
if is_key_pressed(pyray.KeyboardKey.KEY_N):
|
if is_key_pressed(pyray.KEY_N):
|
||||||
if not is_window_state(pyray.ConfigFlags.FLAG_WINDOW_MINIMIZED):
|
if not is_window_state(pyray.FLAG_WINDOW_MINIMIZED):
|
||||||
minimize_window()
|
minimize_window()
|
||||||
frames_counter = 0
|
frames_counter = 0
|
||||||
|
|
||||||
if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_MINIMIZED):
|
if is_window_state(pyray.FLAG_WINDOW_MINIMIZED):
|
||||||
frames_counter += 1
|
frames_counter += 1
|
||||||
if frames_counter >= 240:
|
if frames_counter >= 240:
|
||||||
restore_window() # Restore window after 3 seconds
|
restore_window() # Restore window after 3 seconds
|
||||||
|
|
||||||
if is_key_pressed(pyray.KeyboardKey.KEY_M):
|
if is_key_pressed(pyray.KEY_M):
|
||||||
if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_RESIZABLE):
|
if is_window_state(pyray.FLAG_WINDOW_RESIZABLE):
|
||||||
if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_MAXIMIZED):
|
if is_window_state(pyray.FLAG_WINDOW_MAXIMIZED):
|
||||||
restore_window()
|
restore_window()
|
||||||
else:
|
else:
|
||||||
maximize_window()
|
maximize_window()
|
||||||
|
|
||||||
if is_key_pressed(pyray.KeyboardKey.KEY_U):
|
if is_key_pressed(pyray.KEY_U):
|
||||||
if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNFOCUSED):
|
if is_window_state(pyray.FLAG_WINDOW_UNFOCUSED):
|
||||||
clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNFOCUSED)
|
clear_window_state(pyray.FLAG_WINDOW_UNFOCUSED)
|
||||||
else:
|
else:
|
||||||
set_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNFOCUSED)
|
set_window_state(pyray.FLAG_WINDOW_UNFOCUSED)
|
||||||
|
|
||||||
if is_key_pressed(pyray.KeyboardKey.KEY_T):
|
if is_key_pressed(pyray.KEY_T):
|
||||||
if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_TOPMOST):
|
if is_window_state(pyray.FLAG_WINDOW_TOPMOST):
|
||||||
clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_TOPMOST)
|
clear_window_state(pyray.FLAG_WINDOW_TOPMOST)
|
||||||
else:
|
else:
|
||||||
set_window_state(pyray.ConfigFlags.FLAG_WINDOW_TOPMOST)
|
set_window_state(pyray.FLAG_WINDOW_TOPMOST)
|
||||||
|
|
||||||
if is_key_pressed(pyray.KeyboardKey.KEY_A):
|
if is_key_pressed(pyray.KEY_A):
|
||||||
if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_ALWAYS_RUN):
|
if is_window_state(pyray.FLAG_WINDOW_ALWAYS_RUN):
|
||||||
clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_ALWAYS_RUN)
|
clear_window_state(pyray.FLAG_WINDOW_ALWAYS_RUN)
|
||||||
else:
|
else:
|
||||||
set_window_state(pyray.ConfigFlags.FLAG_WINDOW_ALWAYS_RUN)
|
set_window_state(pyray.FLAG_WINDOW_ALWAYS_RUN)
|
||||||
|
|
||||||
if is_key_pressed(pyray.KeyboardKey.KEY_V):
|
if is_key_pressed(pyray.KEY_V):
|
||||||
if is_window_state(pyray.ConfigFlags.FLAG_VSYNC_HINT):
|
if is_window_state(pyray.FLAG_VSYNC_HINT):
|
||||||
clear_window_state(pyray.ConfigFlags.FLAG_VSYNC_HINT)
|
clear_window_state(pyray.FLAG_VSYNC_HINT)
|
||||||
else:
|
else:
|
||||||
set_window_state(pyray.ConfigFlags.FLAG_VSYNC_HINT)
|
set_window_state(pyray.FLAG_VSYNC_HINT)
|
||||||
|
|
||||||
# Bouncing ball logic
|
# Bouncing ball logic
|
||||||
ball_position.x += ball_speed.x
|
ball_position.x += ball_speed.x
|
||||||
|
@ -96,7 +96,7 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
begin_drawing()
|
begin_drawing()
|
||||||
|
|
||||||
if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_TRANSPARENT):
|
if is_window_state(pyray.FLAG_WINDOW_TRANSPARENT):
|
||||||
clear_background(BLANK)
|
clear_background(BLANK)
|
||||||
else:
|
else:
|
||||||
clear_background(RAYWHITE)
|
clear_background(RAYWHITE)
|
||||||
|
@ -113,16 +113,16 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
# Draw window state info
|
# Draw window state info
|
||||||
draw_text("Following flags can be set after window creation:", 10, 60, 10, GRAY)
|
draw_text("Following flags can be set after window creation:", 10, 60, 10, GRAY)
|
||||||
flag_texts = [
|
flag_texts = [
|
||||||
("FLAG_FULLSCREEN_MODE", pyray.ConfigFlags.FLAG_FULLSCREEN_MODE),
|
("FLAG_FULLSCREEN_MODE", pyray.FLAG_FULLSCREEN_MODE),
|
||||||
("FLAG_WINDOW_RESIZABLE", pyray.ConfigFlags.FLAG_WINDOW_RESIZABLE),
|
("FLAG_WINDOW_RESIZABLE", pyray.FLAG_WINDOW_RESIZABLE),
|
||||||
("FLAG_WINDOW_UNDECORATED", pyray.ConfigFlags.FLAG_WINDOW_UNDECORATED),
|
("FLAG_WINDOW_UNDECORATED", pyray.FLAG_WINDOW_UNDECORATED),
|
||||||
("FLAG_WINDOW_HIDDEN", pyray.ConfigFlags.FLAG_WINDOW_HIDDEN),
|
("FLAG_WINDOW_HIDDEN", pyray.FLAG_WINDOW_HIDDEN),
|
||||||
("FLAG_WINDOW_MINIMIZED", pyray.ConfigFlags.FLAG_WINDOW_MINIMIZED),
|
("FLAG_WINDOW_MINIMIZED", pyray.FLAG_WINDOW_MINIMIZED),
|
||||||
("FLAG_WINDOW_MAXIMIZED", pyray.ConfigFlags.FLAG_WINDOW_MAXIMIZED),
|
("FLAG_WINDOW_MAXIMIZED", pyray.FLAG_WINDOW_MAXIMIZED),
|
||||||
("FLAG_WINDOW_UNFOCUSED", pyray.ConfigFlags.FLAG_WINDOW_UNFOCUSED),
|
("FLAG_WINDOW_UNFOCUSED", pyray.FLAG_WINDOW_UNFOCUSED),
|
||||||
("FLAG_WINDOW_TOPMOST", pyray.ConfigFlags.FLAG_WINDOW_TOPMOST),
|
("FLAG_WINDOW_TOPMOST", pyray.FLAG_WINDOW_TOPMOST),
|
||||||
("FLAG_WINDOW_ALWAYS_RUN", pyray.ConfigFlags.FLAG_WINDOW_ALWAYS_RUN),
|
("FLAG_WINDOW_ALWAYS_RUN", pyray.FLAG_WINDOW_ALWAYS_RUN),
|
||||||
("FLAG_VSYNC_HINT", pyray.ConfigFlags.FLAG_VSYNC_HINT),
|
("FLAG_VSYNC_HINT", pyray.FLAG_VSYNC_HINT),
|
||||||
]
|
]
|
||||||
y_offset = 80
|
y_offset = 80
|
||||||
for text, flag in flag_texts:
|
for text, flag in flag_texts:
|
||||||
|
@ -133,15 +133,15 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
y_offset += 20
|
y_offset += 20
|
||||||
|
|
||||||
draw_text("Following flags can only be set before window creation:", 10, 300, 10, GRAY)
|
draw_text("Following flags can only be set before window creation:", 10, 300, 10, GRAY)
|
||||||
if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_HIGHDPI):
|
if is_window_state(pyray.FLAG_WINDOW_HIGHDPI):
|
||||||
draw_text("FLAG_WINDOW_HIGHDPI: on", 10, 320, 10, LIME)
|
draw_text("FLAG_WINDOW_HIGHDPI: on", 10, 320, 10, LIME)
|
||||||
else:
|
else:
|
||||||
draw_text("FLAG_WINDOW_HIGHDPI: off", 10, 320, 10, MAROON)
|
draw_text("FLAG_WINDOW_HIGHDPI: off", 10, 320, 10, MAROON)
|
||||||
if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_TRANSPARENT):
|
if is_window_state(pyray.FLAG_WINDOW_TRANSPARENT):
|
||||||
draw_text("FLAG_WINDOW_TRANSPARENT: on", 10, 340, 10, LIME)
|
draw_text("FLAG_WINDOW_TRANSPARENT: on", 10, 340, 10, LIME)
|
||||||
else:
|
else:
|
||||||
draw_text("FLAG_WINDOW_TRANSPARENT: off", 10, 340, 10, MAROON)
|
draw_text("FLAG_WINDOW_TRANSPARENT: off", 10, 340, 10, MAROON)
|
||||||
if is_window_state(pyray.ConfigFlags.FLAG_MSAA_4X_HINT):
|
if is_window_state(pyray.FLAG_MSAA_4X_HINT):
|
||||||
draw_text("FLAG_MSAA_4X_HINT: on", 10, 360, 10, LIME)
|
draw_text("FLAG_MSAA_4X_HINT: on", 10, 360, 10, LIME)
|
||||||
else:
|
else:
|
||||||
draw_text("FLAG_MSAA_4X_HINT: off", 10, 360, 10, MAROON)
|
draw_text("FLAG_MSAA_4X_HINT: off", 10, 360, 10, MAROON)
|
||||||
|
|
|
@ -12,7 +12,7 @@ SCREEN_HEIGHT = 450
|
||||||
|
|
||||||
init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [core] example - window should close")
|
init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [core] example - window should close")
|
||||||
|
|
||||||
set_exit_key(KeyboardKey.KEY_NULL) # Disable KEY_ESCAPE to close window, X-button still works
|
set_exit_key(KEY_NULL) # Disable KEY_ESCAPE to close window, X-button still works
|
||||||
|
|
||||||
exitWindowRequested = False # Flag to request window to exit
|
exitWindowRequested = False # Flag to request window to exit
|
||||||
exitWindow = False # Flag to set window to exit
|
exitWindow = False # Flag to set window to exit
|
||||||
|
@ -26,7 +26,7 @@ while not exitWindow:
|
||||||
# Update
|
# Update
|
||||||
# ----------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------
|
||||||
# Detect if X-button or KEY_ESCAPE have been pressed to close window
|
# Detect if X-button or KEY_ESCAPE have been pressed to close window
|
||||||
if window_should_close() or is_key_pressed(KeyboardKey.KEY_ESCAPE):
|
if window_should_close() or is_key_pressed(KEY_ESCAPE):
|
||||||
exitWindowRequested = True
|
exitWindowRequested = True
|
||||||
|
|
||||||
if exitWindowRequested:
|
if exitWindowRequested:
|
||||||
|
@ -34,9 +34,9 @@ while not exitWindow:
|
||||||
# A request for close window has been issued, we can save data before closing
|
# A request for close window has been issued, we can save data before closing
|
||||||
# or just show a message asking for confirmation
|
# or just show a message asking for confirmation
|
||||||
|
|
||||||
if is_key_pressed(KeyboardKey.KEY_Y):
|
if is_key_pressed(KEY_Y):
|
||||||
exitWindow = True
|
exitWindow = True
|
||||||
elif is_key_pressed(KeyboardKey.KEY_N):
|
elif is_key_pressed(KEY_N):
|
||||||
exitWindowRequested = False
|
exitWindowRequested = False
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# python3 -m pip install pyglm
|
# python3 -m pip install pyglm
|
||||||
|
|
||||||
from math import sin, cos
|
from math import sin, cos
|
||||||
import glm # type: ignore
|
import glm
|
||||||
from raylib import rl, ffi
|
from raylib import rl, ffi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,7 @@ python3 flow-field
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys, math, time, random
|
import sys, math, time, random
|
||||||
import glm # type: ignore
|
import glm # Note package is PyGLM, not glm.
|
||||||
# Note package is PyGLM, not glm.
|
|
||||||
from raylib import rl, ffi
|
from raylib import rl, ffi
|
||||||
from raylib.colors import *
|
from raylib.colors import *
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@ Mac:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys, time
|
import sys, time
|
||||||
import glm # type: ignore
|
import glm
|
||||||
import pytweening as tween # type: ignore
|
import pytweening as tween
|
||||||
import screeninfo # type: ignore
|
import screeninfo
|
||||||
from raylib import rl, ffi
|
from raylib import rl, ffi
|
||||||
from raylib.colors import *
|
from raylib.colors import *
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import cv2 as cv # type:ignore
|
import cv2 as cv
|
||||||
from pyray import *
|
from pyray import *
|
||||||
|
|
||||||
opencv_image = cv.imread("resources/raylib_logo.jpg")
|
opencv_image = cv.imread("resources/raylib_logo.jpg")
|
||||||
|
@ -10,7 +10,7 @@ screenHeight = 450
|
||||||
init_window(screenWidth, screenHeight, "example - image loading")
|
init_window(screenWidth, screenHeight, "example - image loading")
|
||||||
|
|
||||||
pointer_to_image_data = ffi.from_buffer(opencv_image.data)
|
pointer_to_image_data = ffi.from_buffer(opencv_image.data)
|
||||||
raylib_image = Image(pointer_to_image_data, 256, 256, 1, PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8)
|
raylib_image = Image(pointer_to_image_data, 256, 256, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8)
|
||||||
texture = load_texture_from_image(raylib_image)
|
texture = load_texture_from_image(raylib_image)
|
||||||
unload_image(raylib_image)
|
unload_image(raylib_image)
|
||||||
|
|
||||||
|
|
|
@ -1,260 +0,0 @@
|
||||||
# An OO wrapper around the Vector2 struct, by @Emtyloc
|
|
||||||
|
|
||||||
from pyray import *
|
|
||||||
|
|
||||||
class Vector2Ex(list):
|
|
||||||
def __init__(self, x, y):
|
|
||||||
super(Vector2Ex, self).__init__([x, y])
|
|
||||||
|
|
||||||
@property
|
|
||||||
def x(self):
|
|
||||||
return self[0]
|
|
||||||
|
|
||||||
@x.setter
|
|
||||||
def x(self, value):
|
|
||||||
self[0]= value
|
|
||||||
|
|
||||||
@property
|
|
||||||
def y(self):
|
|
||||||
return self[1]
|
|
||||||
|
|
||||||
@y.setter
|
|
||||||
def y(self, value):
|
|
||||||
self[1]= value
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def to_Vec2(v: Vector2):
|
|
||||||
"""
|
|
||||||
Cast Vector2 to Vec2.
|
|
||||||
"""
|
|
||||||
return Vector2Ex(v.x, v.y)
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return f"{self.x}, {self.y}"
|
|
||||||
|
|
||||||
def __eq__(self, other):
|
|
||||||
if isinstance(other, Vector2Ex):
|
|
||||||
return self.x == other.x and self.y == other.y
|
|
||||||
return False
|
|
||||||
|
|
||||||
def __add__(self, other):
|
|
||||||
if isinstance(other, Vector2Ex):
|
|
||||||
return Vector2Ex(self.x + other.x, self.y + other.y)
|
|
||||||
return Vector2Ex(self.x + other, self.y + other)
|
|
||||||
|
|
||||||
def __iadd__(self, other):
|
|
||||||
if isinstance(other, Vector2Ex):
|
|
||||||
self.x += other.x
|
|
||||||
self.y += other.y
|
|
||||||
else:
|
|
||||||
res = vector2_add_value(self, other)
|
|
||||||
self.x = res.x
|
|
||||||
self.y = res.y
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __radd__(self, other):
|
|
||||||
return self + other
|
|
||||||
|
|
||||||
def __sub__(self, other):
|
|
||||||
if isinstance(other, Vector2Ex):
|
|
||||||
return Vector2Ex(self.x - other.x, self.y - other.y)
|
|
||||||
return Vector2Ex(self.x - other, self.y - other)
|
|
||||||
|
|
||||||
def __isub__(self, other):
|
|
||||||
if isinstance(other, Vector2Ex):
|
|
||||||
self.x -= other.x
|
|
||||||
self.y -= other.y
|
|
||||||
else:
|
|
||||||
self.x -= other
|
|
||||||
self.y -= other
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __rsub__(self, other):
|
|
||||||
return Vector2Ex(other - self.x, other - self.y)
|
|
||||||
|
|
||||||
def __mul__(self, other):
|
|
||||||
if isinstance(other, Vector2Ex):
|
|
||||||
res = vector2_multiply(self, other)
|
|
||||||
return self.to_Vec2(res)
|
|
||||||
return Vector2Ex(self.x * other, self.y * other)
|
|
||||||
|
|
||||||
def __imul__(self, other):
|
|
||||||
if isinstance(other, Vector2Ex):
|
|
||||||
res = vector2_multiply(self, other)
|
|
||||||
else:
|
|
||||||
res = vector2_scale(self, other)
|
|
||||||
self.x = res.x
|
|
||||||
self.y = res.y
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __truediv__(self, other):
|
|
||||||
if isinstance(other, Vector2Ex):
|
|
||||||
res = vector_2divide(self, other)
|
|
||||||
return self.to_Vec2(res)
|
|
||||||
return Vector2Ex(self.x / other, self.y / other)
|
|
||||||
|
|
||||||
def __itruediv__(self, other):
|
|
||||||
if isinstance(other, Vector2Ex):
|
|
||||||
res = vector_2divide(self, other)
|
|
||||||
else:
|
|
||||||
res = vector2_scale(self, 1/other)
|
|
||||||
self.x = res.x
|
|
||||||
self.y = res.y
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __neg__(self):
|
|
||||||
return Vector2Ex(-self.x, -self.y)
|
|
||||||
|
|
||||||
def __pos__(self):
|
|
||||||
return Vector2Ex(self.x, self.y)
|
|
||||||
|
|
||||||
def __pow__(self, exponent):
|
|
||||||
return Vector2Ex(self.x ** exponent, self.y ** exponent)
|
|
||||||
|
|
||||||
# PyRay mapped vector2 functions
|
|
||||||
|
|
||||||
def angle(self, vec2):
|
|
||||||
return vector2_angle(self, vec2)
|
|
||||||
|
|
||||||
def clamp(self, min_vec2, max_vec2):
|
|
||||||
res = vector2_clamp(self, min_vec2, max_vec2)
|
|
||||||
return self.to_Vec2(res)
|
|
||||||
|
|
||||||
def clamp_value(self, min_val: float, max_val: float):
|
|
||||||
res = vector2_clamp_value(self, min_val, max_val)
|
|
||||||
return self.to_Vec2(res)
|
|
||||||
|
|
||||||
def distance(self, vec2):
|
|
||||||
return vector_2distance(self, vec2)
|
|
||||||
|
|
||||||
def distance_sqr(self, vec2) -> float:
|
|
||||||
return vector_2distance_sqr(self, vec2)
|
|
||||||
|
|
||||||
def dot_product(self, vec2) -> float:
|
|
||||||
return vector_2dot_product(self, vec2)
|
|
||||||
|
|
||||||
def invert(self):
|
|
||||||
res = vector2_invert(self)
|
|
||||||
return self.to_Vec2(res)
|
|
||||||
|
|
||||||
def length(self):
|
|
||||||
return vector2_length(self)
|
|
||||||
|
|
||||||
def length_sqr(self) -> float:
|
|
||||||
return vector2_length_sqr(self)
|
|
||||||
|
|
||||||
def lerp(self, vec2, amount: float):
|
|
||||||
res = vector2_lerp(self, vec2, amount)
|
|
||||||
return self.to_Vec2(res)
|
|
||||||
|
|
||||||
def move_towards(self, target_vec2, max_distance: float):
|
|
||||||
res = vector2_move_towards(self, target_vec2, max_distance)
|
|
||||||
return self.to_Vec2(res)
|
|
||||||
|
|
||||||
def negate(self):
|
|
||||||
res = vector2_negate(self)
|
|
||||||
return self.to_Vec2(res)
|
|
||||||
|
|
||||||
def normalize(self):
|
|
||||||
res = vector2_normalize(self)
|
|
||||||
return self.to_Vec2(res)
|
|
||||||
|
|
||||||
def reflect(self, normal_vec2):
|
|
||||||
res = vector2_reflect(self, normal_vec2)
|
|
||||||
return self.to_Vec2(res)
|
|
||||||
|
|
||||||
def rotate(self, angle: float):
|
|
||||||
res = vector2_rotate(self, angle)
|
|
||||||
return self.to_Vec2(res)
|
|
||||||
|
|
||||||
def transform(self, mat: Matrix):
|
|
||||||
res = vector2_transform(self, mat)
|
|
||||||
return self.to_Vec2(res)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def line_angle(start_vec2, end_vec2) -> float:
|
|
||||||
return vector2_line_angle(start_vec2, end_vec2)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def one():
|
|
||||||
return Vector2Ex(1, 1)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def zero():
|
|
||||||
return Vector2Ex(0, 0)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
# Arithmetic ops
|
|
||||||
v1 = Vector2Ex(5, 5)
|
|
||||||
v2 = Vector2Ex(10, 10)
|
|
||||||
|
|
||||||
print(v1 + v2) # 15, 15
|
|
||||||
print(v1 - v2) # -5, -5
|
|
||||||
|
|
||||||
print(v1 * v2) # 50.0, 50.0
|
|
||||||
print(v1 / v2) # 0.5, 0.5
|
|
||||||
|
|
||||||
print(v1 * 2) # 10, 10
|
|
||||||
print(v2 / 2) # 5.0, 5.0
|
|
||||||
|
|
||||||
v1+=v2
|
|
||||||
print(v1) #15, 15
|
|
||||||
v2-=v1
|
|
||||||
print(v2) #-5, -5
|
|
||||||
|
|
||||||
v1/=-v2
|
|
||||||
print(v1) #3.0, 3.0
|
|
||||||
v2*=v1
|
|
||||||
print(v2) #-15.0, -15.0
|
|
||||||
|
|
||||||
v3 = Vector2Ex(3, 5)
|
|
||||||
print(v3 ** 2) #9, 25
|
|
||||||
|
|
||||||
v1 = Vector2Ex.one()
|
|
||||||
print(v1)
|
|
||||||
|
|
||||||
v0 = Vector2Ex.zero()
|
|
||||||
print(v0)
|
|
||||||
|
|
||||||
# Vector2 pyray methods
|
|
||||||
v1 = Vector2Ex(3, 4)
|
|
||||||
v2 = Vector2Ex(1, 2)
|
|
||||||
v_min = Vector2Ex(0, 0)
|
|
||||||
v_max = Vector2Ex(5, 5)
|
|
||||||
|
|
||||||
print("Angle:", v1.angle(v2))
|
|
||||||
|
|
||||||
print("Clamp:", v1.clamp(v_min, v_max))
|
|
||||||
|
|
||||||
print("Clamp value:", v1.clamp_value(1.5, 3.5))
|
|
||||||
|
|
||||||
print("Distance:", v1.distance(v2))
|
|
||||||
|
|
||||||
print("Distance Sqr:", v1.distance_sqr(v2))
|
|
||||||
|
|
||||||
print("Dot Product:", v1.dot_product(v2))
|
|
||||||
|
|
||||||
print("Invert:", v1.invert())
|
|
||||||
|
|
||||||
print("Length:", v1.length())
|
|
||||||
|
|
||||||
print("Length Sqr:", v1.length_sqr())
|
|
||||||
|
|
||||||
print("Lerp:", v1.lerp(v2, 0.5))
|
|
||||||
|
|
||||||
print("Line Angle:", Vector2Ex.line_angle(v1, v2))
|
|
||||||
|
|
||||||
print("Move Towards:", v1.move_towards(v2, 0.5))
|
|
||||||
|
|
||||||
print("Negate:", v1.negate())
|
|
||||||
|
|
||||||
print("Normalize:", v1.normalize())
|
|
||||||
|
|
||||||
print("Reflect:", v1.reflect(v2))
|
|
||||||
|
|
||||||
print("Rotate:", v1.rotate(45))
|
|
||||||
|
|
||||||
# I don't know why this not work
|
|
||||||
# mat = Matrix2x2(1, 0, 0, 1)
|
|
||||||
# print("Transform:", v1.transform(mat))
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
import pyray as ray
|
import pyray as ray
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,11 +13,11 @@ camera.position = ray.Vector3( 10.0, 10.0, 10.0 ) # Camera position
|
||||||
camera.target = ray.Vector3( 0.0, 0.0, 0.0 ) # Camera looking at point
|
camera.target = ray.Vector3( 0.0, 0.0, 0.0 ) # Camera looking at point
|
||||||
camera.up = ray.Vector3( 0.0, 1.0, 0.0 ) # Camera up vector (rotation towards target)
|
camera.up = ray.Vector3( 0.0, 1.0, 0.0 ) # Camera up vector (rotation towards target)
|
||||||
camera.fovy = 45.0 # Camera field-of-view Y
|
camera.fovy = 45.0 # Camera field-of-view Y
|
||||||
camera.projection = ray.CameraProjection.CAMERA_PERSPECTIVE # Camera mode type
|
camera.projection = ray.CAMERA_PERSPECTIVE # Camera mode type
|
||||||
|
|
||||||
model = ray.load_model("resources/models/iqm/guy.iqm") # Load the animated model mesh and basic data
|
model = ray.load_model("resources/models/iqm/guy.iqm") # Load the animated model mesh and basic data
|
||||||
texture = ray.load_texture("resources/models/iqm/guytex.png") # Load model texture and set material
|
texture = ray.load_texture("resources/models/iqm/guytex.png") # Load model texture and set material
|
||||||
ray.set_material_texture(model.materials, ray.MaterialMapIndex.MATERIAL_MAP_ALBEDO, texture) # Set model material map texture
|
ray.set_material_texture(model.materials, ray.MATERIAL_MAP_ALBEDO, texture) # Set model material map texture
|
||||||
|
|
||||||
position = ( 0., 0., 0. ) # Set model position
|
position = ( 0., 0., 0. ) # Set model position
|
||||||
|
|
||||||
|
@ -32,10 +33,10 @@ ray.set_target_fps(60) # Set our game to run at 60 frames-per-
|
||||||
while not ray.window_should_close(): # Detect window close button or ESC key
|
while not ray.window_should_close(): # Detect window close button or ESC key
|
||||||
# Update
|
# Update
|
||||||
#----------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------
|
||||||
ray.update_camera(camera, ray.CameraMode.CAMERA_FREE)
|
ray.update_camera(camera, ray.CAMERA_FREE)
|
||||||
|
|
||||||
# Play animation when spacebar is held down
|
# Play animation when spacebar is held down
|
||||||
if ray.is_key_down(ray.KeyboardKey.KEY_SPACE):
|
if ray.is_key_down(ray.KEY_SPACE):
|
||||||
anim_frame_counter+=1
|
anim_frame_counter+=1
|
||||||
ray.update_model_animation(model, anims[0], anim_frame_counter)
|
ray.update_model_animation(model, anims[0], anim_frame_counter)
|
||||||
if anim_frame_counter >= anims[0].frameCount:
|
if anim_frame_counter >= anims[0].frameCount:
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#type: ignore
|
|
||||||
import raylib as rl
|
import raylib as rl
|
||||||
from raylib.colors import *
|
from raylib.colors import *
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ camera.position = Vector3(30.0, 20.0, 30.0) # Camera position
|
||||||
camera.target = Vector3(0.0, 0.0, 0.0) # Camera looking at point
|
camera.target = Vector3(0.0, 0.0, 0.0) # Camera looking at point
|
||||||
camera.up = Vector3(0.0, 1.0, 0.0) # Camera up vector (rotation towards target)
|
camera.up = Vector3(0.0, 1.0, 0.0) # Camera up vector (rotation towards target)
|
||||||
camera.fovy = 70.0 # Camera field-of-view Y
|
camera.fovy = 70.0 # Camera field-of-view Y
|
||||||
camera.projection = pyray.CameraProjection.CAMERA_PERSPECTIVE # Camera projection type
|
camera.projection = pyray.CAMERA_PERSPECTIVE # Camera projection type
|
||||||
|
|
||||||
# Specify the amount of blocks in each direction
|
# Specify the amount of blocks in each direction
|
||||||
numBlocks = 15
|
numBlocks = 15
|
||||||
|
|
|
@ -118,18 +118,18 @@ class Camera:
|
||||||
# GLFW3: Error callback
|
# GLFW3: Error callback
|
||||||
@ffi.callback("void(int, const char *)")
|
@ffi.callback("void(int, const char *)")
|
||||||
def ErrorCallback(error: int, description: bytes):
|
def ErrorCallback(error: int, description: bytes):
|
||||||
print("%r" % description, file=sys.stderr)
|
print("%s" % description, file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
# GLFW3: Keyboard callback
|
# GLFW3: Keyboard callback
|
||||||
@ffi.callback("void(GLFWwindow *, int, int, int, int)")
|
@ffi.callback("void(GLFWwindow *, int, int, int, int)")
|
||||||
def KeyCallback(window, key: int, scancode: int, action: int, mods: int):
|
def KeyCallback(window: 'GLFWwindow', key: int, scancode: int, action: int, mods: int):
|
||||||
if key == GLFW_KEY_ESCAPE and action == GLFW_PRESS:
|
if key == GLFW_KEY_ESCAPE and action == GLFW_PRESS:
|
||||||
rl.glfwSetWindowShouldClose(window, GLFW_TRUE)
|
rl.glfwSetWindowShouldClose(window, GLFW_TRUE)
|
||||||
|
|
||||||
|
|
||||||
# Draw rectangle using rlgl OpenGL 1.1 style coding (translated to OpenGL 3.3 internally)
|
# Draw rectangle using rlgl OpenGL 1.1 style coding (translated to OpenGL 3.3 internally)
|
||||||
def DrawRectangleV(position, size, color: Color):
|
def DrawRectangleV(position: 'raylib.Vector2', size: 'raylib.Vector2', color: Color):
|
||||||
rl.rlBegin(RL_TRIANGLES)
|
rl.rlBegin(RL_TRIANGLES)
|
||||||
rl.rlColor4ub(color.r, color.g, color.b, color.a)
|
rl.rlColor4ub(color.r, color.g, color.b, color.a)
|
||||||
rl.rlVertex2f(position.x, position.y)
|
rl.rlVertex2f(position.x, position.y)
|
||||||
|
@ -168,7 +168,7 @@ def DrawGrid(slices: int, spacing: float):
|
||||||
|
|
||||||
# Draw cube
|
# Draw cube
|
||||||
# NOTE: Cube position is the center position
|
# NOTE: Cube position is the center position
|
||||||
def DrawCube(position, width: float, height: float, length: float, color: Color):
|
def DrawCube(position: 'raylib.Vector3', width: float, height: float, length: float, color: Color):
|
||||||
x: float = 0.0
|
x: float = 0.0
|
||||||
y: float = 0.0
|
y: float = 0.0
|
||||||
z: float = 0.0
|
z: float = 0.0
|
||||||
|
@ -242,7 +242,7 @@ def DrawCube(position, width: float, height: float, length: float, color: Color)
|
||||||
|
|
||||||
|
|
||||||
#Draw cube wires
|
#Draw cube wires
|
||||||
def DrawCubeWires(position, width: float, height: float, length: float, color: Color):
|
def DrawCubeWires(position: 'raylib.Vector3', width: float, height: float, length: float, color: Color):
|
||||||
x: float = 0.0
|
x: float = 0.0
|
||||||
y: float = 0.0
|
y: float = 0.0
|
||||||
z: float = 0.0
|
z: float = 0.0
|
||||||
|
|
|
@ -2,9 +2,13 @@
|
||||||
raylib [physac] example - physics demo
|
raylib [physac] example - physics demo
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from pyray import Vector2
|
||||||
from raylib import *
|
from raylib import *
|
||||||
|
from raylib.colors import (
|
||||||
|
BLACK,
|
||||||
|
GREEN,
|
||||||
|
WHITE
|
||||||
|
)
|
||||||
|
|
||||||
SCREEN_WIDTH = 800
|
SCREEN_WIDTH = 800
|
||||||
SCREEN_HEIGHT = 450
|
SCREEN_HEIGHT = 450
|
||||||
|
@ -14,10 +18,10 @@ InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, b'[physac] Basic demo')
|
||||||
|
|
||||||
InitPhysics()
|
InitPhysics()
|
||||||
|
|
||||||
floor = CreatePhysicsBodyRectangle((SCREEN_WIDTH/2, SCREEN_HEIGHT), 500, 100, 10)
|
floor = CreatePhysicsBodyRectangle(Vector2(SCREEN_WIDTH/2, SCREEN_HEIGHT), 500, 100, 10)
|
||||||
floor.enabled = False
|
floor.enabled = False
|
||||||
|
|
||||||
circle = CreatePhysicsBodyCircle((SCREEN_WIDTH/2, SCREEN_HEIGHT/2), 45, 10)
|
circle = CreatePhysicsBodyCircle(Vector2(SCREEN_WIDTH/2, SCREEN_HEIGHT/2), 45, 10)
|
||||||
circle.enabled = False
|
circle.enabled = False
|
||||||
|
|
||||||
SetTargetFPS(60)
|
SetTargetFPS(60)
|
||||||
|
@ -25,15 +29,15 @@ SetTargetFPS(60)
|
||||||
while not WindowShouldClose():
|
while not WindowShouldClose():
|
||||||
# Update
|
# Update
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
UpdatePhysics() # Update physics system
|
||||||
|
|
||||||
if IsKeyPressed(KEY_R): # Reset physics system
|
if IsKeyPressed(KEY_R): # Reset physics system
|
||||||
ClosePhysics()
|
ResetPhysics()
|
||||||
InitPhysics()
|
|
||||||
|
|
||||||
floor = CreatePhysicsBodyRectangle((SCREEN_WIDTH/2, SCREEN_HEIGHT), 500, 100, 10)
|
floor = CreatePhysicsBodyRectangle(Vector2(SCREEN_WIDTH/2, SCREEN_HEIGHT), 500, 100, 10)
|
||||||
floor.enabled = False
|
floor.enabled = False
|
||||||
|
|
||||||
circle = CreatePhysicsBodyCircle((SCREEN_WIDTH/2, SCREEN_HEIGHT/2), 45, 10)
|
circle = CreatePhysicsBodyCircle(Vector2(SCREEN_WIDTH/2, SCREEN_HEIGHT/2), 45, 10)
|
||||||
circle.enabled = False
|
circle.enabled = False
|
||||||
|
|
||||||
# Physics body creation inputs
|
# Physics body creation inputs
|
||||||
|
|
|
@ -4,20 +4,20 @@ import raylib as rl
|
||||||
class LightSystem:
|
class LightSystem:
|
||||||
MAX_LIGHTS = 4 #// Max dynamic lights supported by shader
|
MAX_LIGHTS = 4 #// Max dynamic lights supported by shader
|
||||||
lightsCount = 0
|
lightsCount = 0
|
||||||
lights: list['Light'] = []
|
lights = []
|
||||||
|
|
||||||
def __init__(self, ambient = [ 0.2, 0.2, 0.2, 1.0 ], *ls):
|
def __init__(self, ambient = [ 0.2, 0.2, 0.2, 1.0 ], *ls):
|
||||||
self.shader = rl.LoadShader(b"resources/shaders/fogLight.vs",
|
self.shader = rl.LoadShader(b"resources/shaders/fogLight.vs",
|
||||||
b"resources/shaders/fogLight.fs");
|
b"resources/shaders/fogLight.fs");
|
||||||
|
|
||||||
#// Get some shader loactions
|
#// Get some shader loactions
|
||||||
self.shader.locs[rl.SHADER_LOC_MATRIX_MODEL] = rl.GetShaderLocation(self.shader, b"matModel")
|
self.shader.locs[rl.SHADER_LOC_MATRIX_MODEL] = rl.GetShaderLocation(self.shader, b"matModel");
|
||||||
self.shader.locs[rl.SHADER_LOC_VECTOR_VIEW] = rl.GetShaderLocation(self.shader, b"viewPos")
|
self.shader.locs[rl.SHADER_LOC_VECTOR_VIEW] = rl.GetShaderLocation(self.shader, b"viewPos");
|
||||||
|
|
||||||
#// ambient light level
|
#// ambient light level
|
||||||
self.ambientLoc = rl.GetShaderLocation(self.shader, b"ambient")
|
self.ambientLoc = rl.GetShaderLocation(self.shader, b"ambient");
|
||||||
v = rl.ffi.new("struct Vector4 *", ambient)
|
v = rl.ffi.new("struct Vector4 *", ambient)
|
||||||
rl.SetShaderValue(self.shader, self.ambientLoc, v, rl.SHADER_UNIFORM_VEC4)
|
rl.SetShaderValue(self.shader, self.ambientLoc, v, rl.SHADER_UNIFORM_VEC4);
|
||||||
|
|
||||||
for light in ls:
|
for light in ls:
|
||||||
self.add(light)
|
self.add(light)
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
#version 330
|
|
||||||
|
|
||||||
// Input vertex attributes (from vertex shader)
|
|
||||||
in vec2 fragTexCoord;
|
|
||||||
in vec4 fragColor;
|
|
||||||
|
|
||||||
// Input uniform values
|
|
||||||
uniform sampler2D texture0;
|
|
||||||
uniform vec4 colDiffuse;
|
|
||||||
|
|
||||||
// Output fragment color
|
|
||||||
out vec4 finalColor;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
vec4 texelColor = texture(texture0, fragTexCoord);
|
|
||||||
|
|
||||||
finalColor = texelColor*colDiffuse*fragColor;
|
|
||||||
gl_FragDepth = 1.0 - finalColor.z;
|
|
||||||
}
|
|
|
@ -48,7 +48,7 @@ screenWidth = 1200
|
||||||
screenHeight = 720
|
screenHeight = 720
|
||||||
|
|
||||||
rl.SetConfigFlags(
|
rl.SetConfigFlags(
|
||||||
rl.FLAG_MSAA_4X_HINT | rl.FLAG_WINDOW_RESIZABLE) # Enable Multi Sampling Anti Aliasing 4x (if available)
|
rl.FLAG_MSAA_4X_HINT | rl.FLAG_WINDOW_RESIZABLE); # Enable Multi Sampling Anti Aliasing 4x (if available)
|
||||||
rl.InitWindow(screenWidth, screenHeight, b"raylib [shaders] example - basic lighting")
|
rl.InitWindow(screenWidth, screenHeight, b"raylib [shaders] example - basic lighting")
|
||||||
|
|
||||||
camera = rl.ffi.new('struct Camera3D *', [
|
camera = rl.ffi.new('struct Camera3D *', [
|
||||||
|
|
|
@ -1,123 +0,0 @@
|
||||||
from pyray import *
|
|
||||||
import raylib as rl
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------------
|
|
||||||
# Define custom functions required for the example
|
|
||||||
#------------------------------------------------------------------------------------
|
|
||||||
# Load custom render texture, create a writable depth texture buffer
|
|
||||||
def LoadRenderTextureDepthTex(width, height):
|
|
||||||
|
|
||||||
target = RenderTexture()
|
|
||||||
|
|
||||||
target.id = rl_load_framebuffer() # Load an empty framebuffer
|
|
||||||
|
|
||||||
if target.id > 0:
|
|
||||||
|
|
||||||
rl_enable_framebuffer(target.id)
|
|
||||||
|
|
||||||
# Create color texture (default to RGBA)
|
|
||||||
target.texture.id = rl_load_texture(None, width, height, PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1)
|
|
||||||
target.texture.width = width
|
|
||||||
target.texture.height = height
|
|
||||||
target.texture.format = PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
|
|
||||||
target.texture.mipmaps = 1
|
|
||||||
|
|
||||||
# Create depth texture buffer (instead of raylib default renderbuffer)
|
|
||||||
target.depth.id = rl_load_texture_depth(width, height, False)
|
|
||||||
target.depth.width = width
|
|
||||||
target.depth.height = height
|
|
||||||
target.depth.format = 19 #DEPTH_COMPONENT_24BIT?
|
|
||||||
target.depth.mipmaps = 1
|
|
||||||
|
|
||||||
# Attach color texture and depth texture to FBO
|
|
||||||
rl_framebuffer_attach(target.id, target.texture.id, rl.RL_ATTACHMENT_COLOR_CHANNEL0, rl.RL_ATTACHMENT_TEXTURE2D, 0)
|
|
||||||
rl_framebuffer_attach(target.id, target.depth.id, rl.RL_ATTACHMENT_DEPTH, rl.RL_ATTACHMENT_TEXTURE2D, 0)
|
|
||||||
|
|
||||||
# Check if fbo is complete with attachments (valid)
|
|
||||||
if rl_framebuffer_complete(target.id):
|
|
||||||
print(f"FBO: [{target.id}] Framebuffer object created successfully")
|
|
||||||
|
|
||||||
rl_disable_framebuffer()
|
|
||||||
|
|
||||||
else:
|
|
||||||
print("FBO: Framebuffer object can not be created")
|
|
||||||
|
|
||||||
return target
|
|
||||||
|
|
||||||
|
|
||||||
# Unload render texture from GPU memory (VRAM)
|
|
||||||
def UnloadRenderTextureDepthTex(target):
|
|
||||||
|
|
||||||
if target.id > 0:
|
|
||||||
|
|
||||||
# Color texture attached to FBO is deleted
|
|
||||||
rl_unload_texture(target.texture.id)
|
|
||||||
rl_unload_texture(target.depth.id)
|
|
||||||
|
|
||||||
# NOTE: Depth texture is automatically
|
|
||||||
# queried and deleted before deleting framebuffer
|
|
||||||
rl_unload_framebuffer(target.id)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
screenWidth = 800
|
|
||||||
screenHeight = 450
|
|
||||||
|
|
||||||
init_window(screenWidth, screenHeight, "raylib [shaders] example - write depth buffer")
|
|
||||||
|
|
||||||
# The shader inverts the depth buffer by writing into it by `gl_FragDepth = 1 - gl_FragCoord.z`
|
|
||||||
shader = load_shader("","resources/shaders/glsl330/write_depth.fs")
|
|
||||||
|
|
||||||
# Use Customized function to create writable depth texture buffer
|
|
||||||
target = LoadRenderTextureDepthTex(screenWidth, screenHeight)
|
|
||||||
|
|
||||||
# Define the camera to look into our 3d world
|
|
||||||
camera = Camera3D((2.0, 2.0, 3.0),(0.0, 0.5, 0.0),(0.0, 1.0, 0.0),45.0, CameraProjection.CAMERA_PERSPECTIVE)
|
|
||||||
|
|
||||||
|
|
||||||
set_target_fps(60) # Set our game to run at 60 frames-per-second
|
|
||||||
#--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# Main game loop
|
|
||||||
while not window_should_close(): # Detect window close button or ESC key
|
|
||||||
|
|
||||||
# Update
|
|
||||||
#----------------------------------------------------------------------------------
|
|
||||||
update_camera(camera, CameraMode.CAMERA_ORBITAL)
|
|
||||||
#----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# Draw
|
|
||||||
#----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# Draw into our custom render texture (framebuffer)
|
|
||||||
begin_texture_mode(target)
|
|
||||||
clear_background(WHITE)
|
|
||||||
|
|
||||||
begin_mode_3d(camera)
|
|
||||||
begin_shader_mode(shader)
|
|
||||||
draw_cube_wires_v((0.0, 0.5, 1.0) , (1.0,1.0, 1.0), RED)
|
|
||||||
draw_cube_v((0.0, 0.5, 1.0) , (1.0, 1.0, 1.0) , PURPLE)
|
|
||||||
draw_cube_wires_v((0.0, 0.5, -1.0), (1.0, 1.0, 1.0) , DARKGREEN)
|
|
||||||
draw_cube_v((0.0, 0.5, -1.0) , (1.0, 1.0, 1.0) , YELLOW)
|
|
||||||
draw_grid(10, 1.0)
|
|
||||||
end_shader_mode()
|
|
||||||
end_mode_3d()
|
|
||||||
end_texture_mode()
|
|
||||||
|
|
||||||
# Draw into screen our custom render texture
|
|
||||||
begin_drawing()
|
|
||||||
clear_background(RAYWHITE)
|
|
||||||
|
|
||||||
draw_texture_rec(target.texture, Rectangle(0, 0, screenWidth, -screenHeight) , (0, 0) , WHITE)
|
|
||||||
draw_fps(10, 10)
|
|
||||||
end_drawing()
|
|
||||||
|
|
||||||
|
|
||||||
# De-Initialization
|
|
||||||
#--------------------------------------------------------------------------------------
|
|
||||||
UnloadRenderTextureDepthTex(target)
|
|
||||||
unload_shader(shader)
|
|
||||||
|
|
||||||
close_window() # Close window and OpenGL context
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,19 @@
|
||||||
import pyray
|
import pyray
|
||||||
|
from raylib.colors import (
|
||||||
|
RAYWHITE,
|
||||||
|
DARKGRAY,
|
||||||
|
DARKBLUE,
|
||||||
|
SKYBLUE,
|
||||||
|
MAROON,
|
||||||
|
ORANGE,
|
||||||
|
RED,
|
||||||
|
VIOLET,
|
||||||
|
BEIGE,
|
||||||
|
BROWN,
|
||||||
|
BLACK,
|
||||||
|
GREEN,
|
||||||
|
GOLD
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# Initialization
|
# Initialization
|
||||||
|
@ -18,37 +33,37 @@ while not pyray.window_should_close():
|
||||||
# Draw
|
# Draw
|
||||||
pyray.begin_drawing()
|
pyray.begin_drawing()
|
||||||
|
|
||||||
pyray.clear_background(pyray.RAYWHITE)
|
pyray.clear_background(RAYWHITE)
|
||||||
|
|
||||||
pyray.draw_text("some basic shapes available on raylib", 20, 20, 20, pyray.DARKGRAY)
|
pyray.draw_text("some basic shapes available on raylib", 20, 20, 20, DARKGRAY)
|
||||||
|
|
||||||
# Circle shapes and lines
|
# Circle shapes and lines
|
||||||
pyray.draw_circle(screenWidth // 5, 120, 35, pyray.DARKBLUE)
|
pyray.draw_circle(screenWidth // 5, 120, 35, DARKBLUE)
|
||||||
pyray.draw_circle_gradient(screenWidth // 5, 220, 60, pyray.GREEN, pyray.SKYBLUE)
|
pyray.draw_circle_gradient(screenWidth // 5, 220, 60, GREEN, SKYBLUE)
|
||||||
pyray.draw_circle_lines(screenWidth // 5, 340, 80, pyray.DARKBLUE)
|
pyray.draw_circle_lines(screenWidth // 5, 340, 80, DARKBLUE)
|
||||||
|
|
||||||
# Rectangle shapes and lines
|
# Rectangle shapes and lines
|
||||||
pyray.draw_rectangle(screenWidth // 4 * 2 - 60, 100, 120, 60, pyray.RED)
|
pyray.draw_rectangle(screenWidth // 4 * 2 - 60, 100, 120, 60, RED)
|
||||||
pyray.draw_rectangle_gradient_h(screenWidth // 4 * 2 - 90, 170, 180, 130, pyray.MAROON, pyray.GOLD)
|
pyray.draw_rectangle_gradient_h(screenWidth // 4 * 2 - 90, 170, 180, 130, MAROON, GOLD)
|
||||||
pyray.draw_rectangle_lines(screenWidth // 4 * 2 - 40, 320, 80, 60, pyray.ORANGE)
|
pyray.draw_rectangle_lines(screenWidth // 4 * 2 - 40, 320, 80, 60, ORANGE)
|
||||||
|
|
||||||
# Triangle shapes and lines
|
# Triangle shapes and lines
|
||||||
pyray.draw_triangle(pyray.Vector2(screenWidth / 4.0 * 3.0, 80.0),
|
pyray.draw_triangle(pyray.Vector2(screenWidth / 4.0 * 3.0, 80.0),
|
||||||
pyray.Vector2(screenWidth / 4.0 * 3.0 - 60.0, 150.0),
|
pyray.Vector2(screenWidth / 4.0 * 3.0 - 60.0, 150.0),
|
||||||
pyray.Vector2(screenWidth / 4.0 * 3.0 + 60.0, 150.0), pyray.VIOLET)
|
pyray.Vector2(screenWidth / 4.0 * 3.0 + 60.0, 150.0), VIOLET)
|
||||||
|
|
||||||
pyray.draw_triangle_lines(pyray.Vector2(screenWidth / 4.0 * 3.0, 160.0),
|
pyray.draw_triangle_lines(pyray.Vector2(screenWidth / 4.0 * 3.0, 160.0),
|
||||||
pyray.Vector2(screenWidth / 4.0 * 3.0 - 20.0, 230.0),
|
pyray.Vector2(screenWidth / 4.0 * 3.0 - 20.0, 230.0),
|
||||||
pyray.Vector2(screenWidth / 4.0 * 3.0 + 20.0, 230.0), pyray.DARKBLUE)
|
pyray.Vector2(screenWidth / 4.0 * 3.0 + 20.0, 230.0), DARKBLUE)
|
||||||
|
|
||||||
# Polygon shapes and lines
|
# Polygon shapes and lines
|
||||||
pyray.draw_poly(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 80, rotation, pyray.BROWN)
|
pyray.draw_poly(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 80, rotation, BROWN)
|
||||||
pyray.draw_poly_lines(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 90, rotation, pyray.BROWN)
|
pyray.draw_poly_lines(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 90, rotation, BROWN)
|
||||||
pyray.draw_poly_lines_ex(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 85, rotation, 6, pyray.BEIGE)
|
pyray.draw_poly_lines_ex(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 85, rotation, 6, BEIGE)
|
||||||
|
|
||||||
# NOTE: We draw all LINES based shapes together to optimize internal drawing,
|
# NOTE: We draw all LINES based shapes together to optimize internal drawing,
|
||||||
# this way, all LINES are rendered in a single draw pass
|
# this way, all LINES are rendered in a single draw pass
|
||||||
pyray.draw_line(18, 42, screenWidth - 18, 42, pyray.BLACK)
|
pyray.draw_line(18, 42, screenWidth - 18, 42, BLACK)
|
||||||
|
|
||||||
pyray.end_drawing()
|
pyray.end_drawing()
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ pyray.set_target_fps(60)
|
||||||
# Main game loop
|
# Main game loop
|
||||||
while not pyray.window_should_close():
|
while not pyray.window_should_close():
|
||||||
# Update
|
# Update
|
||||||
if pyray.is_key_pressed(pyray.KeyboardKey.KEY_SPACE):
|
if pyray.is_key_pressed(pyray.KEY_SPACE):
|
||||||
pause = not pause
|
pause = not pause
|
||||||
|
|
||||||
if not pause:
|
if not pause:
|
||||||
|
|
|
@ -12,6 +12,13 @@
|
||||||
#********************************************************************************************/
|
#********************************************************************************************/
|
||||||
|
|
||||||
import pyray
|
import pyray
|
||||||
|
from raylib.colors import (
|
||||||
|
RAYWHITE,
|
||||||
|
LIGHTGRAY,
|
||||||
|
DARKGRAY,
|
||||||
|
GOLD,
|
||||||
|
MAROON,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
SCREEN_WIDTH = 800
|
SCREEN_WIDTH = 800
|
||||||
|
@ -43,17 +50,17 @@ while not pyray.window_should_close(): #// Detect window close button or ESC ke
|
||||||
#// Draw
|
#// Draw
|
||||||
#//----------------------------------------------------------------------------------
|
#//----------------------------------------------------------------------------------
|
||||||
pyray.begin_drawing()
|
pyray.begin_drawing()
|
||||||
pyray.clear_background(pyray.RAYWHITE)
|
pyray.clear_background(RAYWHITE)
|
||||||
|
|
||||||
pyray.draw_line(560,0,560,pyray.get_screen_height(),pyray.fade(pyray.LIGHTGRAY,0.6))
|
pyray.draw_line(560,0,560,pyray.get_screen_height(),pyray.fade(LIGHTGRAY,0.6))
|
||||||
pyray.draw_rectangle(560,0,pyray.get_screen_width()-500,pyray.get_screen_height(),pyray.fade(pyray.LIGHTGRAY,0.3))
|
pyray.draw_rectangle(560,0,pyray.get_screen_width()-500,pyray.get_screen_height(),pyray.fade(LIGHTGRAY,0.3))
|
||||||
|
|
||||||
if drawRect:
|
if drawRect:
|
||||||
pyray.draw_rectangle_rec(rec,pyray.fade(pyray.GOLD,0.6))
|
pyray.draw_rectangle_rec(rec,pyray.fade(GOLD,0.6))
|
||||||
if drawRoundedRect:
|
if drawRoundedRect:
|
||||||
pyray.draw_rectangle_rounded(rec,roundness,segments,pyray.fade(pyray.MAROON,0.2))
|
pyray.draw_rectangle_rounded(rec,roundness,segments,pyray.fade(MAROON,0.2))
|
||||||
if drawRoundedLines:
|
if drawRoundedLines:
|
||||||
pyray.draw_rectangle_rounded_lines(rec,roundness,segments,pyray.fade(pyray.MAROON,0.4))
|
pyray.draw_rectangle_rounded_lines(rec,roundness,segments,lineThick,pyray.fade(MAROON,0.4))
|
||||||
|
|
||||||
#// Draw GUI controls
|
#// Draw GUI controls
|
||||||
#//------------------------------------------------------------------------------
|
#//------------------------------------------------------------------------------
|
||||||
|
@ -72,7 +79,7 @@ while not pyray.window_should_close(): #// Detect window close button or ESC ke
|
||||||
# drawRect = pyray.gui_check_box(pyray.Rectangle(640,380,20,20),"DrawRect",drawRect)
|
# drawRect = pyray.gui_check_box(pyray.Rectangle(640,380,20,20),"DrawRect",drawRect)
|
||||||
#//------------------------------------------------------------------------------
|
#//------------------------------------------------------------------------------
|
||||||
|
|
||||||
pyray.draw_text( "MANUAL" if segments >= 4 else "AUTO" , 640, 280, 10, pyray.MAROON if segments >= 4 else pyray.DARKGRAY)
|
pyray.draw_text( "MANUAL" if segments >= 4 else "AUTO" , 640, 280, 10, MAROON if segments >= 4 else DARKGRAY)
|
||||||
pyray.draw_fps(10,10)
|
pyray.draw_fps(10,10)
|
||||||
pyray.end_drawing()
|
pyray.end_drawing()
|
||||||
#//------------------------------------------------------------------------------
|
#//------------------------------------------------------------------------------
|
||||||
|
|
|
@ -5,7 +5,13 @@ raylib [shapes] example - Following Eyes
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from pyray import *
|
from pyray import *
|
||||||
|
from raylib.colors import (
|
||||||
|
RAYWHITE,
|
||||||
|
BROWN,
|
||||||
|
BLACK,
|
||||||
|
LIGHTGRAY,
|
||||||
|
DARKGREEN,
|
||||||
|
)
|
||||||
from math import (
|
from math import (
|
||||||
atan2,
|
atan2,
|
||||||
cos,
|
cos,
|
||||||
|
|
|
@ -5,6 +5,11 @@ raylib [shapes] example - Lines Bezier
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from pyray import *
|
from pyray import *
|
||||||
|
from raylib.colors import (
|
||||||
|
RAYWHITE,
|
||||||
|
GRAY,
|
||||||
|
RED
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -4,7 +4,11 @@ raylib [shapes] example - Logo Raylib
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from pyray import *
|
from pyray import *
|
||||||
|
from raylib.colors import (
|
||||||
|
RAYWHITE,
|
||||||
|
BLACK,
|
||||||
|
GRAY
|
||||||
|
)
|
||||||
|
|
||||||
# Initialization
|
# Initialization
|
||||||
screenWidth = 800
|
screenWidth = 800
|
||||||
|
|
|
@ -38,9 +38,9 @@ bunnies = []
|
||||||
for i in range(0, MAX_BUNNIES):
|
for i in range(0, MAX_BUNNIES):
|
||||||
bunnies.append(Bunny())
|
bunnies.append(Bunny())
|
||||||
|
|
||||||
bunniesCount = 0 # Bunnies counter
|
bunniesCount = 0; # Bunnies counter
|
||||||
|
|
||||||
SetTargetFPS(60) # Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); # Set our game to run at 60 frames-per-second
|
||||||
#//--------------------------------------------------------------------------------------
|
#//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#// Main game loop
|
#// Main game loop
|
||||||
|
@ -63,8 +63,8 @@ while not WindowShouldClose(): #// Detect window close button or ESC key
|
||||||
|
|
||||||
# // Update bunnies
|
# // Update bunnies
|
||||||
for i in range(0, bunniesCount):
|
for i in range(0, bunniesCount):
|
||||||
bunnies[i].position.x += bunnies[i].speed.x
|
bunnies[i].position.x += bunnies[i].speed.x;
|
||||||
bunnies[i].position.y += bunnies[i].speed.y
|
bunnies[i].position.y += bunnies[i].speed.y;
|
||||||
|
|
||||||
if ((bunnies[i].position.x + texBunny.width/2) > GetScreenWidth()) or ((bunnies[i].position.x + texBunny.width/2) < 0):
|
if ((bunnies[i].position.x + texBunny.width/2) > GetScreenWidth()) or ((bunnies[i].position.x + texBunny.width/2) < 0):
|
||||||
bunnies[i].speed.x *= -1
|
bunnies[i].speed.x *= -1
|
||||||
|
@ -104,7 +104,7 @@ while not WindowShouldClose(): #// Detect window close button or ESC key
|
||||||
#//--------------------------------------------------------------------------------------
|
#//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
UnloadTexture(texBunny) #Unload bunny texture
|
UnloadTexture(texBunny); #Unload bunny texture
|
||||||
|
|
||||||
CloseWindow() # Close window and OpenGL context
|
CloseWindow() # Close window and OpenGL context
|
||||||
#//--------------------------------------------------------------------------------------
|
#//--------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -36,9 +36,9 @@ bunnies = []
|
||||||
for i in range(0, MAX_BUNNIES):
|
for i in range(0, MAX_BUNNIES):
|
||||||
bunnies.append(Bunny())
|
bunnies.append(Bunny())
|
||||||
|
|
||||||
bunniesCount = 0 # Bunnies counter
|
bunniesCount = 0; # Bunnies counter
|
||||||
|
|
||||||
SetTargetFPS(60) # Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); # Set our game to run at 60 frames-per-second
|
||||||
#//--------------------------------------------------------------------------------------
|
#//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#// Main game loop
|
#// Main game loop
|
||||||
|
|
|
@ -4,6 +4,16 @@ raylib [texture] example - Mouse Painting
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from pyray import *
|
from pyray import *
|
||||||
|
from raylib.colors import *
|
||||||
|
from raylib import (
|
||||||
|
KEY_RIGHT,
|
||||||
|
KEY_LEFT,
|
||||||
|
MOUSE_BUTTON_LEFT,
|
||||||
|
KEY_C,
|
||||||
|
GESTURE_DRAG,
|
||||||
|
MOUSE_BUTTON_RIGHT,
|
||||||
|
KEY_S
|
||||||
|
)
|
||||||
|
|
||||||
MAX_COLORS_COUNT = 23 # Number of colors available
|
MAX_COLORS_COUNT = 23 # Number of colors available
|
||||||
|
|
||||||
|
@ -52,9 +62,9 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
mousePos = get_mouse_position()
|
mousePos = get_mouse_position()
|
||||||
|
|
||||||
# Move between colors with keys
|
# Move between colors with keys
|
||||||
if is_key_pressed(KeyboardKey.KEY_RIGHT):
|
if is_key_pressed(KEY_RIGHT):
|
||||||
colorSelected += 1
|
colorSelected += 1
|
||||||
elif is_key_pressed(KeyboardKey.KEY_LEFT):
|
elif is_key_pressed(KEY_LEFT):
|
||||||
colorSelected -= 1
|
colorSelected -= 1
|
||||||
|
|
||||||
if colorSelected >= MAX_COLORS_COUNT:
|
if colorSelected >= MAX_COLORS_COUNT:
|
||||||
|
@ -70,7 +80,7 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
else:
|
else:
|
||||||
colorMouseHover = -1
|
colorMouseHover = -1
|
||||||
|
|
||||||
if colorMouseHover >= 0 and is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_LEFT):
|
if colorMouseHover >= 0 and is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
|
||||||
colorSelected = colorMouseHover
|
colorSelected = colorMouseHover
|
||||||
colorSelectedPrev = colorSelected
|
colorSelectedPrev = colorSelected
|
||||||
|
|
||||||
|
@ -79,13 +89,13 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
if brushSize < 2: brushSize = 2
|
if brushSize < 2: brushSize = 2
|
||||||
if brushSize > 50: brushSize = 50
|
if brushSize > 50: brushSize = 50
|
||||||
|
|
||||||
if is_key_pressed(KeyboardKey.KEY_C):
|
if is_key_pressed(KEY_C):
|
||||||
# Clear render texture to clear color
|
# Clear render texture to clear color
|
||||||
begin_texture_mode(target)
|
begin_texture_mode(target)
|
||||||
clear_background(colors[0])
|
clear_background(colors[0])
|
||||||
end_texture_mode()
|
end_texture_mode()
|
||||||
|
|
||||||
if is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_LEFT) or get_gesture_detected() == Gesture.GESTURE_DRAG:
|
if is_mouse_button_pressed(MOUSE_BUTTON_LEFT) or get_gesture_detected() == GESTURE_DRAG:
|
||||||
|
|
||||||
# Paint circle into render texture
|
# Paint circle into render texture
|
||||||
# NOTE: To avoid discontinuous circles, we could store
|
# NOTE: To avoid discontinuous circles, we could store
|
||||||
|
@ -94,7 +104,7 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
if mousePos.y > 50:
|
if mousePos.y > 50:
|
||||||
draw_circle(int(mousePos.x), int(mousePos.y), brushSize, colors[colorSelected])
|
draw_circle(int(mousePos.x), int(mousePos.y), brushSize, colors[colorSelected])
|
||||||
end_texture_mode()
|
end_texture_mode()
|
||||||
if is_mouse_button_down(MouseButton.MOUSE_BUTTON_RIGHT):
|
if is_mouse_button_down(MOUSE_BUTTON_RIGHT):
|
||||||
|
|
||||||
if not mouseWasPressed:
|
if not mouseWasPressed:
|
||||||
colorSelectedPrev = colorSelected
|
colorSelectedPrev = colorSelected
|
||||||
|
@ -107,7 +117,7 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
if mousePos.y > 50: draw_circle(int(mousePos.x), int(mousePos.y), brushSize, colors[0])
|
if mousePos.y > 50: draw_circle(int(mousePos.x), int(mousePos.y), brushSize, colors[0])
|
||||||
end_texture_mode()
|
end_texture_mode()
|
||||||
|
|
||||||
elif is_mouse_button_released(MouseButton.MOUSE_BUTTON_RIGHT) and mouseWasPressed:
|
elif is_mouse_button_released(MOUSE_BUTTON_RIGHT) and mouseWasPressed:
|
||||||
|
|
||||||
colorSelected = colorSelectedPrev
|
colorSelected = colorSelectedPrev
|
||||||
mouseWasPressed = False
|
mouseWasPressed = False
|
||||||
|
@ -120,7 +130,7 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
|
|
||||||
# Image saving logic
|
# Image saving logic
|
||||||
# NOTE: Saving painted texture to a default named image
|
# NOTE: Saving painted texture to a default named image
|
||||||
if (btnSaveMouseHover and is_mouse_button_released(MouseButton.MOUSE_BUTTON_LEFT)) or is_key_pressed(KeyboardKey.KEY_S):
|
if (btnSaveMouseHover and is_mouse_button_released(MOUSE_BUTTON_LEFT)) or is_key_pressed(KEY_S):
|
||||||
image = load_image_from_texture(target.texture)
|
image = load_image_from_texture(target.texture)
|
||||||
image_flip_vertical(image)
|
image_flip_vertical(image)
|
||||||
export_image(image, "my_amazing_texture_painting.png")
|
export_image(image, "my_amazing_texture_painting.png")
|
||||||
|
@ -147,7 +157,7 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
|
|
||||||
# Draw drawing circle for reference
|
# Draw drawing circle for reference
|
||||||
if mousePos.y > 50:
|
if mousePos.y > 50:
|
||||||
if is_mouse_button_down(MouseButton.MOUSE_BUTTON_RIGHT):
|
if is_mouse_button_down(MOUSE_BUTTON_RIGHT):
|
||||||
draw_circle_lines(int(mousePos.x), int(mousePos.y), brushSize, GRAY)
|
draw_circle_lines(int(mousePos.x), int(mousePos.y), brushSize, GRAY)
|
||||||
else:
|
else:
|
||||||
draw_circle(get_mouse_x(), get_mouse_y(), brushSize, colors[colorSelected])
|
draw_circle(get_mouse_x(), get_mouse_y(), brushSize, colors[colorSelected])
|
||||||
|
|
|
@ -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
|
|
|
@ -39,8 +39,6 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
|
|
||||||
clear_background(RAYWHITE)
|
clear_background(RAYWHITE)
|
||||||
|
|
||||||
texture.width
|
|
||||||
|
|
||||||
draw_texture(texture, int(screenWidth/2 - texture.width/2), int(screenHeight/2 - texture.height/2), WHITE)
|
draw_texture(texture, int(screenWidth/2 - texture.width/2), int(screenHeight/2 - texture.height/2), WHITE)
|
||||||
|
|
||||||
draw_text("this IS a texture loaded from an image!", 300, 370, 10, GRAY)
|
draw_text("this IS a texture loaded from an image!", 300, 370, 10, GRAY)
|
||||||
|
|
20
make_docs.sh
20
make_docs.sh
|
@ -12,12 +12,12 @@ cd ../..
|
||||||
|
|
||||||
echo "installing raylib headers to /usr/local/include"
|
echo "installing raylib headers to /usr/local/include"
|
||||||
|
|
||||||
sudo cp -v ./raylib-c/src/raylib.h /usr/local/include/
|
sudo cp ./raylib-c/src/raylib.h /usr/local/include/
|
||||||
sudo cp -v ./raylib-c/src/rlgl.h /usr/local/include/
|
sudo cp ./raylib-c/src/rlgl.h /usr/local/include/
|
||||||
sudo cp -v ./raylib-c/src/raymath.h /usr/local/include/
|
sudo cp ./raylib-c/src/raymath.h /usr/local/include/
|
||||||
sudo cp -v ./raygui/src/raygui.h /usr/local/include/
|
sudo cp ./raygui/src/raygui.h /usr/local/include/
|
||||||
sudo cp -v ./physac/src/physac.h /usr/local/include/
|
sudo cp ./physac/src/physac.h /usr/local/include/
|
||||||
sudo cp -rv ./raylib-c/src/external/glfw/include/GLFW /usr/local/include/
|
sudo cp -r ./raylib-c/src/external/glfw/include/GLFW /usr/local/include/
|
||||||
|
|
||||||
echo "building raylib_parser"
|
echo "building raylib_parser"
|
||||||
|
|
||||||
|
@ -45,15 +45,17 @@ python3 create_enums.py > dynamic/raylib/enums.py
|
||||||
|
|
||||||
echo "creating defines.py"
|
echo "creating defines.py"
|
||||||
|
|
||||||
python3 create_define_consts.py | awk '!seen[$0]++' > raylib/defines.py
|
python3 create_define_consts.py > raylib/defines.py
|
||||||
python3 create_define_consts.py | awk '!seen[$0]++' > dynamic/raylib/defines.py
|
python3 create_define_consts.py > dynamic/raylib/defines.py
|
||||||
|
|
||||||
|
|
||||||
echo "creating pyi files"
|
echo "creating pyi files"
|
||||||
|
|
||||||
python3 create_stub_pyray.py > pyray/__init__.pyi
|
python3 create_stub_pyray.py > pyray/__init__.pyi
|
||||||
|
python3 create_enums.py >> pyray/__init__.pyi
|
||||||
|
|
||||||
python3 create_stub_static.py >raylib/__init__.pyi
|
python3 create_stub_static.py >raylib/__init__.pyi
|
||||||
python3 create_stub_static.py >dynamic/raylib/__init__.pyi
|
|
||||||
|
|
||||||
echo "installing sphinx modules"
|
echo "installing sphinx modules"
|
||||||
|
|
||||||
|
|
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:
|
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]+)([A-Z][a-z])", r'\1_\2', word)
|
||||||
word = re.sub(r"([a-z\d])([A-Z])", r'\1_\2', word)
|
word = re.sub(r"([a-z\d])([A-Z])", r'\1_\2', word)
|
||||||
word = word.replace("-", "_")
|
word = word.replace("-", "_")
|
||||||
|
@ -126,7 +127,7 @@ def _make_struct_constructor_function(struct):
|
||||||
or isinstance(arg, (array, bytes, bytearray, memoryview)))):
|
or isinstance(arg, (array, bytes, bytearray, memoryview)))):
|
||||||
arg = ffi.from_buffer(field[1].type, arg)
|
arg = ffi.from_buffer(field[1].type, arg)
|
||||||
modified_args.append(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
|
global_weakkeydict[s] = modified_args
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
@ -135,7 +136,7 @@ def _make_struct_constructor_function(struct):
|
||||||
|
|
||||||
for name, attr in getmembers(rl):
|
for name, attr in getmembers(rl):
|
||||||
# print(name, attr)
|
# 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(
|
if isbuiltin(attr) or str(type(attr)) == "<class '_cffi_backend.__FFIFunctionWrapper'>" or str(
|
||||||
type(attr)) == "<class '_cffi_backend._CDataBase'>":
|
type(attr)) == "<class '_cffi_backend._CDataBase'>":
|
||||||
# print(attr.__call__)
|
# print(attr.__call__)
|
||||||
|
|
7543
pyray/__init__.pyi
7543
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 a2e31c4e1ba7b2ab0c4b87c70e88fa365b02f652
|
|
@ -12,23 +12,13 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
# 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
|
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))
|
|
||||||
raise
|
|
||||||
|
|
||||||
from raylib._raylib_cffi.lib import *
|
from raylib._raylib_cffi.lib import *
|
||||||
from raylib.colors import *
|
from raylib.colors import *
|
||||||
from raylib.defines import *
|
from raylib.defines import *
|
||||||
import cffi
|
import cffi
|
||||||
|
import sys
|
||||||
from .version import __version__
|
from .version import __version__
|
||||||
|
|
||||||
logger.warning("RAYLIB STATIC %s LOADED", __version__)
|
print("RAYLIB STATIC "+__version__+" LOADED", file=sys.stderr)
|
||||||
|
|
||||||
|
|
4076
raylib/__init__.pyi
4076
raylib/__init__.pyi
File diff suppressed because it is too large
Load diff
|
@ -24,14 +24,8 @@ import platform
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
THIS_DIR = Path(__file__).resolve().parent
|
|
||||||
REPO_ROOT = THIS_DIR.parent
|
|
||||||
|
|
||||||
|
|
||||||
RAYLIB_PLATFORM = os.getenv("RAYLIB_PLATFORM", "Desktop")
|
RAYLIB_PLATFORM = os.getenv("RAYLIB_PLATFORM", "Desktop")
|
||||||
ENABLE_WAYLAND_DRM_LEASING = os.getenv("ENABLE_WAYLAND_DRM_LEASING")
|
|
||||||
|
|
||||||
def check_raylib_installed():
|
def check_raylib_installed():
|
||||||
return subprocess.run(['pkg-config', '--exists', 'raylib'], text=True, stdout=subprocess.PIPE).returncode == 0
|
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,
|
return subprocess.run(['pkg-config', '--variable=libdir', 'raylib'], text=True,
|
||||||
stdout=subprocess.PIPE).stdout.strip()
|
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():
|
def get_lib_flags():
|
||||||
return subprocess.run(['pkg-config', '--libs', 'raylib'], text=True,
|
return subprocess.run(['pkg-config', '--libs', 'raylib'], text=True,
|
||||||
stdout=subprocess.PIPE).stdout.strip().split()
|
stdout=subprocess.PIPE).stdout.strip().split()
|
||||||
|
@ -192,17 +175,11 @@ def build_unix():
|
||||||
else: #platform.system() == "Linux":
|
else: #platform.system() == "Linux":
|
||||||
print("BUILDING FOR LINUX")
|
print("BUILDING FOR LINUX")
|
||||||
extra_link_args = get_lib_flags() + [ '-lm', '-lpthread', '-lGL',
|
extra_link_args = get_lib_flags() + [ '-lm', '-lpthread', '-lGL',
|
||||||
'-lrt', '-lm', '-ldl', '-lpthread', '-latomic']
|
'-lrt', '-lm', '-ldl', '-lX11', '-lpthread', '-latomic']
|
||||||
if RAYLIB_PLATFORM=="SDL":
|
if RAYLIB_PLATFORM=="SDL":
|
||||||
extra_link_args += ['-lX11','-lSDL2']
|
extra_link_args += ['-lSDL2']
|
||||||
elif RAYLIB_PLATFORM=="DRM":
|
elif RAYLIB_PLATFORM=="DRM":
|
||||||
extra_link_args += get_specified_libs("egl")
|
extra_link_args += ['-lEGL', '-lgbm']
|
||||||
extra_link_args += get_specified_libs("gbm")
|
|
||||||
|
|
||||||
if ENABLE_WAYLAND_DRM_LEASING != "":
|
|
||||||
extra_link_args += get_specified_libs("wayland-client")
|
|
||||||
else:
|
|
||||||
extra_link_args += ['-lX11']
|
|
||||||
extra_compile_args = ["-Wno-incompatible-pointer-types", "-D_CFFI_NO_LIMITED_API"]
|
extra_compile_args = ["-Wno-incompatible-pointer-types", "-D_CFFI_NO_LIMITED_API"]
|
||||||
libraries = [] # Not sure why but we put them in extra_link_args instead so *shouldnt* be needed here
|
libraries = [] # Not sure why but we put them in extra_link_args instead so *shouldnt* be needed here
|
||||||
|
|
||||||
|
@ -221,13 +198,13 @@ def build_unix():
|
||||||
|
|
||||||
def build_windows():
|
def build_windows():
|
||||||
print("BUILDING FOR 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":
|
if RAYLIB_PLATFORM=="Desktop":
|
||||||
ffibuilder.cdef((THIS_DIR / "glfw3.h.modified").read_text())
|
ffibuilder.cdef(open("raylib/glfw3.h.modified").read())
|
||||||
ffibuilder.cdef((THIS_DIR / "rlgl.h.modified").read_text())
|
ffibuilder.cdef(open("raylib/rlgl.h.modified").read())
|
||||||
ffibuilder.cdef((THIS_DIR / "raygui.h.modified").read_text())
|
ffibuilder.cdef(open("raylib/raygui.h.modified").read())
|
||||||
ffibuilder.cdef((THIS_DIR / "physac.h.modified").read_text())
|
ffibuilder.cdef(open("raylib/physac.h.modified").read())
|
||||||
ffibuilder.cdef((THIS_DIR / "raymath.h.modified").read_text())
|
ffibuilder.cdef(open("raylib/raymath.h.modified").read())
|
||||||
|
|
||||||
ffi_includes = """
|
ffi_includes = """
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
@ -245,7 +222,6 @@ def build_windows():
|
||||||
#define RAYGUI_SUPPORT_RICONS
|
#define RAYGUI_SUPPORT_RICONS
|
||||||
#include "raygui.h"
|
#include "raygui.h"
|
||||||
#define PHYSAC_IMPLEMENTATION
|
#define PHYSAC_IMPLEMENTATION
|
||||||
#define PHYSAC_NO_THREADS
|
|
||||||
#include "physac.h"
|
#include "physac.h"
|
||||||
"""
|
"""
|
||||||
libraries = ['raylib', 'gdi32', 'shell32', 'user32', 'OpenGL32', 'winmm']
|
libraries = ['raylib', 'gdi32', 'shell32', 'user32', 'OpenGL32', 'winmm']
|
||||||
|
@ -258,10 +234,10 @@ def build_windows():
|
||||||
extra_compile_args=["/D_CFFI_NO_LIMITED_API"],
|
extra_compile_args=["/D_CFFI_NO_LIMITED_API"],
|
||||||
py_limited_api=False,
|
py_limited_api=False,
|
||||||
libraries=libraries,
|
libraries=libraries,
|
||||||
include_dirs=[str(REPO_ROOT / 'raylib-c/src'),
|
include_dirs=['D:\\a\\raylib-python-cffi\\raylib-python-cffi\\raylib-c\\src',
|
||||||
str(REPO_ROOT / 'raylib-c/src/external/glfw/include'),
|
'D:\\a\\raylib-python-cffi\\raylib-python-cffi\\raylib-c\\src\\external\\glfw\\include',
|
||||||
str(REPO_ROOT / 'raygui/src'),
|
'D:\\a\\raylib-python-cffi\\raylib-python-cffi\\raygui\\src',
|
||||||
str(REPO_ROOT / 'physac/src')],
|
'D:\\a\\raylib-python-cffi\\raylib-python-cffi\\physac\\src'],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import raylib
|
||||||
RAYLIB_VERSION_MAJOR: int = 5
|
RAYLIB_VERSION_MAJOR: int = 5
|
||||||
RAYLIB_VERSION_MINOR: int = 5
|
RAYLIB_VERSION_MINOR: int = 5
|
||||||
RAYLIB_VERSION_PATCH: int = 0
|
RAYLIB_VERSION_PATCH: int = 0
|
||||||
RAYLIB_VERSION: str = "5.5"
|
RAYLIB_VERSION: str = "5.5-dev"
|
||||||
PI: float = 3.141592653589793
|
PI: float = 3.141592653589793
|
||||||
DEG2RAD = PI / 180.0
|
DEG2RAD = PI / 180.0
|
||||||
RAD2DEG = 180.0 / PI
|
RAD2DEG = 180.0 / PI
|
||||||
|
@ -14,7 +14,10 @@ MATERIAL_MAP_DIFFUSE = raylib.MATERIAL_MAP_ALBEDO
|
||||||
MATERIAL_MAP_SPECULAR = raylib.MATERIAL_MAP_METALNESS
|
MATERIAL_MAP_SPECULAR = raylib.MATERIAL_MAP_METALNESS
|
||||||
SHADER_LOC_MAP_DIFFUSE = raylib.SHADER_LOC_MAP_ALBEDO
|
SHADER_LOC_MAP_DIFFUSE = raylib.SHADER_LOC_MAP_ALBEDO
|
||||||
SHADER_LOC_MAP_SPECULAR = raylib.SHADER_LOC_MAP_METALNESS
|
SHADER_LOC_MAP_SPECULAR = raylib.SHADER_LOC_MAP_METALNESS
|
||||||
|
PI: float = 3.141592653589793
|
||||||
EPSILON: float = 1e-06
|
EPSILON: float = 1e-06
|
||||||
|
DEG2RAD = PI / 180.0
|
||||||
|
RAD2DEG = 180.0 / PI
|
||||||
RLGL_VERSION: str = "5.0"
|
RLGL_VERSION: str = "5.0"
|
||||||
RL_DEFAULT_BATCH_BUFFER_ELEMENTS: int = 8192
|
RL_DEFAULT_BATCH_BUFFER_ELEMENTS: int = 8192
|
||||||
RL_DEFAULT_BATCH_BUFFERS: int = 1
|
RL_DEFAULT_BATCH_BUFFERS: int = 1
|
||||||
|
@ -99,6 +102,9 @@ RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS: int = 7
|
||||||
RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS: int = 8
|
RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS: int = 8
|
||||||
RL_SHADER_LOC_MAP_DIFFUSE = raylib.RL_SHADER_LOC_MAP_ALBEDO
|
RL_SHADER_LOC_MAP_DIFFUSE = raylib.RL_SHADER_LOC_MAP_ALBEDO
|
||||||
RL_SHADER_LOC_MAP_SPECULAR = raylib.RL_SHADER_LOC_MAP_METALNESS
|
RL_SHADER_LOC_MAP_SPECULAR = raylib.RL_SHADER_LOC_MAP_METALNESS
|
||||||
|
PI: float = 3.141592653589793
|
||||||
|
DEG2RAD = PI / 180.0
|
||||||
|
RAD2DEG = 180.0 / PI
|
||||||
GL_SHADING_LANGUAGE_VERSION: int = 35724
|
GL_SHADING_LANGUAGE_VERSION: int = 35724
|
||||||
GL_COMPRESSED_RGB_S3TC_DXT1_EXT: int = 33776
|
GL_COMPRESSED_RGB_S3TC_DXT1_EXT: int = 33776
|
||||||
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: int = 33777
|
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: int = 33777
|
||||||
|
@ -186,10 +192,12 @@ RAYGUI_TEXTFORMAT_MAX_SIZE: int = 256
|
||||||
PHYSAC_MAX_BODIES: int = 64
|
PHYSAC_MAX_BODIES: int = 64
|
||||||
PHYSAC_MAX_MANIFOLDS: int = 4096
|
PHYSAC_MAX_MANIFOLDS: int = 4096
|
||||||
PHYSAC_MAX_VERTICES: int = 24
|
PHYSAC_MAX_VERTICES: int = 24
|
||||||
PHYSAC_CIRCLE_VERTICES: int = 24
|
PHYSAC_DEFAULT_CIRCLE_VERTICES: int = 24
|
||||||
PHYSAC_COLLISION_ITERATIONS: int = 20
|
PHYSAC_COLLISION_ITERATIONS: int = 100
|
||||||
PHYSAC_PENETRATION_ALLOWANCE: float = 0.05
|
PHYSAC_PENETRATION_ALLOWANCE: float = 0.05
|
||||||
PHYSAC_PENETRATION_CORRECTION: float = 0.4
|
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_FLT_MAX: float = 3.402823466e+38
|
||||||
PHYSAC_EPSILON: float = 1e-06
|
PHYSAC_EPSILON: float = 1e-06
|
||||||
GLFW_VERSION_MAJOR: int = 3
|
GLFW_VERSION_MAJOR: int = 3
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue