@@ -6,7 +6,7 @@ original Raylib.
6
6
* Faster, fewer bugs and easier to maintain than ctypes.
7
7
* Commercial-friendly license.
8
8
* 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 **
10
10
11
11
[ Full documentation] ( http://electronstudio.github.io/raylib-python-cffi )
12
12
@@ -81,6 +81,48 @@ Use [the C API](https://electronstudio.github.io/raylib-python-cffi/raylib.html)
81
81
82
82
Use [ the Python API] ( https://electronstudio.github.io/raylib-python-cffi/pyray.html ) .
83
83
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
+
84
126
# App showcase
85
127
86
128
[ Tanki] ( https://github.com/pkulev/tanki )
0 commit comments