User Tools

Site Tools


development:player:web

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
development:player:web [2015/05/19 22:44]
ghabry add download link
development:player:web [2020/09/20 21:54] (current)
ghabry recommend python server. improve ?game wording
Line 1: Line 1:
-=====EasyRPG Player for the Web=====+====== EasyRPG Player for the Web ======
  
-EasyRPG supports running games directly inside your web browser.+EasyRPG Player supports running games directly inside your web browser.
  
-If you want to test it you can play with a [[https://easy-rpg.org/play/index-pr.html|Demo of our TestGame]].+If you want to test it you can play with a [[https://easyrpg.org/play/|Demo of our TestGame]]. Try also a working game: [[https://easyrpg.org/play/?game=ib|Ib]]
  
-===How does it work===+===== How it works =====
  
-Web request are asynchronous. This means that all assets like pictures and music must be fetched asynchronously. When the Player wants to display a new graphic it will appear on the desktop versions (Windows, Linux, Android, ...) immedieately but on the web it will be invisible while the file is downloaded. Once the downloaded finishes it is replaced with the real image.+Web request are asynchronous. This means that all assets like pictures and music must be fetched asynchronously. When the Player wants to display a new graphic it will appear on the desktop versions (Windows, Linux, Android, ...) immediately but on the web it will be invisible while the file is downloaded. Once the downloaded finishes it is replaced with the real image.
  
-In contrast to images and music some files are important to continue execution. When a map file is pending the Player will halt until the file is downloaded. The first halt is while the Logo is displayed on startup, it downloads the database and the maptree here. Download of map files is blocking, too. But this is usually not noticable because the download is executed while the fadeout animation plays (it will stay black when the map downloading takes longer then this).+In contrast to images and music some files are important to continue execution. When a map file is pending the Player will halt until the file is downloaded. The first halt is while the Logo is displayed on startup, it downloads the database and the maptree here. Download of map files is blocking, too. But this is usually not noticeable because the download is executed while the fade out animation plays (it will stay black when the map downloading takes longer then this).
  
-===Hosting your own games===+===== Hosting your own games =====
  
-Hosting your own games is quite simple. Just follow these three steps.+Hosting your own games is quite simple. Just follow these steps.
  
-== Deploying the Player on your server ==+==== Deploying the Player on your server ====
  
-[[https://easy-rpg.org/jenkins/job/player-js/lastSuccessfulBuild/artifact/player-js.tar.gz|Download this archive]] and extract it on your server.+[[https://ci.easyrpg.org/job/player-js/lastSuccessfulBuild/artifact/player-js.tar.gz|Download this archive]] and extract it on your server.
  
-Your server needs support for PHP (most servers support this). +You will get the following files and folder:
- +
-You will get the following files:+
  
   * index.html   * index.html
 +  * index.wasm
   * index.js   * index.js
-  * index.html.mem +  * games/
-  * games/index.php +
- +
-== Preprocessing steps for games == +
- +
-Because of limitations in web browser you must convert all your ''midi'' and ''mp3'' audio files to ogg. To do this run TODO. +
- +
-== Deploying a game on your server == +
- +
-The following only apply when you use our ''index.php''+
- +
-Your games are expected in subdirectories of the ''games'' directory. The default game executed is the one in ''games/default''. You can create further games by just putting them in subdirectories of the ''games'' directory. Because of security considerations (directory traversal) your directory name may not contain ''.'', ''\'' or ''cache''+
- +
-If your ''games'' directory is not writable for PHP create a ''cache'' folder in ''games'' and give it write permissions. You can skip this step if ''games'' is writable. You can revoke read permission on this folder for world/others. +
- +
-Run ''games/?update'' once. You have to run this each time you change files of the game. For other games then default use ''games/?update&game=folder_name''+
- +
-Now open the ''index.html'' file and your default game should start. To play a different game pass ''?game=folder_name'' to your index file. +
- +
-===Technical details about the server side=== +
- +
-The ''index.php'' works as a file finder which allows case-insensitive lookup of files. +
- +
-Depending on the requested ''file'' it either returns ''404'' or a ''Location''-header to the file on the server. +
- +
-This is required because Windows is case-insensitive (and original RPG2k was for Windows) and because the file extensions are not stored. ''Charset/Hero1'' could be ''Hero1.png'', hero1.bmp or ''HeRo1.xyz'', depending on which file exists. +
- +
-== Example ==+
  
-The file ''System/System1'' is requestedThe server returns ''Location: games/default/System/System1.png''The same result is expected for file ''SyStEm/systEM1''.+If you want to //try it locally// you need a HTTP server. Just opening the ''index.html'' in your browser will not workIf you don't have a local webserver the simplest way is installing Python and running ''python -m http.server''Then open ''http://localhost:8000/'' in your browser and navigate to your directory.
  
-== API ==+==== Deploying a game on your server ====
  
-Our file finder is stored under ''src/platform/easyrpg-filefinder.php''. In case you want to replace the file finder you only have to fulfill a very simple API.+Because RPG Maker games refer to files without extension and querying the server for every supported extension would be slow, you need to run a small tool to generate a file called ''index.json'' (containing an game file list index with extensions) for every game before uploading. The tool is called ''gencache''.
  
-The directory struture of the ''games'' folder is not part of the API contract. The player only expects that accessing ''games/'' invokes the file finder.+You can get the tool here:
  
-The only GET arguments that must be supported are ''game'' and ''file''.+  * {{https://ci.easyrpg.org/job/tools-win32/lastSuccessfulBuild/artifact/bin/gencache.exe|gencache for Windows}} 
 +  * {{https://ci.easyrpg.org/job/tools-linux/lastSuccessfulBuild/artifact/gencache.tar.gz|gencache for Linux}}
  
-''game'' is the name of the game that is executed.+Place the gencache executable in a game working folder (the folder containing RPG_RT.* files) to generate the ''index.json''. Move the ''gencache'' executable to working folders for each game you want to upload and run ''gencache'' again to generate the ''index.json'' for them. Once finished you can remove (don't upload it, it's not needed) the ''gencache'' from any game folder.
  
-''file'' is the name of the file the game requests.+Your games are expected in subdirectories of the ''games'' directory. The default game executed is the one in ''games/default''. You can create further games by just by putting them in subdirectories of the ''games'' directory.
  
-When a ''file'' is requested it must return a downloadable representation of the file. How doesn't matter, it can be an ''octet-stream'' or redirect via ''Location''-header. If the file is not found ''404'' must be returned.+Now access the ''index.html'' file and your default game should startTo play different game pass ''?game=folder_name'' as part of the URL (query string) to your index file.
development/player/web.1432075481.txt.gz · Last modified: 2015/05/19 22:44 by ghabry