mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-02 20:29:18 -05:00
Updated Compile your game for Web (markdown)
@ -2,11 +2,17 @@ To build your raylib game for HTML5 you need a different compiler than the one t
|
||||
|
||||
##Installing emscripten
|
||||
|
||||
Download emscripten SDK from [here](http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html). I recommend downloading the Portable Emscripten SDK for Windows and decompress it in `C:\emsdk` folder. After that, follow the portable version installation instructions.
|
||||
Download emscripten SDK from [here](http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html). I recommend downloading the Portable Emscripten SDK for Windows and decompressing it in `C:\emsdk` folder. After that, go to emsdk intallation folder, run `emcmdprompt.bat` and execute the following commands:
|
||||
|
||||
emsdk update
|
||||
emsdk list
|
||||
emsdk install sdk-1.34.1-64bit
|
||||
|
||||
_NOTE: If a newer preconpiled SDK version (newer than sdk-1.34.1-64bit) is available, install new version. Preconpiled SDK already includes latest version of clang, emscripten, python and node.js, so you don't have to install it separately._
|
||||
|
||||
##Compiling raylib source code [Optional]
|
||||
|
||||
Before compiling your game, raylib library must be recompiled for HTML5. By default, when you install raylib using the Windows Installer, an already pre-compiled raylib HTML5 version is found in C:\raylib\raylib\src\libraylib.bc. Notepad++ use this version but you can regenerate it just recompiling raylib for web.
|
||||
Before compiling your game, raylib library must be recompiled for HTML5. By default, when you install raylib using the Windows Installer, an already pre-compiled raylib HTML5 version is found in C:\raylib\raylib\src\libraylib.bc. Notepad++ uses this version but you can regenerate it just recompiling raylib for web (in case you have modified raylib sources or you updated it with GitHub develop branch sources).
|
||||
|
||||
##Preparing your raylib game for web
|
||||
To compile your game for web, code must be slightly adapted. It means moving all your Update and Draw code to an external function. The reason for that is the way web games work within a browser; basically, the browser needs to control the game loop and just allow and Update-Draw cycle when the tab is selected or browser is not minimized. As reference, you can check `core_basic_window` sample adapted for web [here](https://github.com/raysan5/raylib/blob/master/examples/core_basic_window_web.c).
|
||||
|
||||
Reference in New Issue
Block a user