You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pinball/packages/pinball_components/lib/src/components/kicker.dart

166 lines
4.8 KiB

import 'dart:math' as math;
import 'package:flame/components.dart';
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:geometry/geometry.dart' as geometry show centroid;
import 'package:pinball_components/gen/assets.gen.dart';
import 'package:pinball_components/pinball_components.dart' hide Assets;
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
/// {@template kicker}
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
/// Triangular [BodyType.static] body that propels the [Ball] towards the
/// opposite side.
///
/// [Kicker]s are usually positioned above each [Flipper].
/// {@endtemplate kicker}
class Kicker extends BodyComponent with InitialPosition {
/// {@macro kicker}
Kicker({
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
required BoardSide side,
}) : _side = side;
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
/// The size of the [Kicker] body.
static final Vector2 size = Vector2(4.4, 15);
/// Whether the [Kicker] is on the left or right side of the board.
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
///
/// A [Kicker] with [BoardSide.left] propels the [Ball] to the right,
/// whereas a [Kicker] with [BoardSide.right] propels the [Ball] to the
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
/// left.
final BoardSide _side;
List<FixtureDef> _createFixtureDefs() {
final fixturesDefs = <FixtureDef>[];
final direction = _side.direction;
const quarterPi = math.pi / 4;
final upperCircle = CircleShape()..radius = 1.6;
upperCircle.position.setValues(0, upperCircle.radius / 2);
final upperCircleFixtureDef = FixtureDef(upperCircle);
fixturesDefs.add(upperCircleFixtureDef);
final lowerCircle = CircleShape()..radius = 1.6;
lowerCircle.position.setValues(
size.x * -direction,
size.y + 0.8,
);
final lowerCircleFixtureDef = FixtureDef(lowerCircle);
fixturesDefs.add(lowerCircleFixtureDef);
final wallFacingEdge = EdgeShape()
..set(
upperCircle.position +
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
Vector2(
upperCircle.radius * direction,
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
0,
),
Vector2(2.5 * direction, size.y - 2),
);
final wallFacingLineFixtureDef = FixtureDef(wallFacingEdge);
fixturesDefs.add(wallFacingLineFixtureDef);
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
final bottomEdge = EdgeShape()
..set(
wallFacingEdge.vertex2,
lowerCircle.position +
Vector2(
lowerCircle.radius * math.cos(quarterPi) * direction,
lowerCircle.radius * math.sin(quarterPi),
),
);
final bottomLineFixtureDef = FixtureDef(bottomEdge);
fixturesDefs.add(bottomLineFixtureDef);
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
final bouncyEdge = EdgeShape()
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
..set(
upperCircle.position +
Vector2(
upperCircle.radius * math.cos(quarterPi) * -direction,
-upperCircle.radius * math.sin(quarterPi),
),
lowerCircle.position +
Vector2(
lowerCircle.radius * math.cos(quarterPi) * -direction,
-lowerCircle.radius * math.sin(quarterPi),
),
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
);
final bouncyFixtureDef = FixtureDef(
bouncyEdge,
// TODO(alestiago): Play with restitution value once game is bundled.
restitution: 10,
);
fixturesDefs.add(bouncyFixtureDef);
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
// TODO(alestiago): Evaluate if there is value on centering the fixtures.
final centroid = geometry.centroid(
[
upperCircle.position + Vector2(0, -upperCircle.radius),
lowerCircle.position +
Vector2(
lowerCircle.radius * math.cos(quarterPi) * -direction,
lowerCircle.radius * math.sin(quarterPi),
),
wallFacingEdge.vertex2,
],
);
for (final fixtureDef in fixturesDefs) {
fixtureDef.shape.moveBy(-centroid);
}
return fixturesDefs;
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
}
@override
Body createBody() {
final bodyDef = BodyDef(
position: initialPosition,
);
final body = world.createBody(bodyDef);
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
_createFixtureDefs().forEach(body.createFixture);
return body;
}
@override
Future<void> onLoad() async {
await super.onLoad();
renderBody = false;
await add(_KickerSpriteComponent(side: _side));
}
}
class _KickerSpriteComponent extends SpriteComponent with HasGameRef {
_KickerSpriteComponent({required BoardSide side}) : _side = side;
final BoardSide _side;
@override
Future<void> onLoad() async {
await super.onLoad();
final sprite = await gameRef.loadSprite(
(_side.isLeft)
? Assets.images.kicker.left.keyName
: Assets.images.kicker.right.keyName,
);
this.sprite = sprite;
size = sprite.originalSize / 10;
anchor = Anchor.center;
position = Vector2(0.7 * -_side.direction, -2.2);
}
feat: define SlingShot component (#39) * feat: created sling-short.dart * refactor: used appropiate file name * chore: included sling_shot export * refactor: simplified _createFixtureDefs * doc: included SlingShot in doc comment * feat: implemented basic SlingShot * feat: used EdgeShape instead of PolygonShape * feat: implemented _addSlingShot method * feat: adding placeholder art for the flippers * Update lib/game/components/flipper.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: included missing documentation (#29) * chore: ignored lint rue * docs: documented ball.dart * docs: ignored lint rule * docs: documented wall.dart * docs: documented game_over_dialog.dart * docs: fixed typo * docs: included TODO comments * fix: misisng doc * chore: add code owners (#31) * feat: add character selection (#20) * chore: lock file * feat: character selection page * fix: ignore generated asset coverage * chore: add suggestions * feat: tint ball with theme color * refactor: decrease theme cubit scope * chore: minimize changes * chore: typos and readability * refactor: use extension for initial pinball game * fix: tests from merge * refactor: ignore docs for views * refactor: revert to ignoring for file * fix: todo analyzer warning * refactor: remove Flutter dep from geometry (#27) * fix: removed flutter dependency * test: fixed tests for assertions * test: check assertion with isA * ci: added geometry workflow file * refactor: changed flame dep to vector_math for vector2 * fix: changed import for vector to vector_math_64 * Update .github/workflows/geometry.yaml Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: rename pinball game test extension (#33) * chore: rename pinball game test extension * refactor: initial to create * docs: small change * chore: removed unecessary end callback (#30) * feat: adding ball spawning upon click on debug mode (#28) * feat: adding ball spawming upon click on debug mode * PR suggestions * fix: coverage * fix: rebase * feat: rebase fixes * feat: moved triangle to centroid * feat: made SlingShot a PositionBodyComponent * feat: removed PositionBodyComponent * refactor: moved centroid function * refactor: simplified centroid function * docs: typo in macro * feat: modified restitution value * refactor: added variable for incline * docs: included TODO comment * feat: included tests * feat: removed friction from SlingShot * feat: removed adding slinghsots * refactor: used variables for fixtures * feat: included side in SlingShot * feat: included different shapes test * docs: fixed typo * refactor: removed unused import * refactor: used centroid from geometry package * docs: fixed typo * refactor: improved triangleVertices readability * refactor: removed EmptyGame class Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com>
3 years ago
}
// TODO(alestiago): Evaluate if there's value on generalising this to
// all shapes.
extension on Shape {
void moveBy(Vector2 offset) {
if (this is CircleShape) {
final circle = this as CircleShape;
circle.position.setFrom(circle.position + offset);
} else if (this is EdgeShape) {
final edge = this as EdgeShape;
edge.set(edge.vertex1 + offset, edge.vertex2 + offset);
}
}
}