WebPlayer for Love2D engine games (webgl+javascript)
JavaScript Lua PHP
Switch branches/tags
Nothing to show
Pull request Compare This branch is 3 commits ahead, 35 commits behind ghoulsblade:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Love2D WebPlayer
started 2012-03 ghoulsblade@schattenkind.net
demos: http://ghoulsblade.schattenkind.net/love-webplayer/
github: https://github.com/ghoulsblade/love-webplayer
infos: http://ghoulsblade.schattenkind.net/wiki/index.php/Love-WebPlayer
love-forum: https://love2d.org/forums/viewtopic.php?f=5&t=8487

goal : play games made for love2d inside the browser without plugins (webgl+javascript capable browser required)
usage: unpack .love file (rename to .zip), add the .js files and the index.html from love-webplayer, upload the whole folder to webserver, open in browser, play
tech : webgl for display, github.com/mherkender/lua.js to run lua code in javascript

love2d is a lua based 2d game engine : http://love2d.org/ 
lua-parser.js is a lua interpreter/converter in javascript from https://github.com/mherkender/lua.js (added LuaBootStrap call)

not-yet-implemented (incomplete list) 
* love 0.8 api (currently webplayer is mostly for 0.7, to test some 0.8 stuff add to index.html : <body onload="Love_Enable_Experimental_080(); ...>
* spritebatch,framebuf
* love.physics/box2d 
* font truetype/ttf loading (rasterizer), pixelfonts should work  (except a few special cases in text formatting/wrapping)
* network/luasocket
* love.thread
* love.sound sounddata/decoder stuff. audio itself should work, but is troublesome in some browsers, notably firefox (html5 audio)
* love.timer.sleep : not possible in js, would lead to browser hang in most browsers
* love.imagedata (load-from-file + imgdata.paste + graphics.newImage(imgdata) works, but not decoding, etc)
* love.filesystem stuff (some of it already works, but only if "localstorage" is available in the browser, stored in cookies or sth)
* debug.stacktrace and useful stacktraces on error in general (i recommend testing in native love first and if the problem is webplayer only litter the code with lots of print("pos01") to narrow it down)
* complex string matching pattern, especially balanced braces

known issues : 
* 404 warning in webconsole when using "require somemodule", you can safely ignore this, this is just the only way javascript can do a file-exists check for the module loading behavior of require
* (TODO) workaround for 404 : call LoveFileList('filelist.txt') in index.html body onload to enable love.filesystem.enumerate
* images have to be listed in index.html onLoad call for preloading, otherwise .width/.height access can return 0, and it's not possible in chrome+firefox to pause running code without changing code-structure to callback
* ticket/issue at lua.js github : https://github.com/mherkender/lua.js/issues/5
* parser bug : clouds demo : parse error in keypressed :  >> love.filesystem.load("main.lua")() << (already fixed for some generic cases) workaround : >> (love.filesystem.load("main.lua"))() <<
* parser NotImplemented : string.format("%d",5),debug.backtrace,coroutines,...
* firefox(11) is known to have issues with sound: lag,delay..   chrome (18.0.1025.151) works better for me on ubuntu 11.04 (2012-04)
* doesn't work with file:// url for some reason. so you need to upload stuff to a webserver to try, php and similar isn't needed.
* when changing lua files, be sure to clear browser cache to see your changes, pressing f5 is not enough since it doesn't refresh dynamically loaded files like the .lua ones

web api available:
* if (love.web) then ... end
* love.web.javascript("jsfun()")
* if (string.find(love.web.getAgent(),"MSIE")) then ...mp3... else ...ogg... end
* love.web.setMaxFPS(99) -- default 60, stepper interval
* love.web.showPreCompiledJS("map.lua") -- shows a html textbox with the lua file converted to javascript, useful for loading big (several mb) files in firefox without parser hang, see ludumdare201204 for example
* if (love.web.browserIsFirefox() or love.web.browserIsChrome()) then ... end