Installing Go 1.12
GopherJS requires Go 1.12 or older. Get Go 1.12 via your current Go:
go get golang.org/dl/go1.12.16 go1.12.16 download
See the official instruction to isntall extra versions of Go for the details.
Install gopherjs command. You might need to set
go1.12.16 get github.com/gopherjs/gopherjs
Compile your game with GopherJS:
gopherjs build -o yourgame.js path/to/yourgame
Then, open the below HTML on your HTTP server:
<!DOCTYPE html> <script src="yourgame.js"></script></code>
file:// URL may not work with Ebiten. Execute your game on a HTTP server.
If you want to embed your game into your web page, using iframe is strongly recommended.
You might find this message with Chrome:
The AudioContext was not allowed to start. It must be resume (or created) after a user gesture on the page. https://goo.gl/7K7WLu
In this case, you can solve this by putting
allow="autoplay" on the iframe.
Note that Ebiten automatically restores images on desktop browsers when the context is lost. This restoring doesn't work on mobile browsers for a performance reason.
Running examples on browsers
gopherjs serve --tags=example
And access to
On Windows, you might need to set GOOS environment variable: