Flame : Part 1: Flutter Game development using Flame



What is Flame?

Flame is a popular game engine for the flutter programming language. This is a 2d game engine built on top of flutter. Flame provides lots of features which will help to make games quickly, as well as game loop. Flutter also includes core primitives such as a component system, animated sprites and images, collision detection, a world camera, an effects system, and gesture and input support.

Why to use Flame?

The best thing about flame is that it is an open source project under MIT licence. Flame is  modular and can also be extended with packages that offer integrations to other libraries, for instant Rive(for animations), audio players(for music and sound effects), and many more.

2D vs 3D game development:

2D games use flat graphics, called sprites, and don’t have three-dimensional geometry. They’re drawn to the screen as flat images, and the camera (orthographic camera) has no perspective. Flutter exposes us canvas, which is basically an API where you can make very low-level GPU calls to draw stuff. However, 3D games usually make use of three-dimensional geometry, with Materials and Textures rendered on the surface of GameObjects to make them appear as solid environments, characters and objects that make up the game world. 3D game engine works  as it delegates all that to the GPU by using low-level 3D call, so we don't have to do all maths work to make 3D game, canvas doest supports those advances 3d functions.

Set up Flame v1.0

Go to pubspec.yaml file and under dependencies add

  flame: ^1.0.0

then go to main.dart and import 'package:flame/flame.dart';


import 'package:flutter/material.dart'; import 'package:flame/flame.dart';

import 'package:flame/game.dart';
void main() {
var game = MyGame();
runApp(GameWidget(game: game));
}
class MyGame extends BaseGame{
@override
Future<void> onLoad() async {
print('loading....');
}

}

With this piece of code you have done set up and that function will output a basic graphic like shown below.


This blog just explains about flutter and set up of flutter, in the upcoming blogs we will see implementation of flame.



Post a Comment

Previous Post Next Post

Subscribe Us


Get tutorials, Flutter news and other exclusive content delivered to your inbox. Join 1000+ growth-oriented Flutter developers subscribed to the newsletter

100% value, 0% spam. Unsubscribe anytime