|
|
@ -33,18 +33,19 @@ class SlingShot extends BodyComponent {
|
|
|
|
/// left.
|
|
|
|
/// left.
|
|
|
|
final BoardSide _side;
|
|
|
|
final BoardSide _side;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The size of the [SlingShot] body.
|
|
|
|
|
|
|
|
// TODO(alestiago): Use size from PositionedBodyComponent instead,
|
|
|
|
|
|
|
|
// once a sprite is given.
|
|
|
|
|
|
|
|
static final Vector2 size = Vector2(6, 8);
|
|
|
|
|
|
|
|
|
|
|
|
List<FixtureDef> _createFixtureDefs() {
|
|
|
|
List<FixtureDef> _createFixtureDefs() {
|
|
|
|
final fixtures = <FixtureDef>[];
|
|
|
|
final fixtures = <FixtureDef>[];
|
|
|
|
|
|
|
|
|
|
|
|
// TODO(alestiago): Use size from PositionedBodyComponent instead,
|
|
|
|
|
|
|
|
// once a sprite is given.
|
|
|
|
|
|
|
|
final size = Vector2(10, 10);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO(alestiago): This magic number can be deduced by specifying the
|
|
|
|
// TODO(alestiago): This magic number can be deduced by specifying the
|
|
|
|
// angle and using polar coordinate system to place the bottom right
|
|
|
|
// angle and using polar coordinate system to place the bottom right
|
|
|
|
// vertex.
|
|
|
|
// vertex.
|
|
|
|
// Something as: y = -size.y * math.cos(angle)
|
|
|
|
// Something as: y = -size.y * math.cos(angle)
|
|
|
|
const additionalIncrement = 2;
|
|
|
|
const additionalIncrement = 3;
|
|
|
|
final triangleVertices = _side.isLeft
|
|
|
|
final triangleVertices = _side.isLeft
|
|
|
|
? [
|
|
|
|
? [
|
|
|
|
Vector2(0, 0),
|
|
|
|
Vector2(0, 0),
|
|
|
@ -78,7 +79,7 @@ class SlingShot extends BodyComponent {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
// TODO(alestiago): Play with restitution value once game is bundled.
|
|
|
|
// TODO(alestiago): Play with restitution value once game is bundled.
|
|
|
|
final kickerFixtureDef = FixtureDef(kicker)
|
|
|
|
final kickerFixtureDef = FixtureDef(kicker)
|
|
|
|
..restitution = 20.0
|
|
|
|
..restitution = 10.0
|
|
|
|
..friction = 0;
|
|
|
|
..friction = 0;
|
|
|
|
fixtures.add(kickerFixtureDef);
|
|
|
|
fixtures.add(kickerFixtureDef);
|
|
|
|
|
|
|
|
|
|
|
|