Cookie Consent by Privacy Policies Generator Vegapit


Fast development of 2D games and visualisation apps in Rust with Piston

Rust Piston Mon Aug 12 2019 16:33:00 GMT+0100 (British Summer Time)

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.

Mandelbrot Set Browser

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.



Classic Pong

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.

Page loaded on Monday, August 3rd 2020 at 10:52:37