Build better games with Flutter Casual Games Toolkit — a Google I/O ’22 update
This years Google I/O event was just as exciting as the previous ones. With so many new devices and updates to talk about, I am particularly interested in the Casual Games Toolkit that was introduced to provide resources to game developers to build beautiful, complex games.
As we all know, Flutter is an open source platform for app development where you can build mobile, web, desktop and embedded apps, and it is now having an increase in popularity towards game development.
One of the challenges faced by Flutter game developers that Google is trying their best to tackle is — lack of resources for building Flutter games.
If you try to google flutter games, the resources you will find are limited. And it is actually true because Game Development was never really an official use case until Google I/O ‘22. So that’s why this year’s I/O update is big for game developers and also to flutter developers that are planning to start with building games.
One very common question that game developers often get asked is “why flutter for games?”
A study was conducted on Fluter developers who had released Flutter games and they shared their experience which said that:
1. Flutter is simple to learn and easy to use , especially if it was a casual game, building UI was a lot simpler
So if you compare Flutter with other game development softwares, building the UI could be faster and could save up a lot of time as you can reuse the widgets.
2. Ability to look into the framework source code (no “black boxes”) and have full control of the canvas
3. The ability to design a widget and then reuse it in other parts of the game, which ensured data persistence
4. Some developers consider Flutter’s audio capabilities superior to other cross-platform UI toolkits
And thats because the audio integration is one such feature that Google is trying to improve in every update
5. Flutter is portable — you write your code once and the game runs on multiple platforms
So that was some of the feedback shared by the flutter game developers.
Community contributions
There are multiple games that were built using Flutter such as 4 pics 1 word, Kelimelik etc.
Flame, by definition is a minimalist 2D game engine built on top of Flutter — a library of solutions to tackle problems that arise during game development.
Flame offers features such as animations, physics, collision detection, and more. A package that can be used to build games that require high level features.
For example, if you’re building an action-based game, you can use the flame package, forge2d to control the physics of the game.
Types of games in Flutter:
Games in Flutter can be classified into roughly two types:
- App-like games include casual games such as board games, card games, puzzles, and strategy games.
— these kind of games respond to a user input, which can be a screen tap or a text input
— so you will see in the video here, every time the screen is tapped, the game is responding to that tap
2. Video games include arcade-style games that include shooters, racing games, and so on.
— these are action based and they require a continuous input device, like a joystick
— such games require high level animations, collision detection, and so on, which can be achieved by using packages like flame.
You might want to explore and plan every module ahead of building the game by exploring all the features that flame offers
Casual Games Toolkit
With that let’s look at what is Casual Games Toolkit, and why did Google decide to add it as an update in this years list of I/O updates
- A growing community of developers use Flutter for casual game development, by taking advantage of the hardware-accelerated graphics support that Flutter provides.
- Flutter becomes a great choice for user interaction games such as puzzles and word games
- For games that use game loop, Flame can be a helpful tool
So even if you want to build simple games, you can use flutter as it is a great choice, and for complex games, flame packages can be used to achieve the high level features.
So no matter what type of game you’re building, you can always consider Flutter to be a good option.
4. Casual Games Toolkit can be considered as a resource provided by google for the game developers, almost like a reference
Now let us now look at what is included in Casual Games Toolkit and how it is going to help game developers:
So google used the existing resources along with the new ones to speed up game development of casual games in flutter — click on Get the template to get a repository of resources with a detailed Readme file that explains how to integrate the features into your game
- comes with a full repository for the underlying code to help developers see how it was accomplished
- The game template app includes the following in-built features:
— main menu
— sound & music
— ads
— in-app purchases
— achievements and leader boards
— crashlytics support
4. The template is open source
5. And you can use the repository to make changes as per your game requirements
6. This repo has a working game that you can use as a reference for your next game, it has state management and also audio integration
Google I/O Pinball
- Google I/O pinball is a Flutter web game that was launched ahead of the I/O event ‘22
- It works on any platform that has a browser
- It also uses firebase as the hosting platform and also to track the high score of the player
- The source code is available, you can use it as a starter project for your next big game!
You can take the existing features and add those to your game to build your own game! This game is an example that you can create such powerful games with Flutter.
The game uses Flame package and it’s out of the box features to make the game running, some of those packages include:
- forge2d: a package for collision detection between game objects. Also to power the physics of the game
- flame_bloc : a package that bridges blocs with flame components. flame_bloc to keep track of the number of rounds left to play, any bonuses achieved through the game, as well as the current game score.
The game is available to play at : https://pinball.flutter.dev/
By now, you should have an idea of what the Casual Games Toolkit contains and how it can speed up the game development, especially for simpler games. This could be the start of building greater games in Flutter and I hope you’re equally excited for that!
If you wish to learn more about games, Flutter docs provide plenty of resources at https://docs.flutter.dev/resources/games-toolkit
Also, you can find my talk on this topic at https://youtu.be/qZtqMujsE3I
Some of the resources that helped me write this article:
- Perspectives from early adopters of Flutter as a game development tool — @taodong
2. Announcing the Flutter Casual Games Toolkit — @zoeyfan_43394
— https://medium.com/flutter/announcing-the-flutter-casual-games-toolkit-c22e401d8fee
3. I/O Pinball Powered by Flutter and Firebase — @vgv_team
— https://medium.com/flutter/i-o-pinball-powered-by-flutter-and-firebase-d22423f3f5d
Feel free to leave a comment and share as much if you found it helpful!