Import a web game (early preview)

Bring a browser game you made into Arcwright: it plays in the engine at once, and from there you can change it like any Arcwright game. Ask your AI to call import_web_game {folder: "/path/to/my-game"} (a folder with its index.html, its .zip, or the index.html itself).

What you get

  • Scenes/<Game>.ttrscene: a 2D camera the size of the game's canvas and a WebGame object.
  • Scripts/web/<game>.js: the web game bridge with your game's own code at the bottom, in page order.
  • Assets/Web/<game>/: its pictures (JPEG, GIF and BMP saved as PNG), looks.json and IMPORT.md (what was found and what is not supported). Its sounds go to Assets/Sounds/web_<game>_*.

Your game's code runs in the engine's own script runtime. The bridge gives it the browser calls a canvas game uses (canvas 2D drawing and transforms, requestAnimationFrame, timers, keyboard and mouse events, Image, Audio and a small Web Audio, localStorage, and fetch of its own data files). Every picture it draws becomes an engine sprite; rectangles, dots and text are tinted sprites. Play shows them as Web_<picture>_<n> objects.

Make it better

  • Change its code in Scripts/web/<game>.js, the part below __webGame(.
  • Change how a picture shows in looks.json, by the picture's path in the game:
{
  "img/firefly.png": { "glow": 1.6, "light": { "color": [1, 0.82, 0.4], "intensity": 1.6, "radius": 130, "flicker": 0.3 }, "material": { "mode": "unlit" } },
  "img/fox.png": { "image": "Web/my-game/img/fox_hd.png", "rim": 0.8, "contact_shadow": 34 },
  "glyph": { "material": { "mode": "unlit" } }
}

Keys: image (another picture with the same frame layout), glow, glow_color, rim, rim_color, rim_width, shading, sparkle, contact_shadow, tint, and light / material / occluder / particles (their fields as in light_2d, material_2d, occluder_2d, particles_2d). rect, dot, ring and glyph set the plain shapes and text. Import again to apply. The scene is kept when you import again.

  • Add engine objects round it in the scene: lighting_2d on the camera for night and bloom, lights, particles, weather.
  • Make it fully native. List the game's objects headless with the outside tool web_game_objects, then rewrite them as scene objects and a script, one kind at a time. Each object can then be selected, moved, lit and scripted in the editor.

Limits

Canvas 2D only. WebGL, Phaser, PixiJS and WebAssembly builds bring their pictures and sounds in, but do not draw yet. three.js games take the 3D route: their world is read into a model and a scene. Not bridged yet:

  • filled polygons other than rectangles and circles (drawn as their bounds);
  • gradients (drawn in their first colour), clip, and pixel reads (getImageData);
  • .webp and .svg pictures;
  • scripts loaded from the internet.

Play logs web bridge: not supported: ... once for anything else the game calls.

Arcwright Beta 3 (0.5.0) · generated from the engine source (026429ab6)Something wrong or missing? Tell us
Download Arcwright free