The code template I am using is fairly simple to follow. It enables a quick implementation of any 2D game or live visualisation application in Rust. I have put it into the piston2dtemplate GitHub repository which should help anyone requiring these UI functionalities. I could not really call it a library as it only contains a couple of traits and a
run function, but by looking through the examples that come with it, anyone can use it as a reference guide for developing applications in record time.
The first example is an application providing an interactive visualisation of the Mandlebrot set. The user can adjust the zoom and move the point of view across the canvas without losing definition. The implementation uses the image crate to build the set pixel-by-pixel. It is then imported within the
PistonWindow as a
Texture. At each detected button press, the new image is calculated and re-fed to the window. As fast as Rust can be, there is still an incompressible few seconds lag at each update request due to the recalculation of the set.
This minimalistic implementation of this classic game shows how to organise your code using sprites and render them on the
Piston Window. It also shows how to write captions of text on the screen using
Glyph structs. The sound is not implemented but could easily be with the music crate.
I hope you will find this code as useful to organise your own project as I do. If you have any questions or comments, do not hesitate to post them on github or twitter.