Building Games with Flutter

Book description

Build a complete game from start to finish using Flutter and Flame while getting acquainted with each building block in game design along the way

Key Features

  • Begin your Flutter game development journey with step-by-step instructions and best practices
  • Understand the Flame game engine and its essential elements for making games, sprite animation, tilemaps, and audio
  • Build enjoyable games with Flutter that can be played across different platforms

Book Description

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.

What you will learn

  • Discover the Flame engine and how to use it in game programming in Flutter
  • Organize the graphics and sounds used in your game
  • Animate a sprite in your games and detect when the player collides with tiles
  • Run the game as a web page and desktop app
  • Expand our player control with key navigation
  • Build your first game and make your enemies more intelligent with AI for games

Who this book is for

If you are a Flutter developer looking to apply your Flutter programming skills to games development, this book is for you. Basic knowledge of Dart will assist with understanding the concepts covered.

Table of contents

  1. Building Games with Flutter
  2. Contributors
  3. About the author
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
  6. Part 1: Game Basics
  7. Chapter 1: Getting Started with Flutter Games
    1. Technical requirements
    2. Working with Flutter
    3. Using Dart
      1. Compilation types
      2. Hot reload
      3. Native bridge
      4. Garbage collection
      5. Thread control
    4. Summarizing the book
      1. Flame
      2. Designing a game
      3. Graphics
      4. Input
      5. Sounds
      6. Level design
      7. Cross-platform games
      8. Advanced graphics effects
      9. Game AI
      10. Finishing the game
    5. Creating a simple example animation
    6. Summary
    7. Questions
  8. Chapter 2: Working with the Flame Engine
    1. Technical requirements
    2. Organizing the assets in your game
    3. Adding the game loop
      1. Update
      2. Render
    4. Working with components
      1. FlameGame
      2. Converting our code to use components
    5. Summary
    6. Questions
  9. Chapter 3: Building a Game Design
    1. Planning a game
    2. Designing the game screens
    3. Summary
    4. Questions
  10. Part 2: Graphics and Sound
  11. Chapter 4: Drawing and Animating Graphics
    1. Technical requirements
    2. Drawing on the screen
    3. Working with sprite animation
    4. Moving a sprite around the screen
    5. Colliding with other sprites
    6. Summary
    7. Questions
  12. Chapter 5: Moving the Graphics with Input
    1. Technical requirements
    2. Drawing onscreen controls
    3. Moving our character with onscreen controls
    4. Moving our character with touch
    5. Summary
    6. Questions
  13. Chapter 6: Playing Sound Effects and Music
    1. Technical requirements
    2. Playing background music
    3. Playing sound effects
    4. Controlling the volume
    5. Summary
    6. Questions
  14. Chapter 7: Designing Your Own Levels
    1. Technical requirements
    2. Introduction to Tiled
    3. Loading a tile map
    4. Adding dynamic objects to the map
    5. Understanding map navigation
    6. Detecting tile collisions
      1. Understanding collisions
      2. Implementing collisions
    7. Summary
    8. Questions
  15. Chapter 8: Scaling the Game for Web and Desktop
    1. Technical requirements
    2. Building the game for the web and desktop
      1. Setting the new screen boundary
      2. Fixing the sprites
      3. Fixing the coin and water components
      4. Fixing the background and tile map
      5. Fixing the HUD components
    3. Setting background music
    4. Setting Flutter Web build parameters
    5. Navigating with key events
    6. Summary
    7. Questions
  16. Part 3: Advanced Games Programming
  17. Chapter 9: Implementing Advanced Graphics Effects
    1. Technical requirements
    2. What are particle effects?
    3. Animating with particles
    4. Creating shadows with layers
    5. Summary
    6. Questions
  18. Chapter 10: Making Intelligent Enemies with AI
    1. Technical requirements
    2. Making enemies chase the player
    3. Navigating obstacles with pathfinding
    4. Summary
    5. Questions
  19. Chapter 11: Finishing the Game
    1. Technical requirements
    2. Wrapping up the game
      1. Adding a menu screen
      2. Adding a settings screen
      3. Adding a game over screen
      4. Compiling all screens with navigation routes and music volume
    3. Monetizing your game
      1. Adverts
      2. In-app purchases
      3. Purchase
    4. What else should I learn?
      1. Forge2d
      2. Nakama
      3. Rive
      4. What games shall I make?
    5. Where to get help?
    6. Summary
    7. Questions
  20. Appendix: Answers
    1. Chapter 1
    2. Chapter 2
    3. Chapter 3
    4. Chapter 4
    5. Chapter 5
    6. Chapter 6
    7. Chapter 7
    8. Chapter 8
    9. Chapter 9
    10. Chapter 10
    11. Chapter 11
    12. Why subscribe?
  21. Other Books You May Enjoy
    1. Packt is searching for authors like you

Product information

  • Title: Building Games with Flutter
  • Author(s): Paul Teale
  • Release date: June 2022
  • Publisher(s): Packt Publishing
  • ISBN: 9781801816984