Book Image

Building Games with Flutter

By : Paul Teale
Book Image

Building Games with Flutter

By: Paul Teale

Overview of this book

With its powerful tools and quick implementation capabilities, Flutter provides a new way to build scalable cross-platform apps. In this book, you'll learn how to build on your knowledge and use Flutter as the foundation for creating games. This game development book takes a hands-on approach to building a complete game from scratch. You'll see how to get started with the Flame library and build a simple animated example to test Flame. You'll then discover how to organize and load images and audio in your Flutter game. As you advance, you'll gain insights into the game loop and set it up for fast and efficient processing. The book also guides you in using Tiled to create maps, add sprites to the maps that the player can interact with, and see how to use tilemap collision to create paths for a player to walk on. Finally, you'll learn how to make enemies more intelligent with artificial intelligence (AI). By the end of the book, you'll have gained the confidence to build fun multiplatform games with Flutter.
Table of Contents (17 chapters)
1
Part 1: Game Basics
5
Part 2: Graphics and Sound
11
Part 3: Advanced Games Programming

Chapter 1: Getting Started with Flutter Games

Welcome to Building Games with Flutter!

We will show you how to use Google's Flutter framework to build scalable games that work across mobile and web platforms. Flutter may seem a strange choice at first for building games because there are more established frameworks for making games, such as Unity or Unreal Engine, but a lot of these tools are very complex to learn and it takes a long time to start producing games with them.

Building on your existing knowledge of Flutter and Dart, we will take you through the steps needed to build a 2D game that will work across all supported platforms. Starting with the basics, we will build on this knowledge and gradually get on to more advanced game topics. By the end of the book, you will be able to make your own 2D games containing the following:

  • Animating graphics around the screen
  • Playing sound effects and music
  • Controlling your player with keys, joystick, or gestures
  • Detecting when graphics collide
  • Creating game level maps and navigating around them
  • Designing games
  • Scaling the game across different platforms
  • Advanced graphical effects
  • Intelligent enemies

We will cover the core concepts with examples and then build on this, chapter by chapter, gradually building up a full game that works across different devices. Each chapter will contain code samples to help learn the building blocks of game development, along with the code, image, and sound resources to build our complete game. The game involves the player navigating around a map and avoiding the enemies while collecting as much gold as they can.

In this chapter, we want to delve a bit deeper into Flutter and Dart and what features they have that make them a great choice for game development. This will give you an understanding of why Flutter and Dart can be used for fast, smooth games across many platforms.

In this chapter, we will cover the following topics:

  • Working with Flutter
  • Using Dart
  • Summarizing the book
  • Creating a simple example animation

We have a lot to cover, so let's get started!