An optimized rewrite of gjtorikian/Earthbound-Battle-Backgrounds-JS with cleaner code
Earthbound, also known as Mother 2 in Japan, is a SNES game released in 1994. This project displays Earthbound's battle backgrounds in browsers. In order to render the frames, currently a Canvas 2D context is used. I'd be happy to use a WebGL 2 context once support is more wide-spread.
Yes. You can find a full-screen demo here.
[←]
and [→]
to change layer 1.[↑]
and [↓]
to change layer 2.The source code for the demo can be found here.
$ npm i -S earthbound-battle-backgrounds
This code is more or less equivalent to the demo from above, minus the key events.
import { BackgroundLayer, Engine } from "earthbound-battle-backgrounds";
/* Create two layers */
const layer1 = new BackgroundLayer(153);
const layer2 = new BackgroundLayer(298);
/* Create animation engine */
const engine = new Engine([layer1, layer2], {
canvas: document.querySelector("#target-canvas");
});
engine.animate();
A great portion of the code was essentially re-written. Essentially, this code…
computeFrame()
romGraphics.drawTile()
var
), but const
and let
.getX()
- and setX()
-style functions (cf. Java).registerType
etc.).LOG_TAG
variable-based logging.Version | Tag | Published |
---|---|---|
2.0.6 | latest | 5yrs ago |