Skip to content

Instantly share code, notes, and snippets.

@Dev-Owl
Created November 24, 2019 14:47
Show Gist options
  • Save Dev-Owl/2493a9e8f0c07afac98a962d389bc391 to your computer and use it in GitHub Desktop.
Save Dev-Owl/2493a9e8f0c07afac98a962d389bc391 to your computer and use it in GitHub Desktop.
Game with flame, box2d
import 'dart:ui';
import 'package:box2d_flame/box2d.dart';
import 'package:flame/flame.dart';
import 'package:flame/game.dart';
class MazeBallGame extends Game {
//Needed for Box2D
static const int WORLD_POOL_SIZE = 100;
static const int WORLD_POOL_CONTAINER_SIZE = 10;
//Main physic object -> our game world
World world;
//Zero vector -> no gravity
final Vector2 _gravity = Vector2.zero();
MazeBallGame(){
world = new World.withPool(_gravity,
DefaultWorldPool(WORLD_POOL_SIZE, WORLD_POOL_CONTAINER_SIZE));
initialize();
}
//Initialize all things we need, devided by things need the size and things without
Future initialize() async{
//Call the resize as soon as flutter is ready
resize(await Flame.util.initialDimensions());
}
void resize(Size size) {
// TODO: implement resize
super.resize(size);
}
@override
void render(Canvas canvas) {
// TODO: implement render
}
@override
void update(double t) {
// TODO: implement update
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment