How can i create a 2d game engine in Rust?

What should i use or what tutorials i should follow to make a game engine in rust?

For the most part, you can do whatever you would do in another language. Some engine designs rely a lot on global system availability (e.g. the renderer, the window, the scene, etc). If it's once-init, then you can use something like once-cell to make this pattern safe.

Using an ECS, generational arena, etc is useful even in C++ to tame pointer soup. In Rust, since references are type checked (lifetimes), you aren't going to be able to do anything with a pointer soup design, so an arena token design is more necessary.

RustConf 2018 - Closing Keynote - Using Rust For Game Development by Catherine West - YouTube is a good talk in that space.

And finally, http://gameprogrammingpatterns.com/ is just a useful language agnostic resource.

4 Likes

Have you try checking bevy game engine. They have tutorials also. The game engine is written in rust

You might get plenty of mileage out of something like macroquad or ggez rather than jumping all the way to making or using an engine; it could be nicer to just make a game or two rather than something more general.

It's fun to make a game engine, yes, but I concur with the other advice here: your goal should be to make a game, and only develop whatever engine/tooling you need to support that game. If you set out to build an engine, you'll never be finished and never build a game.

Plus, having a concrete user of your engine will help you make better choices for usability of the engine over theoretical purity.

Now if only I would heed my own advice