Want to build 2D games? Now more accessible than ever with Flutter Flame.

Anyone who has wondered about creating a 2D game should learn about Flame. Game development has not been so easy until now! Keep reading to discover the new world of 2D games that Flutter and Flame offer you!

What is Flutter anyways?

Let's start by explaining what Flutter is - created by Google; it is an open-source framework used to develop applications for multiple platforms like Mobile, Desktop, Web, etc., from a single code base. Flutter is extremely developer-friendly, as it offers speed in performance and accessibility through plenty of documentation and cuts down on developing time without compromising on UI or any other aspect.

You've mentioned Flame... what is Flame?

With all of the above being said, let's explore what Flame is. Flame is a modular game engine that allows anyone who wants to create a 2D game with a complete set of tools! Flame is extremely powerful since it uses the Flutter infrastructure. Still, it also manages to simplify the developing process by tons. It has created another direction in which Flutter developers can go in. Flame is your best friend, from simple, catchy games to more advanced ones!

Why should we use Flame?

You might be wondering - it sounds all so nice, but why use Flame over an engine like Unity or Unreal Engine?

Well, it's a simple answer. No matter how much experience you have or don't even have, Flame is beginner-friendly! Since it is built on Flutter, it is naturally quite understandable and fast. You can still go out and create some pretty advanced games with it! It's all in your hands.

Flame provides not only the accessibility of developing a 2D game but also several packages for adding audio and integrating SVG. If we compare it to Unity, Flame is far from that level of game engines.

Nevertheless, the learning curve is not so steep, even if you have little experience with Flutter or programming. It's possible to start from the very beginning, and it's possible to dive right in and create advanced games immediately! Another thing worth mentioning, just like Flutter, Flame provides you with enough tools to develop fast without cutting down on essential aspects like Game Designs!

What do we need to get started?

Starting with Flame, it's pretty simple. All you need is a Flutter-compatible IDE like VS Code or Android Studio, a game idea you like and desire to create! Furthermore, you will need to set up a project. All you have to do is follow the Installation and Getting started guidelines on their official website.

Yes, it's that simple.

How to start learning Flame and create your very own game?

Let's review some of the basics you might find helpful when starting a game!

Whenever you begin a new Flutter project, you will find that in the folder lib, you have a file main.dart that you use to run your project. In the same folder, you should create all the other files containing game components and only run one in the main.dart file.

This way, your game structure will be more precise. We can see what all of this means in practice now.

Start by creating a file called game.dart, for example. There you would be displaying all of your components. It should look something like this:

Now it might be pretty useful to create the component we wanted to use. This is the Player component, and it's good if we create separate files for each one. Let's make the player.dart file and see what it looks like:

The @override functions we keep seeing ensure that they are always called at the start and don't need to be recalled. We can also notice that the component has a function you can explicitly call whenever you need it.

Some more explanations - we can see that Vector2 takes two values - the X-axis and Y-axis, respectively. With Flame, the 0's of the axis meet at the top left corner of the screen. Now you can choose your positions and sizes! Try it out differently and see what you prefer for your game.

Another thing worth mentioning, your images should already be in the folder assets and included in the pubspec.yaml so you can access them.

At this point, we have already created a component and called it in the base of the game. The only thing that is left is to run the game! This is as simple as that:

Now that you can run your game with a component, it is time for you to start adding more components and explore some functionalities! Everything you would want to know how to do, you can find in the Flame documentation.

To wrap up, every developer has once wondered about creating a catchy game. Game development is not that easy, given that one of the most famous engines is Unity, which is quite frankly tricky for beginners. However, with the game engine Flame, creating your own game is now more accessible than ever! All it takes is to start a Flutter project and add some components! The documentation is excellent, and the engine is easily accessible. There is no reason anymore not to try it out! Remember to enjoy creating and exploring with Flame!