首页 > 其他分享 >5 Rust game engines to consider for your next project

5 Rust game engines to consider for your next project

时间:2022-11-17 09:23:56浏览次数:82  
标签:engine Bevy use consider engines next game your Rust

https://blog.logrocket.com/5-rust-game-engines-consider-next-project/

 

  5 min read 

5 Rust Game Engines To Consider For Your Next Project

More and more developers are choosing Rust over C++ as their go-to language for game development. There are many game engines you can use for projects in Rust. Let’s take a look at five popular Rust game engines and discuss how to choose the best option for your needs.

In this article:

Why use Rust for game development?

Before Rust was released, C++ was the go-to language for game development. Languages like C and Assembly provided reliable performance and speed in past years as well.

Many developers still use these languages for game development. However, the Rust community is strong, active, and growing, particularly in the game development domain.

According to Stack Overflow’s 2021 survey, Rust has been the most-loved language for the past six years. Its growing list of production users includes tech giants such as Atlassian, Mozilla, and more.

There are many reasons why Rust is so popular amongst large companies and developers. For example:

  • Rust is extremely fast because it does not use a garbage collector
  • Rust‘s build system, Cargo, helps manage your libraries, keep versions locked, and more
  • Rust supports functional and imperative paradigms

Typically, Rust is at least as fast as C/C++, and it may become a bit faster in the future because of upcoming performance updates to the language.

Rust also has a great capacity for game development because of its concurrency. Concurrency in Rust prevents data races and provides epic memory management to help make it impossible for your application to crash.

To me, Rust is a well-designed and very clean language. Though some consider Rust to have a steep learning curve, the extensive documentation and expanding crate registry can certainly help you quickly learn best practices.

Let us look at some Rust game engines you might want to consider for projects in the game development domain.

Amethyst

Amethyst is a data-driven and data-oriented game engine written in Rust. This free and open source software has grown popular because it’s fast and easy to use.

The core principles of Amethyst include:

  • Massively parallel architecture
  • Follows the Entity Component System (ECS) paradigm to organize game logic
  • Uses Rusty Object Notation (RON), which is simple and supports all data types

ECS makes Amethyst entirely thread-safe and avoids memory-locking of any sort. Learn more in the ECS infographic below:

Five Panel Infographic Defining Entity Component System

In addition, ECS enforces code modularity. As a result, you can share components such as your data structures or logic rather than having to rewrite them.

Amethyst is mainly used to develop 2D and 3D games. People getting started with Rust for game development find Amethyst to be beginner-friendly thanks to the precise documentation available to help developers working with the engine.

To install the Amethyst engine, add the following code below to your Cargo.toml file:

amethyst = "0.15.3"
 

As of this writing, Amethyst is partnered with the Bevy engine, meaning Bevy is essentially Amethyst 2.0. Developers should be aware that the Amethyst creators plan to eventually archive the amethyst/amethyst repo.

The Amethyst and Bevy projects are meant to be collaborative, not competitive. There are plans to streamline the different areas of these projects into one game engine in the future. Learn more about Bevy in the next section.

Bevy

Bevy is another simple data-driven game engine. While it is still in the early stages of development and likely to undergo significant changes, this does not stop its vital features from shining.

To use the Bevy engine, add the following line to your Cargo.toml:

bevy = "0.7.0"
 

Like Amethyst, Bevy uses ECS, applying modular architecture so components can be reused or even replaced. It is easy to use for beginners getting started in Rust for game development.

However, developers are warned against using Bevy for serious projects because the API is still in development and expected to significantly change.

You can use Bevy for 2D and 3D rendering, or you can compose a custom rendering flow using a graph data structure. Another great feature is the Bevy UI, which helps you compose UI dynamically either in code or using the scene format.

My favorite Bevy feature is hot_asset_reloading, which allows you to modify and reload assets without having to compile your changes. If you add an asset at runtime, this feature will catch it and reload it to be used, which is great for enhancing productiveness.

To enable this feature, just add this line:

$ asset_server.watch_for_changes().unwrap();
 

If you think this is the game engine you need, make sure you follow this full tutorial to gain a better understanding. As I said earlier, Bevy is still very much in development as of this writing, and its APIs are expected to change.

Fyrox

Fyrox is a production-ready engine with extensive documentation and resources that focuses on 2D and 3D rendering. To use the Fyrox engine, add the following line to your Cargo.toml:

rg3d = "0.24.0"
 

Besides being clear and easy to use, one of its popular features is the scene editor, which provides a scene preview as demonstrated in this example:

Fyrox Scene Editor Showing World Outliner, Scene Preview, and Node Properties

The Fyrox engine was originally called rg3d, but the project founder changed this working title based on a community poll. The current release (v0.24) supports Windows, Linux, macOS, and WebAssembly.

Unlike some other game engines, Fyrox features reliably quick iterative compilation.

Other new or improved features include 2D support, performance improvements in the UI layout and rendering, and more. The sound (rg3d_sound) was also optimized to be 30 percent faster.

Piston

The Piston project is maintained by an active group of contributors. Due to this sharing of maintenance and resources, it is described as a modular open source game engine.


Over 200k developers use LogRocket to create better digital experiences

Learn more →

To use the Piston engine, add the following line to your cargo.toml file:

piston = "0.53.1"
 

Piston’s extensive library collection encompasses 2D, 3D, image processing, event programming, a GUI, sound and animation, and other features. These libraries can be used independently depending on the project you are working on.

Maintenance of the libraries is shared amongst the developers to provide more time, increase productivity, and achieve higher quality in the codebases.

In addition to its modular libraries, Piston‘s public API allows you to access inputs like a gamepad, mouse, or keypad. Another great thing about Piston is the event loop. You can either pass your game logic into the event loop or create a separate thread for it.

Piston also uses a dynamic scripting language called Dyon, which was specifically created for game engines and designed to work with Rust. People with no programming experience will find it easy to pick up and use.

Make sure you check out this Piston repository to review some helpful examples and other necessary tutorials.

Nannou

Nannou is an open source game framework that is still in its early days. It is also more hands-on for developers, but it is still a popular game engine that is greatly in use at the moment. As of this writing, the Nannou crate has over 35,000 downloads.

To use the Nannou engine, add the following line to your cargo.toml file:

nannou = "0.18.1"
 

Nannou consists of a full palette of creative tools for graphics, audio, lasers, lighting, and more. In many ways, it is like a toolkit for artists — its many tools allow creative individuals to work productively.

This project is also a good toolkit to learn the Rust language. It aims to use only Rust libraries and will require you to use cargo build for compilation.

However, remember Rust has interoperability with other languages, especially with C and C++. If there are no Rust libraries available for the functionality you’re looking for, you can use something like bindgen to access another library.

How to decide which Rust game engine to use

After learning about the above five engines, you may be wondering which one you should use. The answer is not so straightforward. However, you can look at common patterns in what they offer to help determine which options best match your needs.

For example, all offer the GUI and an editor. A few focus on performance, especially Piston and Fyrox. Bevy offers hot_asset_reloading for more productivity.


More great articles from LogRocket:


The above options are not necessarily the best out of all the engines available. However, they all have high numbers of downloads, useful features, extensive documentation, and more. Any one of them might be a great option for your project.

In my opinion, the best approach to choosing a Rust game engine is to go through various game engine features and pick one that supports what you are trying to build. Ask yourself questions such as:

  • What features do I need for my project?
  • What unique features does each engine offer?
  • Is there documentation and community support available?

Conclusion

In this article, we looked at the Rust game engines Amethyst, Bevy, Fyrox, Piston, and Nannou. We also explored why Rust is such a widely loved language, which contributes to it being used more often in game development.

I hope this helped show you how to choose the most favorable game engine for your needs. If you enjoyed this article and want to fully begin your experience in game development, you can head over to see some tutorials using various engines.

标签:engine,Bevy,use,consider,engines,next,game,your,Rust
From: https://www.cnblogs.com/itfanr/p/16898300.html

相关文章