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/lib/game/components/kicker.dart

143 lines
4.4 KiB

import 'dart:math' as math;
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/extensions.dart';
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flutter/material.dart';
import 'package:geometry/geometry.dart' as geometry show centroid;
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:pinball/game/game.dart';
/// {@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
// TODO(alestiago): Use sprite instead of color when provided.
paint = Paint()
..color = const Color(0xFF00FF00)
..style = PaintingStyle.fill;
}
/// 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;
/// The size of the [Kicker] body.
// TODO(alestiago): Use size from PositionedBodyComponent instead,
// once a sprite is given.
static final Vector2 size = Vector2(4, 10);
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
List<FixtureDef> _createFixtureDefs() {
final fixturesDefs = <FixtureDef>[];
final direction = _side.direction;
const quarterPi = math.pi / 4;
final upperCircle = CircleShape()..radius = 1.45;
upperCircle.position.setValues(0, -upperCircle.radius / 2);
final upperCircleFixtureDef = FixtureDef(upperCircle)..friction = 0;
fixturesDefs.add(upperCircleFixtureDef);
final lowerCircle = CircleShape()..radius = 1.45;
lowerCircle.position.setValues(
size.x * -direction,
-size.y,
);
final lowerCircleFixtureDef = FixtureDef(lowerCircle)..friction = 0;
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,
),
// TODO(alestiago): Use values from design.
Vector2(2.0 * direction, -size.y + 2),
);
final wallFacingLineFixtureDef = FixtureDef(wallFacingEdge)..friction = 0;
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)..friction = 0;
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.0
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
..friction = 0;
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;
}
}
// 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);
}
}
}