Migrate flame_forge2d to monorepo (#852)

* Migrate flame_forge2d to monorepo

* Put in the temporary publish to none

* Update docs

* Add dart_code_metrics

* Add analysis options

* Fix analyze issues

* Fix formatting

* Add dart_code_metrics to flame_forge2d example
This commit is contained in:
Lukas Klingsbo
2021-06-21 22:02:32 +02:00
committed by GitHub
parent e2aee0cd63
commit cf19ec5e4e
40 changed files with 1766 additions and 7 deletions

View File

@ -0,0 +1,42 @@
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flame_forge2d/forge2d_game.dart';
import 'package:forge2d/forge2d.dart';
import 'package:flame/game.dart';
import 'package:flame_forge2d/body_component.dart';
List<Wall> createBoundaries(Forge2DGame game) {
final topLeft = Vector2.zero();
final bottomRight = game.screenToWorld(game.viewport.effectiveSize);
final topRight = Vector2(bottomRight.x, topLeft.y);
final bottomLeft = Vector2(topLeft.x, bottomRight.y);
return [
Wall(topLeft, topRight),
Wall(topRight, bottomRight),
Wall(bottomRight, bottomLeft),
Wall(bottomLeft, topLeft),
];
}
class Wall extends BodyComponent {
final Vector2 start;
final Vector2 end;
Wall(this.start, this.end);
@override
Body createBody() {
final shape = EdgeShape()..set(start, end);
final fixtureDef = FixtureDef(shape)
..restitution = 0.0
..friction = 0.3;
final bodyDef = BodyDef()
..userData = this // To be able to determine object in collision
..position = Vector2.zero()
..type = BodyType.static;
return world.createBody(bodyDef)..createFixture(fixtureDef);
}
}