Go: Image Rendering in 2D Video Games with Ebiten

Vincent
A Journey With Go
Published in
6 min readFeb 5, 2020

--

Illustration created for “A Journey With Go”, made from the original Go Gopher, created by Renee French.

ℹ️ This article is based on Ebiten 1.10.

Ebiten is a mature 2D game library, written in Go by Hajime Hosh. It is the engine in some mobile games on the Apple Store, such as Bear’s Restaurant, or desktop games like the OpenDiablo2, an open-source implementation of Diablo 2 with Go. Let’s now dive into some fundamental concepts in video games along with their implementation with Ebiten.

Animation

In the video game world, Ebiten renders animation thanks to separated still images. This collection of images are grouped together into a bigger image, usually called “texture atlas,” also called “sprite sheet.” Here is an example of it provided on the website:

This image is then loaded in the memory and rendered part by part where simple maths are sufficient. In the previous example, each part has a width of 32 pixels. Rendering each image is as simple as moving the X coordinates by 32 pixels. Here are the first steps:

--

--