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/flipper.dart

281 lines
8.1 KiB

feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
import 'dart:async';
import 'dart:math' as math;
import 'package:flame/components.dart';
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
import 'package:flame/input.dart';
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flutter/material.dart';
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
import 'package:flutter/services.dart';
import 'package:pinball/game/game.dart';
/// {@template flipper}
/// A bat, typically found in pairs at the bottom of the board.
///
/// [Flipper] can be controlled by the player in an arc motion.
/// {@endtemplate flipper}
class Flipper extends BodyComponent with KeyboardHandler, InitialPosition {
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
/// {@macro flipper}
Flipper._({
required this.side,
required List<LogicalKeyboardKey> keys,
}) : _keys = keys;
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
Flipper._left()
: this._(
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
side: BoardSide.left,
keys: [
LogicalKeyboardKey.arrowLeft,
LogicalKeyboardKey.keyA,
],
);
Flipper._right()
: this._(
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
side: BoardSide.right,
keys: [
LogicalKeyboardKey.arrowRight,
LogicalKeyboardKey.keyD,
],
);
/// Constructs a [Flipper] from a [BoardSide].
///
/// A [Flipper._right] and [Flipper._left] besides being mirrored
/// horizontally, also have different [LogicalKeyboardKey]s that control them.
factory Flipper.fromSide({
required BoardSide side,
}) {
switch (side) {
case BoardSide.left:
return Flipper._left();
case BoardSide.right:
return Flipper._right();
}
}
3 years ago
/// Asset location of the sprite that renders with the [Flipper].
///
/// Sprite is preloaded by [PinballGameAssetsX].
static const spritePath = 'components/flipper.png';
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
/// The width of the [Flipper].
static const width = 12.0;
/// The height of the [Flipper].
static const height = 2.8;
/// The speed required to move the [Flipper] to its highest position.
///
/// The higher the value, the faster the [Flipper] will move.
static const double _speed = 60;
/// Whether the [Flipper] is on the left or right side of the board.
///
/// A [Flipper] with [BoardSide.left] has a counter-clockwise arc motion,
/// whereas a [Flipper] with [BoardSide.right] has a clockwise arc motion.
final BoardSide side;
/// The [LogicalKeyboardKey]s that will control the [Flipper].
///
/// [onKeyEvent] method listens to when one of these keys is pressed.
final List<LogicalKeyboardKey> _keys;
/// Applies downward linear velocity to the [Flipper], moving it to its
/// resting position.
void _moveDown() {
body.linearVelocity = Vector2(0, -_speed);
}
/// Applies upward linear velocity to the [Flipper], moving it to its highest
/// position.
void _moveUp() {
body.linearVelocity = Vector2(0, _speed);
}
feat: implemented Flipper grouping (#32) * feat: started implementing FlipperGroup * refactor: simplified Flipper logic * refactor: used extension instead of condition * docs: used "loads" over "adds" * feat: used size rather than width and height * refactor: removed unecessary mixin * feat: reorder methods * refactor: removed _joint over joint * docs: fixed macro typo * feat: unawait add operation * feat: included tests * 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: adding bonus logic to the game bloc (#24) * feat: adding bonus logic to the game bloc * feat: PR suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions * chore: main rebase * feat: pr suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestion * feat: pr suggestions * feat: pr suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: add plunger to board (#25) * feat: add plunger to board * refactor: leave spawn ball synchronous * fix: ball test * refactor: position ball internally * fix: ball position test * refactor: use joint specific anchor * refactor: remove ballSize * fix: plunger position * refactor: use relative positioning Co-authored-by: Alejandro Santiago <dev@alestiago.com> * refactor: added missing white space Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: adding missing white space Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: renamed test * refactor: used ! instead of ? * chore: rebasing * refactor: simplified Flipper logic * refactor: used extension instead of condition * docs: used "loads" over "adds" * feat: used size rather than width and height * refactor: removed unecessary mixin * feat: reorder methods * refactor: removed _joint over joint * docs: fixed macro typo * chore: rebasing * refactor: added missing white space * refactor: used ! instead of ? Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Erick <erickzanardoo@gmail.com>
3 years ago
/// Loads the sprite that renders with the [Flipper].
Future<void> _loadSprite() async {
final sprite = await gameRef.loadSprite(spritePath);
final spriteComponent = SpriteComponent(
feat: implemented Flipper grouping (#32) * feat: started implementing FlipperGroup * refactor: simplified Flipper logic * refactor: used extension instead of condition * docs: used "loads" over "adds" * feat: used size rather than width and height * refactor: removed unecessary mixin * feat: reorder methods * refactor: removed _joint over joint * docs: fixed macro typo * feat: unawait add operation * feat: included tests * 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: adding bonus logic to the game bloc (#24) * feat: adding bonus logic to the game bloc * feat: PR suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions * chore: main rebase * feat: pr suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestion * feat: pr suggestions * feat: pr suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: add plunger to board (#25) * feat: add plunger to board * refactor: leave spawn ball synchronous * fix: ball test * refactor: position ball internally * fix: ball position test * refactor: use joint specific anchor * refactor: remove ballSize * fix: plunger position * refactor: use relative positioning Co-authored-by: Alejandro Santiago <dev@alestiago.com> * refactor: added missing white space Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: adding missing white space Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: renamed test * refactor: used ! instead of ? * chore: rebasing * refactor: simplified Flipper logic * refactor: used extension instead of condition * docs: used "loads" over "adds" * feat: used size rather than width and height * refactor: removed unecessary mixin * feat: reorder methods * refactor: removed _joint over joint * docs: fixed macro typo * chore: rebasing * refactor: added missing white space * refactor: used ! instead of ? Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Erick <erickzanardoo@gmail.com>
3 years ago
sprite: sprite,
size: Vector2(width, height),
anchor: Anchor.center,
feat: implemented Flipper grouping (#32) * feat: started implementing FlipperGroup * refactor: simplified Flipper logic * refactor: used extension instead of condition * docs: used "loads" over "adds" * feat: used size rather than width and height * refactor: removed unecessary mixin * feat: reorder methods * refactor: removed _joint over joint * docs: fixed macro typo * feat: unawait add operation * feat: included tests * 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: adding bonus logic to the game bloc (#24) * feat: adding bonus logic to the game bloc * feat: PR suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions * chore: main rebase * feat: pr suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestion * feat: pr suggestions * feat: pr suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: add plunger to board (#25) * feat: add plunger to board * refactor: leave spawn ball synchronous * fix: ball test * refactor: position ball internally * fix: ball position test * refactor: use joint specific anchor * refactor: remove ballSize * fix: plunger position * refactor: use relative positioning Co-authored-by: Alejandro Santiago <dev@alestiago.com> * refactor: added missing white space Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: adding missing white space Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: renamed test * refactor: used ! instead of ? * chore: rebasing * refactor: simplified Flipper logic * refactor: used extension instead of condition * docs: used "loads" over "adds" * feat: used size rather than width and height * refactor: removed unecessary mixin * feat: reorder methods * refactor: removed _joint over joint * docs: fixed macro typo * chore: rebasing * refactor: added missing white space * refactor: used ! instead of ? Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Erick <erickzanardoo@gmail.com>
3 years ago
);
if (side.isRight) {
spriteComponent.flipHorizontally();
feat: implemented Flipper grouping (#32) * feat: started implementing FlipperGroup * refactor: simplified Flipper logic * refactor: used extension instead of condition * docs: used "loads" over "adds" * feat: used size rather than width and height * refactor: removed unecessary mixin * feat: reorder methods * refactor: removed _joint over joint * docs: fixed macro typo * feat: unawait add operation * feat: included tests * 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: adding bonus logic to the game bloc (#24) * feat: adding bonus logic to the game bloc * feat: PR suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions * chore: main rebase * feat: pr suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestion * feat: pr suggestions * feat: pr suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: add plunger to board (#25) * feat: add plunger to board * refactor: leave spawn ball synchronous * fix: ball test * refactor: position ball internally * fix: ball position test * refactor: use joint specific anchor * refactor: remove ballSize * fix: plunger position * refactor: use relative positioning Co-authored-by: Alejandro Santiago <dev@alestiago.com> * refactor: added missing white space Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: adding missing white space Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: renamed test * refactor: used ! instead of ? * chore: rebasing * refactor: simplified Flipper logic * refactor: used extension instead of condition * docs: used "loads" over "adds" * feat: used size rather than width and height * refactor: removed unecessary mixin * feat: reorder methods * refactor: removed _joint over joint * docs: fixed macro typo * chore: rebasing * refactor: added missing white space * refactor: used ! instead of ? Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Erick <erickzanardoo@gmail.com>
3 years ago
}
await add(spriteComponent);
feat: implemented Flipper grouping (#32) * feat: started implementing FlipperGroup * refactor: simplified Flipper logic * refactor: used extension instead of condition * docs: used "loads" over "adds" * feat: used size rather than width and height * refactor: removed unecessary mixin * feat: reorder methods * refactor: removed _joint over joint * docs: fixed macro typo * feat: unawait add operation * feat: included tests * 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: adding bonus logic to the game bloc (#24) * feat: adding bonus logic to the game bloc * feat: PR suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions * chore: main rebase * feat: pr suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestion * feat: pr suggestions * feat: pr suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: add plunger to board (#25) * feat: add plunger to board * refactor: leave spawn ball synchronous * fix: ball test * refactor: position ball internally * fix: ball position test * refactor: use joint specific anchor * refactor: remove ballSize * fix: plunger position * refactor: use relative positioning Co-authored-by: Alejandro Santiago <dev@alestiago.com> * refactor: added missing white space Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: adding missing white space Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: renamed test * refactor: used ! instead of ? * chore: rebasing * refactor: simplified Flipper logic * refactor: used extension instead of condition * docs: used "loads" over "adds" * feat: used size rather than width and height * refactor: removed unecessary mixin * feat: reorder methods * refactor: removed _joint over joint * docs: fixed macro typo * chore: rebasing * refactor: added missing white space * refactor: used ! instead of ? Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Erick <erickzanardoo@gmail.com>
3 years ago
}
/// Anchors the [Flipper] to the [RevoluteJoint] that controls its arc motion.
Future<void> _anchorToJoint() async {
final anchor = FlipperAnchor(flipper: this);
await add(anchor);
final jointDef = FlipperAnchorRevoluteJointDef(
flipper: this,
anchor: anchor,
);
// TODO(alestiago): Remove casting once the following is closed:
// https://github.com/flame-engine/forge2d/issues/36
final joint = world.createJoint(jointDef) as RevoluteJoint;
// FIXME(erickzanardo): when mounted the initial position is not fully
// reached.
unawaited(
mounted.whenComplete(
() => FlipperAnchorRevoluteJointDef.unlock(joint, side),
),
);
}
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
List<FixtureDef> _createFixtureDefs() {
feat: crossing upper ramps (#40) * feat: added generic area and area callback for ramps crossing * feat: added jetpack ramp (blue one) and own area, contact callback and maskbits * feat: added sparky ramp (yellow one) and own area, contact callback and maskbits * feat: included ramp components * feat: added maskbits to ball for collisions * feat: added paths to pinball game * feat: added maskbits to paths * fix: fixed collisions of a ball that only touch path entrance but doesn't get into * fix: analysis warnings * feat: ball default maskbits * chore: refactor some names and vars * test: tests for ramps and callbacks, and coverage * test: pinball game check ramps are added * test: tests for ramps check childrens * test: fixing tests for ramps * test: fix tests * chore: increase sparky angle * fix: placed plunge aligned with straight launcher path * fix: fixed maskBits change for ball on crossing ramps and tests coverage * doc: public member api docs * chore: placed launcher ramp * test: moved mock from crossing ramps to helpers file * fix: build and dep where broken by forge2d/position_body_component * Update lib/game/components/crossing_ramp.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update lib/game/components/jetpack_ramp.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update test/game/components/crossing_ramp_test.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update test/game/components/jetpack_ramp_test.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update test/game/components/sparky_ramp_test.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update lib/game/components/jetpack_ramp.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * chore: fixed formatting * chore: removed coverage tool * Update lib/game/components/crossing_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/ball_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update lib/game/components/crossing_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update lib/game/components/jetpack_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/crossing_ramp_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/pathway_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/pinball_game_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/pathway_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * test: fix tests and groups * chore: ramp area name changed to opening * refactor: ball with mixin Layer for mask collisions * chore: avoid foreach in a function literal * refactor: hide maskbits and manage only with layer param * chore: formatting file * refactor: changed name for ramp area * refactor: sparky+launcher into one path * doc: doc layer for ball * refactor: sparky to launcher * feat: allow jetpack ramp to be over the board * feat: refactor to allow jetpack ramp to be above board and launcher ramp * test: coverage * fix: fixed conflict with merge Component position * chore: analysis fixes * chore: doc and comments * refactor: initial position to ramps and cleaned ramp callbacks * refactor: improved ramp contact callback * refactor: ball layer and ramp addAll components * refactor: create fixtures for pathways and opening improved * refactor: placed ramps on pinball game * refactor: splitted layer from rampopening * refactor: rampopening with layered mixin * test: fixed all changes with tests * test: fixed tests after Layer mixin changes * chore: refactor names, test and doc * chore: review docs and names * fix: fixed tests and bug with initialposition collision * chore: analysis error * fix: fixed collision end from ramps * test: coverage * chore: fixed spaces between methods and other comments from pr * chore: remove unnecessary layer set on Layered * fix: removed unrelated files from pr * chore: removed unused import * refactor: ballsInside private and removed from tests * chore: todo comment * chore: removed unused import * chore: removed podfile * doc: changed Layered doc * doc: changed Layered doc * Update test/game/components/ramp_opening_test.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/game/components/layer.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: improved punctuation Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Alejandro Santiago <dev@alestiago.com>
3 years ago
final fixturesDef = <FixtureDef>[];
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
final isLeft = side.isLeft;
final bigCircleShape = CircleShape()..radius = height / 2;
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
bigCircleShape.position.setValues(
isLeft
? -(width / 2) + bigCircleShape.radius
: (width / 2) - bigCircleShape.radius,
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
0,
);
final bigCircleFixtureDef = FixtureDef(bigCircleShape);
feat: crossing upper ramps (#40) * feat: added generic area and area callback for ramps crossing * feat: added jetpack ramp (blue one) and own area, contact callback and maskbits * feat: added sparky ramp (yellow one) and own area, contact callback and maskbits * feat: included ramp components * feat: added maskbits to ball for collisions * feat: added paths to pinball game * feat: added maskbits to paths * fix: fixed collisions of a ball that only touch path entrance but doesn't get into * fix: analysis warnings * feat: ball default maskbits * chore: refactor some names and vars * test: tests for ramps and callbacks, and coverage * test: pinball game check ramps are added * test: tests for ramps check childrens * test: fixing tests for ramps * test: fix tests * chore: increase sparky angle * fix: placed plunge aligned with straight launcher path * fix: fixed maskBits change for ball on crossing ramps and tests coverage * doc: public member api docs * chore: placed launcher ramp * test: moved mock from crossing ramps to helpers file * fix: build and dep where broken by forge2d/position_body_component * Update lib/game/components/crossing_ramp.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update lib/game/components/jetpack_ramp.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update test/game/components/crossing_ramp_test.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update test/game/components/jetpack_ramp_test.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update test/game/components/sparky_ramp_test.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update lib/game/components/jetpack_ramp.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * chore: fixed formatting * chore: removed coverage tool * Update lib/game/components/crossing_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/ball_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update lib/game/components/crossing_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update lib/game/components/jetpack_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/crossing_ramp_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/pathway_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/pinball_game_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/pathway_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * test: fix tests and groups * chore: ramp area name changed to opening * refactor: ball with mixin Layer for mask collisions * chore: avoid foreach in a function literal * refactor: hide maskbits and manage only with layer param * chore: formatting file * refactor: changed name for ramp area * refactor: sparky+launcher into one path * doc: doc layer for ball * refactor: sparky to launcher * feat: allow jetpack ramp to be over the board * feat: refactor to allow jetpack ramp to be above board and launcher ramp * test: coverage * fix: fixed conflict with merge Component position * chore: analysis fixes * chore: doc and comments * refactor: initial position to ramps and cleaned ramp callbacks * refactor: improved ramp contact callback * refactor: ball layer and ramp addAll components * refactor: create fixtures for pathways and opening improved * refactor: placed ramps on pinball game * refactor: splitted layer from rampopening * refactor: rampopening with layered mixin * test: fixed all changes with tests * test: fixed tests after Layer mixin changes * chore: refactor names, test and doc * chore: review docs and names * fix: fixed tests and bug with initialposition collision * chore: analysis error * fix: fixed collision end from ramps * test: coverage * chore: fixed spaces between methods and other comments from pr * chore: remove unnecessary layer set on Layered * fix: removed unrelated files from pr * chore: removed unused import * refactor: ballsInside private and removed from tests * chore: todo comment * chore: removed unused import * chore: removed podfile * doc: changed Layered doc * doc: changed Layered doc * Update test/game/components/ramp_opening_test.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/game/components/layer.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: improved punctuation Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Alejandro Santiago <dev@alestiago.com>
3 years ago
fixturesDef.add(bigCircleFixtureDef);
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
final smallCircleShape = CircleShape()..radius = bigCircleShape.radius / 2;
smallCircleShape.position.setValues(
isLeft
? (width / 2) - smallCircleShape.radius
: -(width / 2) + smallCircleShape.radius,
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
0,
);
final smallCircleFixtureDef = FixtureDef(smallCircleShape);
feat: crossing upper ramps (#40) * feat: added generic area and area callback for ramps crossing * feat: added jetpack ramp (blue one) and own area, contact callback and maskbits * feat: added sparky ramp (yellow one) and own area, contact callback and maskbits * feat: included ramp components * feat: added maskbits to ball for collisions * feat: added paths to pinball game * feat: added maskbits to paths * fix: fixed collisions of a ball that only touch path entrance but doesn't get into * fix: analysis warnings * feat: ball default maskbits * chore: refactor some names and vars * test: tests for ramps and callbacks, and coverage * test: pinball game check ramps are added * test: tests for ramps check childrens * test: fixing tests for ramps * test: fix tests * chore: increase sparky angle * fix: placed plunge aligned with straight launcher path * fix: fixed maskBits change for ball on crossing ramps and tests coverage * doc: public member api docs * chore: placed launcher ramp * test: moved mock from crossing ramps to helpers file * fix: build and dep where broken by forge2d/position_body_component * Update lib/game/components/crossing_ramp.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update lib/game/components/jetpack_ramp.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update test/game/components/crossing_ramp_test.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update test/game/components/jetpack_ramp_test.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update test/game/components/sparky_ramp_test.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update lib/game/components/jetpack_ramp.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * chore: fixed formatting * chore: removed coverage tool * Update lib/game/components/crossing_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/ball_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update lib/game/components/crossing_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update lib/game/components/jetpack_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/crossing_ramp_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/pathway_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/pinball_game_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/pathway_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * test: fix tests and groups * chore: ramp area name changed to opening * refactor: ball with mixin Layer for mask collisions * chore: avoid foreach in a function literal * refactor: hide maskbits and manage only with layer param * chore: formatting file * refactor: changed name for ramp area * refactor: sparky+launcher into one path * doc: doc layer for ball * refactor: sparky to launcher * feat: allow jetpack ramp to be over the board * feat: refactor to allow jetpack ramp to be above board and launcher ramp * test: coverage * fix: fixed conflict with merge Component position * chore: analysis fixes * chore: doc and comments * refactor: initial position to ramps and cleaned ramp callbacks * refactor: improved ramp contact callback * refactor: ball layer and ramp addAll components * refactor: create fixtures for pathways and opening improved * refactor: placed ramps on pinball game * refactor: splitted layer from rampopening * refactor: rampopening with layered mixin * test: fixed all changes with tests * test: fixed tests after Layer mixin changes * chore: refactor names, test and doc * chore: review docs and names * fix: fixed tests and bug with initialposition collision * chore: analysis error * fix: fixed collision end from ramps * test: coverage * chore: fixed spaces between methods and other comments from pr * chore: remove unnecessary layer set on Layered * fix: removed unrelated files from pr * chore: removed unused import * refactor: ballsInside private and removed from tests * chore: todo comment * chore: removed unused import * chore: removed podfile * doc: changed Layered doc * doc: changed Layered doc * Update test/game/components/ramp_opening_test.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/game/components/layer.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: improved punctuation Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Alejandro Santiago <dev@alestiago.com>
3 years ago
fixturesDef.add(smallCircleFixtureDef);
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
final trapeziumVertices = isLeft
? [
Vector2(bigCircleShape.position.x, bigCircleShape.radius),
Vector2(smallCircleShape.position.x, smallCircleShape.radius),
Vector2(smallCircleShape.position.x, -smallCircleShape.radius),
Vector2(bigCircleShape.position.x, -bigCircleShape.radius),
]
: [
Vector2(smallCircleShape.position.x, smallCircleShape.radius),
Vector2(bigCircleShape.position.x, bigCircleShape.radius),
Vector2(bigCircleShape.position.x, -bigCircleShape.radius),
Vector2(smallCircleShape.position.x, -smallCircleShape.radius),
];
final trapezium = PolygonShape()..set(trapeziumVertices);
final trapeziumFixtureDef = FixtureDef(trapezium)
..density = 50.0 // TODO(alestiago): Use a proper density.
..friction = .1; // TODO(alestiago): Use a proper friction.
feat: crossing upper ramps (#40) * feat: added generic area and area callback for ramps crossing * feat: added jetpack ramp (blue one) and own area, contact callback and maskbits * feat: added sparky ramp (yellow one) and own area, contact callback and maskbits * feat: included ramp components * feat: added maskbits to ball for collisions * feat: added paths to pinball game * feat: added maskbits to paths * fix: fixed collisions of a ball that only touch path entrance but doesn't get into * fix: analysis warnings * feat: ball default maskbits * chore: refactor some names and vars * test: tests for ramps and callbacks, and coverage * test: pinball game check ramps are added * test: tests for ramps check childrens * test: fixing tests for ramps * test: fix tests * chore: increase sparky angle * fix: placed plunge aligned with straight launcher path * fix: fixed maskBits change for ball on crossing ramps and tests coverage * doc: public member api docs * chore: placed launcher ramp * test: moved mock from crossing ramps to helpers file * fix: build and dep where broken by forge2d/position_body_component * Update lib/game/components/crossing_ramp.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update lib/game/components/jetpack_ramp.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update test/game/components/crossing_ramp_test.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update test/game/components/jetpack_ramp_test.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update test/game/components/sparky_ramp_test.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update lib/game/components/jetpack_ramp.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * chore: fixed formatting * chore: removed coverage tool * Update lib/game/components/crossing_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/ball_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update lib/game/components/crossing_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update lib/game/components/jetpack_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/crossing_ramp_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/pathway_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/pinball_game_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/pathway_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * test: fix tests and groups * chore: ramp area name changed to opening * refactor: ball with mixin Layer for mask collisions * chore: avoid foreach in a function literal * refactor: hide maskbits and manage only with layer param * chore: formatting file * refactor: changed name for ramp area * refactor: sparky+launcher into one path * doc: doc layer for ball * refactor: sparky to launcher * feat: allow jetpack ramp to be over the board * feat: refactor to allow jetpack ramp to be above board and launcher ramp * test: coverage * fix: fixed conflict with merge Component position * chore: analysis fixes * chore: doc and comments * refactor: initial position to ramps and cleaned ramp callbacks * refactor: improved ramp contact callback * refactor: ball layer and ramp addAll components * refactor: create fixtures for pathways and opening improved * refactor: placed ramps on pinball game * refactor: splitted layer from rampopening * refactor: rampopening with layered mixin * test: fixed all changes with tests * test: fixed tests after Layer mixin changes * chore: refactor names, test and doc * chore: review docs and names * fix: fixed tests and bug with initialposition collision * chore: analysis error * fix: fixed collision end from ramps * test: coverage * chore: fixed spaces between methods and other comments from pr * chore: remove unnecessary layer set on Layered * fix: removed unrelated files from pr * chore: removed unused import * refactor: ballsInside private and removed from tests * chore: todo comment * chore: removed unused import * chore: removed podfile * doc: changed Layered doc * doc: changed Layered doc * Update test/game/components/ramp_opening_test.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/game/components/layer.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: improved punctuation Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Alejandro Santiago <dev@alestiago.com>
3 years ago
fixturesDef.add(trapeziumFixtureDef);
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
feat: crossing upper ramps (#40) * feat: added generic area and area callback for ramps crossing * feat: added jetpack ramp (blue one) and own area, contact callback and maskbits * feat: added sparky ramp (yellow one) and own area, contact callback and maskbits * feat: included ramp components * feat: added maskbits to ball for collisions * feat: added paths to pinball game * feat: added maskbits to paths * fix: fixed collisions of a ball that only touch path entrance but doesn't get into * fix: analysis warnings * feat: ball default maskbits * chore: refactor some names and vars * test: tests for ramps and callbacks, and coverage * test: pinball game check ramps are added * test: tests for ramps check childrens * test: fixing tests for ramps * test: fix tests * chore: increase sparky angle * fix: placed plunge aligned with straight launcher path * fix: fixed maskBits change for ball on crossing ramps and tests coverage * doc: public member api docs * chore: placed launcher ramp * test: moved mock from crossing ramps to helpers file * fix: build and dep where broken by forge2d/position_body_component * Update lib/game/components/crossing_ramp.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update lib/game/components/jetpack_ramp.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update test/game/components/crossing_ramp_test.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update test/game/components/jetpack_ramp_test.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update test/game/components/sparky_ramp_test.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update lib/game/components/jetpack_ramp.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * chore: fixed formatting * chore: removed coverage tool * Update lib/game/components/crossing_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/ball_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update lib/game/components/crossing_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update lib/game/components/jetpack_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/crossing_ramp_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/pathway_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/pinball_game_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * Update test/game/components/pathway_test.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * test: fix tests and groups * chore: ramp area name changed to opening * refactor: ball with mixin Layer for mask collisions * chore: avoid foreach in a function literal * refactor: hide maskbits and manage only with layer param * chore: formatting file * refactor: changed name for ramp area * refactor: sparky+launcher into one path * doc: doc layer for ball * refactor: sparky to launcher * feat: allow jetpack ramp to be over the board * feat: refactor to allow jetpack ramp to be above board and launcher ramp * test: coverage * fix: fixed conflict with merge Component position * chore: analysis fixes * chore: doc and comments * refactor: initial position to ramps and cleaned ramp callbacks * refactor: improved ramp contact callback * refactor: ball layer and ramp addAll components * refactor: create fixtures for pathways and opening improved * refactor: placed ramps on pinball game * refactor: splitted layer from rampopening * refactor: rampopening with layered mixin * test: fixed all changes with tests * test: fixed tests after Layer mixin changes * chore: refactor names, test and doc * chore: review docs and names * fix: fixed tests and bug with initialposition collision * chore: analysis error * fix: fixed collision end from ramps * test: coverage * chore: fixed spaces between methods and other comments from pr * chore: remove unnecessary layer set on Layered * fix: removed unrelated files from pr * chore: removed unused import * refactor: ballsInside private and removed from tests * chore: todo comment * chore: removed unused import * chore: removed podfile * doc: changed Layered doc * doc: changed Layered doc * Update test/game/components/ramp_opening_test.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/game/components/layer.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * docs: improved punctuation Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Alejandro Santiago <dev@alestiago.com>
3 years ago
return fixturesDef;
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
}
feat: implemented Flipper grouping (#32) * feat: started implementing FlipperGroup * refactor: simplified Flipper logic * refactor: used extension instead of condition * docs: used "loads" over "adds" * feat: used size rather than width and height * refactor: removed unecessary mixin * feat: reorder methods * refactor: removed _joint over joint * docs: fixed macro typo * feat: unawait add operation * feat: included tests * 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: adding bonus logic to the game bloc (#24) * feat: adding bonus logic to the game bloc * feat: PR suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions * chore: main rebase * feat: pr suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestion * feat: pr suggestions * feat: pr suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: add plunger to board (#25) * feat: add plunger to board * refactor: leave spawn ball synchronous * fix: ball test * refactor: position ball internally * fix: ball position test * refactor: use joint specific anchor * refactor: remove ballSize * fix: plunger position * refactor: use relative positioning Co-authored-by: Alejandro Santiago <dev@alestiago.com> * refactor: added missing white space Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: adding missing white space Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: renamed test * refactor: used ! instead of ? * chore: rebasing * refactor: simplified Flipper logic * refactor: used extension instead of condition * docs: used "loads" over "adds" * feat: used size rather than width and height * refactor: removed unecessary mixin * feat: reorder methods * refactor: removed _joint over joint * docs: fixed macro typo * chore: rebasing * refactor: added missing white space * refactor: used ! instead of ? Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Erick <erickzanardoo@gmail.com>
3 years ago
@override
Future<void> onLoad() async {
await super.onLoad();
paint = Paint()..color = Colors.transparent;
feat: implemented Flipper grouping (#32) * feat: started implementing FlipperGroup * refactor: simplified Flipper logic * refactor: used extension instead of condition * docs: used "loads" over "adds" * feat: used size rather than width and height * refactor: removed unecessary mixin * feat: reorder methods * refactor: removed _joint over joint * docs: fixed macro typo * feat: unawait add operation * feat: included tests * 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: adding bonus logic to the game bloc (#24) * feat: adding bonus logic to the game bloc * feat: PR suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions * chore: main rebase * feat: pr suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestion * feat: pr suggestions * feat: pr suggestions * Apply suggestions from code review Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: add plunger to board (#25) * feat: add plunger to board * refactor: leave spawn ball synchronous * fix: ball test * refactor: position ball internally * fix: ball position test * refactor: use joint specific anchor * refactor: remove ballSize * fix: plunger position * refactor: use relative positioning Co-authored-by: Alejandro Santiago <dev@alestiago.com> * refactor: added missing white space Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: adding missing white space Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: renamed test * refactor: used ! instead of ? * chore: rebasing * refactor: simplified Flipper logic * refactor: used extension instead of condition * docs: used "loads" over "adds" * feat: used size rather than width and height * refactor: removed unecessary mixin * feat: reorder methods * refactor: removed _joint over joint * docs: fixed macro typo * chore: rebasing * refactor: added missing white space * refactor: used ! instead of ? Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Erick <erickzanardoo@gmail.com>
3 years ago
await Future.wait([
_loadSprite(),
_anchorToJoint(),
]);
}
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
@override
Body createBody() {
final bodyDef = BodyDef()
..position = initialPosition
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
..gravityScale = 0
..type = BodyType.dynamic;
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
final body = world.createBody(bodyDef);
_createFixtureDefs().forEach(body.createFixture);
return body;
}
@override
bool onKeyEvent(
RawKeyEvent event,
Set<LogicalKeyboardKey> keysPressed,
) {
if (!_keys.contains(event.logicalKey)) return true;
if (event is RawKeyDownEvent) {
_moveUp();
} else if (event is RawKeyUpEvent) {
_moveDown();
}
return false;
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
}
}
/// {@template flipper_anchor}
/// [JointAnchor] positioned at the end of a [Flipper].
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
///
/// The end of a [Flipper] depends on its [Flipper.side].
/// {@endtemplate}
class FlipperAnchor extends JointAnchor {
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
/// {@macro flipper_anchor}
FlipperAnchor({
required Flipper flipper,
}) {
initialPosition = Vector2(
flipper.side.isLeft
? flipper.body.position.x - Flipper.width / 2
: flipper.body.position.x + Flipper.width / 2,
flipper.body.position.y,
);
}
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
}
/// {@template flipper_anchor_revolute_joint_def}
/// Hinges one end of [Flipper] to a [FlipperAnchor] to achieve an arc motion.
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
/// {@endtemplate}
class FlipperAnchorRevoluteJointDef extends RevoluteJointDef {
/// {@macro flipper_anchor_revolute_joint_def}
FlipperAnchorRevoluteJointDef({
required Flipper flipper,
required FlipperAnchor anchor,
feat: Flipper (#15) * feat: explicitely imported Anchor * feat: implemented Flipper * feat: implemented Flipper in PinballGame * feat: implemented calculateRequiredSpeed * feat: included right and left constructors * feat: used right and left constructors * refactor: cleaned calcualteSpeed method * refactor: used width and height instead of size * feat: implemented FlipperAnchor * feat: implemented BoardSide enum * docs: used prose in doc comment * feat: implemented BoardSideX * refactor: used isLeft instead of isRight * refactor: implemented unlock method * refactor: same line assignment Co-authored-by: Erick <erickzanardoo@gmail.com> * feat: add themes * feat: add theme cubit * test: character themes * test: remove grouping * refactor: move themes to package * chore: add workflow * fix: workflow * docs: character themes update * refactor: one theme for entire game * chore: add to props * fix: changing ball spawning point to avoid context errors * refactor: modified unlock method due to invalid cast * feat: included test for BoardSide * refactor: removed sweepingAnimationDuration * feat: tested flipper.dart * refactor: included flippersPosition * refactor: implemented _addFlippers method * feat: centered vertices * feat: modified test to match new center * refactor: removed unecessary parenthesis * refactor: removed unecessary calculation * fix: changing ball spawning point to avoid context errors * chore: rebasing * docs: included FIXME comment * feat: moved key listening to Flipper * docs: include TOOD comment * feat: including test and refactor * docs: fixed doc comment typo Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed do comment template name Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: removed unnecessary verbose multiplication * refactor: used ensureAddAll instead of ensureAdd Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * docs: fixed doc comment typo * refactor: used bigCircleShape.radius * refactor: reorganized methods * docs: improved doc comment * refactor: removed unecessary class variables * docs: fix doc comment typo * refactor: removed unused helper * fix: simplified keyEvents * fix: corrected erroneous key tests * refactor: modified component tests * refactor: capitalized Flipper test description * refactor: changed angle calculations * fix: tests * refactor: removed exta line Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Allison Ryan <allisonryan0002@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
}) {
initialize(
flipper.body,
anchor.body,
anchor.body.position,
);
enableLimit = true;
final angle = (flipper.side.isLeft ? _sweepingAngle : -_sweepingAngle) / 2;
lowerAngle = upperAngle = angle;
}
/// The total angle of the arc motion.
static const _sweepingAngle = math.pi / 3.5;
/// Unlocks the [Flipper] from its resting position.
///
/// The [Flipper] is locked when initialized in order to force it to be at
/// its resting position.
// TODO(alestiago): consider refactor once the issue is solved:
// https://github.com/flame-engine/forge2d/issues/36
static void unlock(RevoluteJoint joint, BoardSide side) {
late final double upperLimit, lowerLimit;
switch (side) {
case BoardSide.left:
lowerLimit = -joint.lowerLimit;
upperLimit = joint.upperLimit;
break;
case BoardSide.right:
lowerLimit = joint.lowerLimit;
upperLimit = -joint.upperLimit;
}
joint.setLimits(lowerLimit, upperLimit);
}
}