I earlier wrote about all of the promises that Unity’s Project Tiny brings to the table with the ability to render 2D and 3D games with remarkable speed and small size. But for all the good that the ECS brings to the table, there are a lot of complications that it brings to the table. Enter Bevy, an Open Source data-driven game engine that is built in Rust.
Bevy, which code is available in Github, contains a number of examples in the Examples folder. Aftering getting the project, navigate to the examples folder and run cargo run — example breakout.
Taking a closer look at the examples, you can see that the Bevy engine and game logic is all built on a custom Entity Component System (ECS). ECS is a software paradigm that involves separating data into Components. All of the entities are assigned unique ids. An Entity makes up a group of Components.
The benefit to Bevy is that it uses normal Rust data types for all of these core elements. For example, Components are Rust structs, Systems are Rust functions, and Entities are a type that has a unique integer property. Because Components can be packed tightly together in memory, their read time is blazing fast. Systems have a read/write dependency tree that allows for a lock-free parallel scheduling.
So let’s look at some of the examples of the features:
Similar to Unity, scenes are a way to compose objects of your game ahead of time into a structure. In essence, it is a collection of entities and components. A scene can be “spawned” into the world (even multiple times!). Scene files can be written out to disk and are stored flat as JSON:
The SceneSpawner resource is what you can use to call to load a scene into the world space. Once in the space, the objects preserve their entity IDs and can be manipulated at runtime.
Bevy offers a zero-allocation event consumer system when trying to interact with things happening in the scene. This is used for things like window resizing, assets, and input.
So for all the hype does Bevy live up to the claims of being a Capable and Simple system? I’ll leave that up to you to decide.
Thank you for reading this far. If you enjoyed this post, please share, comment, and press that 👏 !
Follow me on Twitter and Medium if you’re interested in more in-depth and informative write-ups like these in the future!