Flame Book: 2D Game Development with Flutter and Dart

Flame powers Flutter, we can no longer only use the same code for mobile, desktop and web...  we can also use it to create 2D games?”. 

Flame is the key piece that makes it possible. If you are looking for a complete, practical Flame Flutter book designed for you to understand the engine from scratch, here I tell you exactly how I approach it and what you can expect.

What is Flame and why use it with Flutter?

Flame is a 2D game engine built on top of Flutter, and the best thing about it is its simplicity. Literally, installing Flame is as easy as adding a pub package, and voilà: you already have a game engine ready to run on Android, iOS, Linux, Windows, macOS and web.

What I love about Flame is that it is designed to make a Flutter developer feel at home. In my case, the first thing I noticed was that its main elements, the Components, work the same as the widgets: each one represents a part of your game (player, enemy, background, consumable...), each one with its own logic. That familiarity makes the learning curve incredibly smooth.

In addition, with Flame you have:

  • Handling of sprites and animated sprites
  • Collision detection
  • Integrated audio
  • Stable render loop at 60 FPS
  • Perfect integration with Flutter widgets
  • Plugins for physics, SVG, Tiled and more

With this you can go from an idea to a functional prototype in less time than it takes to start a Unity project.

 

I also have free resources for the Book on the Blog and the community/FREE course and book on the Academy website.

 

 

 

 Flame is IDEAL if you are a developer with Flutter and you want to LEARN to create games

 

With Flutter, we can make all kinds of applications especially focused on the mobile field, but, we can also use the same project to develop not only on Android and iOS, but also on desktop for Linux, MacOS and Windows, and also for web development making subtle changes in the project at the code level, although, Flutter goes much further with Flame.

Flame, is an engine to create 2D games with Flutter; its installation is extremely simple since, Flame is nothing more than a pub package; therefore, with this, we can create 2D games with Flame for mobile, desktop and web.

With Flame, we can create components, which are the equivalents of widgets in Flutter and where the components are nothing more than an element of our game, such as a player, an enemy, the background, a consumable, etc; and each component, contains the implementation for its operation; for example, in the case of a player, it contains the logic to move it, change animations, control lives, consumables, etc; and through a master class, we can organize all the logic of these components.

This book and book is mostly practical, we will learn the fundamentals of Flame based on small examples until we know enough about the library to create a simple 2D game.

 

 

 

Flame, for the development of 2D video games

Flame is an open source 2D game engine built in the Dart programming language and is used in conjunction with the Flutter framework as another plugin; therefore, we can use it to create games on mobile, desktop and web devices. 

Flame brings everything you need to create our first games

This game engine provides tools and components to handle game logic, sprite animation, collision detection, user input through taps, keyboard, joystick events and game physics; such as gravity, jumps, falls, etc.

With Flame, you can create 2D games with impressive graphics and high performance on mobile and desktop devices; therefore, with a single project, we can use it to bring our game to the different platforms supported by Flutter. 

Flame also has a series of plugins that we can use to handle audio among others:

  • flame_audio It is used to handle audio players.
  • flame_forge2d It is used to handle physical capabilities using our own Box2D port called Forge2D.
  • flame_tiled It is used to handle integration with tiles.
  • flame_svg Which provides integration with flutter_svg.

In short, you can use Flame with Flutter to create and develop 2D games with attractive graphics and high performance on mobile and desktop devices, giving developers a valuable tool to create a wide variety of games and applications.

With Flame, we can create components, which are the equivalents of widgets in Flutter and where the components are nothing more than an element of our game, such as a player, an enemy, the background, a consumable, etc; and each component, contains the implementation for its operation; for example, in the case of a player, it contains the logic to move it, change animations, control lives, consumables, etc; and through a master class, we can organize all the logic of these components.

 

 

 

book to learn to develop in Flame from scratch

This book is mostly practical, we will learn the fundamentals of Flame based on small examples until we know enough about the library to create simple 2D games; as you can see in each of the sections that make up the  book, we create various applications that have common features such as the use of sprites, animated sprites, sprite sheets, animations, collisions, input... but, seeing it from different approaches, which is crucial to understand in a practical way each of the functionalities of Flame and obtain a better understanding of all the potential of Flame.

Who this book is for

  • This book is aimed at anyone who wants to learn to develop in Flame and create their first 2D games with cross-platform Flutter.
  • For anyone who wants to start in the development of video games for Android, iOS, Linux, Windows, MacOS or web.
  • For those people who know how to program in Flutter.
  • For those people who want to learn something new.
  • For people who want to improve a skill and who want to grow as a developer and who want to continue scaling their path in the development of applications with Flutter.

This book has a practical approach, knowing the key aspects of the technology and moving on to practice, implementing little by little small features and functionalities that can be adapted to a real game; therefore, you can see the book as a set of guides or tutorials in which we will learn to handle Flame little by little.

What you will learn step by step

Throughout the book you will see:

  • How to start a Flame project from scratch
  • How to use GameWidget
  • How to create interactive components
  • How to handle complex animations
  • How to implement collisions
  • How to use overlays for menus and HUDs
  • How to integrate Flame with native Flutter
  • How to add audio and physics
  • How to export your game for mobile, desktop and web

Compatible technologies and platforms

With Flutter and Flame you work on a single project that runs on:

  • Android
  • iOS
  • Linux
  • Windows
  • macOS
  • Web

 

 

Prologue

With Flutter, we can make all kinds of applications especially focused on the mobile field, but, we can also use the same project to develop not only on Android and iOS, but also on desktop for Linux, MacOS and Windows, and also for web development making subtle changes in the project at the code level, although, Flutter goes much further with Flame.

Flame, is an engine to create 2D games with Flutter; its installation is extremely simple since, Flame is nothing more than a pub package; therefore, with this, we can create 2D games with Flame for mobile, desktop and web.

With Flame, we can create components, which are the equivalents of widgets in Flutter and where the components are nothing more than an element of our game, such as a player, an enemy, the background, a consumable, etc; and each component, contains the implementation for its operation; for example, in the case of a player, it contains the logic to move it, change animations, control lives, consumables, etc; and through a master class, we can organize all the logic of these components.

This book is mostly practical, we will learn the fundamentals of Flame based on small examples until we know enough about the library to create a simple 2D game.
 

 

 

 

 

Who this book is for

This book is aimed at anyone who wants to learn to develop in Flame and create their first 2D games with cross-platform Flutter.

  • For anyone who wants to start in the development of 2D video games for Android, iOS, Linux, Windows, MacOS or web.
  • For those people who know how to program in Flutter and who are looking to apply their programming skills in the development of 2D video games.
  • For those people who want to learn to develop their first 2D games.
  • For those people who want to learn something new.
  • For people who want to improve a skill and who want to grow as a developer and who want to continue scaling their path in the development of applications with Flutter.
     

Book content

This book has a total of 12 chapters, it is recommended that you read in the order in which they are arranged and as we explain the fundamentals of Flame based on examples; once you master the library, you can consult the sections in the order you want.

  • Chapter 1: We will create a project in Flutter with the basic dependencies necessary to create games with Flame in Flutter.
  • Chapter 2: This chapter is mostly theoretical and we will learn about the structure of Flame, which is mainly based on the Flame type classes, components and life cycle methods.
  • Chapter 3: This chapter we will see a practical approach to the features of Flame, such as the Game type classes, main components of Flame, keyboard input, tap and collisions.
  • Chapter 4: This chapter we will begin by creating the structure of a simple 2D collision game using as a basis part of the code seen in the previous chapter.
  • Chapter 5: This chapter presents the use of backgrounds to define it by means of a solid color or an image.
  • Chapter 6: This chapter presents the use of tile type backgrounds, using a software to edit the maps and using them in the project in Flutter with Flame.
  • Chapter 7: This chapter we will begin by creating the structure of a simple 2D jumping game using the tile system presented previously.
  • Chapter 8: This chapter we will make some additional changes to the previous game such as varying the jump, limiting the player's movements and defining a background.
  • Chapter 9: This chapter we will create a new game changing the perspective of its visualization and with it, the gameplay.
  • Chapter 10: In this chapter we will incorporate an enemy type sprite for the previous game, we will create different types of enemies varying the movement between a well-defined pattern and random movements.
  • Chapter 11: In this chapter we will create a new project in the style of Plants vs Zombies.
  • Chapter 12: We will learn to introduce sounds or audios for the games, which can be of two types, by actions or in the background.

 

Real examples created during the book

  • Dino Jump
    • A simple but complete runner style clone. Here you learn:
      • animations
      • collision detection
      • player control
      • obstacle spawns
  • Parallax Effect
    • One of my favorites because it shows how easy it is to create visual depth with Flame. Here we work with:
      • layered backgrounds
      • independent movements
      • dynamic visual effects
  • Plant vs Zombie (simplified version)
    • Here we combine components, collisions, animated sprites and attack logic. It is perfect for understanding how to coordinate multiple elements.
  • World XY
    • A map with displacement, animations and multiple entities. Ideal for understanding how to design wider worlds.

I agree to receive announcements of interest about this Blog.

Learn to create cross-platform 2D games with Flutter and Flame. This practical book starts from scratch and includes real-world examples, sprites, collision detection, animations, and more. Master Flutter and Flame and create cross-platform 2D games from the ground up. This practical book includes real-world examples, sprites, animations, collision detection, and everything you need to develop your first professional video game.

Algunas recomendaciones:

Benjamin Huizar Barajas

Laravel Legacy - Ya había tomado este curso pero era cuando estaba la versión 7 u 8. Ahora con la ac...

Andrés Rolán Torres

Laravel Legacy - Cumple de sobras con su propósito. Se nota el grandísimo esfuerzo puesto en este cu...

Cristian Semeria Cortes

Laravel Legacy - El curso la verdad esta muy bueno, por error compre este cuando ya estaba la versi...

Bryan Montes

Laravel Legacy - Hasta el momento el profesor es muy claro en cuanto al proceso de enseñanza y se pu...

José Nephtali Frías Cortés

Fllask 3 - Hasta el momento, están muy claras las expectativas del curso

| 👤 Andrés Cruz

🇪🇸 En español