Skip to content

Commit a826414

Browse files
update docs
1 parent bf6d5d4 commit a826414

15 files changed

+189
-99
lines changed

README.md

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
# Python Bindings for Raylib 5.5
22
## Libraries: raymath, raygui, rlgl, physac and GLFW
33
## Backends: Desktop, SDL, DRM, Web
4+
## Platforms: Windows, Mac, Linux, Raspberry Pi, Web
45

56
Chatroom: [Discord](https://discord.gg/fKDwt85aX6)
67

7-
New CFFI API static bindings.
8+
[HELP WANTED: writing examples](https://github.com/electronstudio/raylib-python-cffi/issues/155)
9+
10+
* CFFI API static bindings.
811
* Automatically generated to be as close as possible to
912
original Raylib.
1013
* Faster, fewer bugs and easier to maintain than ctypes.
1114
* Commercial-friendly license.
1215
* Docstrings and auto-completion.
16+
* Type checking with Mypy
1317

1418

1519
[Full documentation](http://electronstudio.github.io/raylib-python-cffi)
1620

1721
# Quickstart
1822

19-
`pip3 install raylib==5.0.0.4`
23+
`pip3 install raylib==5.5.0.0`
2024
```python
2125
from pyray import *
2226
init_window(800, 450, "Hello")
@@ -37,7 +41,7 @@ First make sure you have the latest pip installed:
3741
Then install
3842

3943
python3 -m pip install setuptools
40-
python3 -m pip install raylib==5.0.0.4
44+
python3 -m pip install raylib==5.5.0.0
4145

4246
On most platforms it should install a binary wheel. If yours isn't available then pip will attempt to build from
4347
source, in which case you will need to have Raylib development libs installed, e.g.
@@ -59,7 +63,7 @@ Older MacOS requires building from source but this is usually simple:
5963

6064
brew install pkg-config
6165
brew install raylib
62-
python3 -m pip install raylib==5.0.0.4
66+
python3 -m pip install raylib==5.5.0.0
6367

6468
(I do have binaries for arm64 MacOS 11, 12 and 13 but I have no way of testing they work, so post an issue
6569
if you want to test them.)
@@ -76,6 +80,8 @@ so may not work on other boards.
7680

7781
[Using on Rasperry Pi](RPI.rst)
7882

83+
# Backends
84+
7985
## Dynamic binding version
8086

8187
There is now a separate dynamic version of this binding:
@@ -85,6 +91,8 @@ There is now a separate dynamic version of this binding:
8591

8692
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)
8793

94+
You can't have multiple raylib packages installed at once.
95+
8896
## SDL backend
8997

9098
This is not well tested but has better support for controllers:
@@ -116,64 +124,84 @@ If it still doesn't work, [submit an issue](https://github.com/electronstudio/ra
116124

117125
# How to use
118126

119-
There are two modules in the raylib package, `raylib` and `pyray`. (There is no separate package for
120-
pyray). You can use either or both:
127+
There are *two* modules in the raylib package, `raylib` and `pyray`. (There is no separate package for
128+
pyray. Do *not* `pip install pyray`). You can use either or both:
121129

122130
### If you are familiar with C coding and the Raylib C library and you want to use an exact copy of the C API
123131

124132
Use [the raylib module](https://electronstudio.github.io/raylib-python-cffi/raylib.html).
125133

126-
### If you prefer a more Pythonistic API
134+
### If you prefer a more Pythonistic API
127135

128136
Use [the pyray module](https://electronstudio.github.io/raylib-python-cffi/pyray.html).
129137

130138
# Running in a web browser
131139

132-
[Pygbag](https://pypi.org/project/pygbag/) >=0.8.7 supports running in a web browser.
140+
[Pygbag](https://pypi.org/project/pygbag/) >=0.8.7 supports running in a web browser. Usually the latest git version
141+
is recommended.
133142

134143
Make a folder `my_project` with a file `main.py`:
135144

136-
# /// script
137-
# dependencies = [
138-
# "cffi",
139-
# "raylib"
140-
# ]
141-
# ///
142-
import asyncio
143-
import platform
144-
from pyray import *
145-
146-
async def main(): # You must have an async main function
147-
init_window(500, 500, "Hello")
148-
platform.window.window_resize() # You must add this line
149-
while not window_should_close():
150-
begin_drawing()
151-
clear_background(WHITE)
152-
draw_text("Hello world", 190, 200, 20, VIOLET)
153-
end_drawing()
154-
await asyncio.sleep(0) # You must call this in your main loop
155-
close_window()
156-
157-
asyncio.run(main())
145+
```python
146+
# /// script
147+
# dependencies = [
148+
# "cffi",
149+
# "raylib"
150+
# ]
151+
# ///
152+
import asyncio
153+
import platform
154+
from pyray import *
155+
156+
async def main(): # You MUST have an async main function
157+
init_window(500, 500, "Hello")
158+
platform.window.window_resize() # You MAY want to add this line
159+
while not window_should_close():
160+
begin_drawing()
161+
clear_background(WHITE)
162+
draw_text("Hello world", 190, 200, 20, VIOLET)
163+
end_drawing()
164+
await asyncio.sleep(0) # You MUST call this in your main loop
165+
close_window()
166+
167+
asyncio.run(main())
168+
```
158169

159170
Then to create the web files and launch a web server:
160171

161172
python3.12 -m pip install --user --upgrade pygbag
162-
python3.12 -m pygbag --PYBUILD 3.12 --ume_block 0 --template noctx.tmpl my_project
173+
python3.12 -m pygbag --PYBUILD 3.12 --ume_block 0 --template noctx.tmpl --git my_project
163174

164175
Point your browser to http://localhost:8000
165176

177+
Some features may not work, so you can disable them like this:
178+
179+
```python
180+
if platform.system() != "Emscripten": # audio does not work on current version of emscripten
181+
init_audio_device()
182+
```
183+
166184
This is all done by Pygbag rather than by me, so you should probably contact them with any issues.
167185
Carefully read all their [documentation](https://pygame-web.github.io/).
168186

169187
It does work for most of [these examples](https://electronstudio.github.io/raylib-python-cffi-pygbag-examples/)
170188

171189
# App showcase
172190

191+
[Tempest-raylib](https://github.com/Emtyloc/tempest-raylib)
192+
193+
[KarabinerKeyboard](https://github.com/bilbofroggins/KarabinerKeyboard)
194+
195+
[PyTaiko](https://github.com/Yonokid/PyTaiko)
196+
197+
[DOOM-Clone](https://github.com/StanislavPetrovV/DOOM-Clone)
198+
173199
[Tanki](https://github.com/pkulev/tanki)
174200

175201
[Alloy Bloxel Editor](https://pebaz.itch.io/alloy-bloxel-editor)
176202

203+
[Eidolon](https://github.com/Miou-zora/Eidolon)
204+
177205
Add your app here!
178206

179207
# RLZero

RPI.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Then have pip compile and install the wheel:
4242
::
4343

4444
python3 -m pip install --break-system-packages setuptools
45-
python3 -m pip install --no-cache-dir --no-binary raylib --upgrade --force-reinstall --break-system-packages raylib==5.0.0.4
45+
python3 -m pip install --no-cache-dir --no-binary raylib --upgrade --force-reinstall --break-system-packages raylib==5.5.0.0
4646

4747
Option 3: Compile Raylib from source DRM mode
4848
---------------------------------------------
@@ -85,7 +85,7 @@ Then have pip compile and install the wheel:
8585
::
8686

8787
python3 -m pip install --break-system-packages setuptools
88-
python3 -m pip install --no-cache-dir --no-binary raylib --upgrade --force-reinstall --break-system-packages raylib==5.0.0.4
88+
python3 -m pip install --no-cache-dir --no-binary raylib --upgrade --force-reinstall --break-system-packages raylib==5.5.0.0
8989

9090

9191

docs/BUILDING.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<li class="toctree-l1"><a class="reference internal" href="README.html">Python Bindings for Raylib 5.5</a></li>
4949
<li class="toctree-l1"><a class="reference internal" href="README.html#quickstart">Quickstart</a></li>
5050
<li class="toctree-l1"><a class="reference internal" href="README.html#installation">Installation</a></li>
51+
<li class="toctree-l1"><a class="reference internal" href="README.html#backends">Backends</a></li>
5152
<li class="toctree-l1"><a class="reference internal" href="README.html#how-to-use">How to use</a></li>
5253
<li class="toctree-l1"><a class="reference internal" href="README.html#running-in-a-web-browser">Running in a web browser</a></li>
5354
<li class="toctree-l1"><a class="reference internal" href="README.html#app-showcase">App showcase</a></li>

0 commit comments

Comments
 (0)