Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building Games with Flutter

You're reading from   Building Games with Flutter The ultimate guide to creating multiplatform games using the Flame engine in Flutter 3

Arrow left icon
Product type Paperback
Published in Jun 2022
Publisher Packt
ISBN-13 9781801816984
Length 224 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Paul Teale Paul Teale
Author Profile Icon Paul Teale
Paul Teale
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Part 1: Game Basics
2. Chapter 1: Getting Started with Flutter Games FREE CHAPTER 3. Chapter 2: Working with the Flame Engine 4. Chapter 3: Building a Game Design 5. Part 2: Graphics and Sound
6. Chapter 4: Drawing and Animating Graphics 7. Chapter 5: Moving the Graphics with Input 8. Chapter 6: Playing Sound Effects and Music 9. Chapter 7: Designing Your Own Levels 10. Chapter 8: Scaling the Game for Web and Desktop 11. Part 3: Advanced Games Programming
12. Chapter 9: Implementing Advanced Graphics Effects 13. Chapter 10: Making Intelligent Enemies with AI 14. Chapter 11: Finishing the Game 15. Other Books You May Enjoy Appendix: Answers

Loading a tile map

In the Technical requirements section, we added our tile map files and the flame_tiled library, which is used for loading and displaying tile maps.

Each tile is 32 x 32 pixels, and the map is 50 tiles wide by 50 tiles high, so our total map size in pixels will be 1,600 x 1,600 pixels, which is 50 * 32 for width and height.

You can open the tiles.tmx file in Tiled if you want to see how the tile map looks there, but here is a screenshot of how our tile map looks when loaded and drawn:

Figure 7.4 – The Gold Rush tile map

The map is basic with water around the edges and paths leading to the center of the map, with grass everywhere else on the map.

We will use this as our base, adding objects and enemies to the map and collision detection to the water areas to prevent George or the enemies from moving off the edges of the map.

Let's get started by loading the tile map and displaying it:

  1. Open the main.dart file...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image