Skip to content

Commit ef3681f

Browse files
update readme
1 parent 70b8d7c commit ef3681f

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ original Raylib.
66
* Faster, fewer bugs and easier to maintain than ctypes.
77
* Commercial-friendly license.
88
* Docstrings and auto-completion.
9-
* **Now includes extra libraries: raymath, raygui, rlgl and physac**
9+
* **Now includes extra libraries: raymath, raygui, rlgl, physac and GLFW**
1010

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

@@ -81,6 +81,48 @@ Use [the C API](https://electronstudio.github.io/raylib-python-cffi/raylib.html)
8181

8282
Use [the Python API](https://electronstudio.github.io/raylib-python-cffi/pyray.html).
8383

84+
# Running in a web browser
85+
86+
[Pygbag](https://pypi.org/project/pygbag/) >=0.8.7 supports running in a web browser.
87+
88+
Make a folder `my_project` with a file `main.py`:
89+
90+
# /// script
91+
# dependencies = [
92+
# "cffi",
93+
# "inflection",
94+
# "raylib"
95+
# ]
96+
# ///
97+
import asyncio
98+
import platform
99+
from pyray import *
100+
101+
async def main(): # You must have an async main function
102+
init_window(500, 500, "Hello")
103+
platform.window.window_resize() # You must add this line
104+
while not window_should_close():
105+
begin_drawing()
106+
clear_background(WHITE)
107+
draw_text("Hello world", 190, 200, 20, VIOLET)
108+
end_drawing()
109+
await asyncio.sleep(0) # You must call this in your main loop
110+
close_window()
111+
112+
asyncio.run(main())
113+
114+
Then to create the web files and launch a web server:
115+
116+
python3 -m pip install --user --upgrade git+https://github.com/pygame-web/pygbag
117+
python3 -m pygbag --git --PYBUILD 3.12 --ume_block 0 --template noctx.tmpl my_project
118+
119+
Point your browser to http://localhost:8000
120+
121+
This is all done by Pygbag rather than by me, so you should probably contact them with any issues.
122+
Carefully read all their [documentation](https://pygame-web.github.io/).
123+
124+
It does work for most of the examples at https://electronstudio.github.io/raylib-python-cffi-pygbag-examples/
125+
84126
# App showcase
85127

86128
[Tanki](https://github.com/pkulev/tanki)

0 commit comments

Comments
 (0)