WavedashDocs

Love2D

Compile Love2D games to WebAssembly with love.js and host them on Wavedash.

View the example on GitHub

Love2D targets the browser through love.js, a community tool that compiles the Love2D runtime to WebAssembly via Emscripten. The output is a static folder that Wavedash can host.

Build for web

  1. Install love.js: npm install -g love.js
  2. Package your game as a .love file (zip your project folder)
  3. Run love.js to produce the web build:
love.js my-game.love build/web -t "My Game" -m 67108864

The -m flag sets the memory size in bytes (64MB above). Adjust based on your game's needs. The output is in build/web/.

SDK integration

Wavedash injects WavedashJS into the page before the Emscripten runtime loads. Call it from the JavaScript side — Love2D's Lua runtime doesn't have direct JS access, so use a small JS bridge.

Add a script to your index.html (or a separate .js file) that exposes wrapper functions:

window.wavedashSubmitScore = function(id, score) {
  WavedashJS.uploadLeaderboardScore(id, score, true);
};

window.wavedashGetUsername = function() {
  var user = WavedashJS.getUser();
  return user ? user.username : "";
};

To call these from Lua, use love.js's JavaScript FFI or pass data through the Emscripten file system.

Load progress

Both progress and completion hook into Emscripten's Module object. Define it before the love.js runtime loads:

var Module = {
  setStatus: function(text) {
    // Emscripten emits progress like "Downloading data... (123/456)"
    var m = text.match(/\((\d+(?:\.\d+)?)\/(\d+(?:\.\d+)?)\)/);
    if (m) {
      WavedashJS.updateLoadProgressZeroToOne(parseFloat(m[1]) / parseFloat(m[2]));
    }
  },
  postRun: [function() {
    WavedashJS.loadComplete();
  }]
};

wavedash.toml

game_id = "YOUR_GAME_ID_HERE"
upload_dir = "./build/web"
entrypoint = "index.html"

love.js builds bundle the entire Love2D runtime (~10-15MB). Make sure your game assets are optimized for web — compress images and use OGG for audio.