How to Create a 2D Snake Game in Flutter

Jan 17 2023 · Dart 2.17, Flutter 3.0, Android Studio or VS Code

Part 1: How to Create a 2D Snake Game in Flutter

01. Flutter as a 2D Game Engine

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Next episode: 02. Basics of 2D Rendering

Notes: 01. Flutter as a 2D Game Engine

You will need to be well aware with the basics of Flutter. Understanding of the common widgets, layouts and methods in Flutter is a definite prerequisite. You can learn about Flutter basics from the Flutter Apprentice

Transcript: 01. Flutter as a 2D Game Engine

In this video, you will learn about Flutter as a 2D game engine. You will also understand how and why Flutter is a good fit for 2D app-like-games.

Flutter is a UI development kit and is used to build apps with beautiful and even complex user interfaces. Flutter allows to you control every single pixel on the device’s screen and it does that very efficiently. It is fast and efficient at rendering the changes in the UI on the screen. It can do so at as high a rate as 120 FPS where FPS stands for frames per second.

Widgets are the building blocks of a Flutter app’s user interface. In games and animations, we move widgets around, change their appearance, or resize them, over a period of time. We keep track of these objects while taking some sort of inputs from the user, which are majorly touch inputs in the case of mobile apps and keyboard/mouse or game controller inputs in case of desktop apps. This can also change from game to game.

Since Flutter is efficient and is highly cross-platform, it is a very good candidate for simple 2D app-like-games. These games are very popular because they are easy to play. Some examples are Flappy Bird and Candy Crush.

Flutter aims to provide 60 frames per second (fps) performance, or 120 fps performance on devices capable of 120Hz updates. For 60fps, frames need to render approximately every 16ms. This makes Flutter a very good candidate for developing simple games.

There is a very popular game engine library available as well. It is called Flame and you can hand over a lot of the work to Flame when building a game but in this course, we are only going to stick with Flutter and will not use any external libraries or packages.

Let’s understand some basic concepts and look at some widgets that you will be using to develop the Snake game.