TQ
dev.com

Blog about software development

Subscribe

Minesweeper written in Go using RayLib

15 Jul 2024 - by 'Maurits van der Schee'

In April I wrote Fyne Mines (Minesweeper in Go using Fyne) and I'm very happy with the release on the Fyne Games page. When further investigating cross platform game development (in Go) I ran into the RayLib engine (and it's Go bindings). During the holidays I decided to recreate my minesweeper game using RayLib to see how that would perform and how it's development in Go would compare to Ebiten and Fyne.

Source code: https://github.com/mevdschee/raylib-go-mines

Developer experience

Raylib uses OpenGL for rendering 2D and 3D and this results in very high performance graphics. RayLib has a very nice and clean API. RayLib includes RayGui and I used that for the buttons and the little menu at the start of the game. I tried compiling with RayGui 5.0.0, which required wayland (which could be disabled with the "x11" build tag), but ended up using RayGui 3.5.0 as I needed no complex GUI.

Cross compiling

Cross-platform support is available. You can compile for Windows on Linux is with the MinGW toolset. I tried to run the resulting Windows executable under Wine and succeeded. I even added some resource data (icon and such) to the resulting Windows executable. I used the winres (go command line) tool for that (see: https://github.com/tc-hib/go-winres). I also wrote a Makefile to create both the Windows and Linux (AMD64) executables from the latest Git tag.

Conclusion

If you are building a small (full screen) game, then RayLib may be the optimal choice. It offers a simple and high performance OpenGL abstraction across platforms, it is fast and easy to compile, has cross-compilation support and the RayLib bindings are available in many programming languages and for many platforms. I prefer RayLib over Ebiten in general: it feels more mature and more finished and it seems easier to port to other platforms (such as HTML5, Nintendo Switch or Android).

Download

Binaries: https://github.com/mevdschee/raylib-go-mines/releases

Links


PS: Liked this article? Please share it on Facebook, Twitter or LinkedIn.