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

101 lines
2.5 KiB

// ignore_for_file: public_member_api_docs
import 'dart:async';
import 'dart:math' as math;
import 'package:flame/extensions.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_bloc/flame_bloc.dart';
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:pinball/flame/blueprint.dart';
import 'package:pinball/game/game.dart';
import 'package:pinball_theme/pinball_theme.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
class PinballGame extends Forge2DGame
with FlameBloc, HasKeyboardHandlerComponents {
PinballGame({required this.theme}) {
images.prefix = '';
}
final PinballTheme theme;
late final Plunger plunger;
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
static final boardSize = Vector2(101.6, 143.8);
static final boardBounds = Rect.fromCenter(
center: Offset.zero,
width: boardSize.x,
height: -boardSize.y,
);
static final boardPerspectiveAngle =
-math.atan(18.6 / PinballGame.boardBounds.height);
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
void onAttach() {
super.onAttach();
spawnBall();
}
@override
Future<void> onLoad() async {
_addContactCallbacks();
await _addGameBoundaries();
unawaited(add(Board()));
unawaited(_addPlunger());
unawaited(_addBonusWord());
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
unawaited(_addPaths());
unawaited(addFromBlueprint(Spaceship()));
// Fix camera on the center of the board.
camera
..followVector2(Vector2.zero())
..zoom = size.y / 16;
}
void _addContactCallbacks() {
addContactCallback(BallScorePointsCallback());
addContactCallback(BottomWallBallContactCallback());
addContactCallback(BonusLetterBallContactCallback());
}
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
Future<void> _addGameBoundaries() async {
await add(BottomWall());
createBoundaries(this).forEach(add);
}
Future<void> _addPlunger() async {
plunger = Plunger(compressionDistance: 29)
..initialPosition = boardBounds.center.toVector2() + Vector2(41.5, -49);
await add(plunger);
}
Future<void> _addBonusWord() async {
await add(
BonusWord(
position: Vector2(
boardBounds.center.dx - 3.07,
boardBounds.center.dy - 2.4,
),
),
);
}
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
Future<void> _addPaths() async {
refactor: Pathway to Shapes (#87) * refactor: removed findNested extensions (#77) * refactor: changed Pathway for Shapes * refactor: renamed pathway to shape * refactor: moved shapes to components package * fix: fixed arc radius on shapes * refactor: changed jetpack to shapes * refactor: modified jetpack ramp to use shapes and blueprint * refactor: launcher ramp * test: removed unnecessary tests for ramps * refactor: refactored baseboard with arcshapes * chore: doc refactor * test: coverage tests * refactor: refactored launcher ramp * test: tests for shapes * test: added removed ellipse tests * test: arcshape coverage * test: unnecessary tests removed * chore: params names * chore: modified doc for Layered and added one test for nested * test: changed tests names * test: not layered nested children * refactor: moved static param and made other private on ramps * Update lib/game/components/jetpack_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 lib/game/components/launcher_ramp.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * chore: renamed straight path vars * Update packages/pinball_components/lib/src/components/shapes/arc_shape.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * refactor: constructors with rotation instead of separated method * test: refactored tests * refactor: moved rotate to separate method * refactor: rotation on shapes Co-authored-by: RuiAlonso <rui.alonso@verygood.ventures> Co-authored-by: Rui Miguel Alonso <ruiskas@gmail.com> Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
3 years ago
unawaited(addFromBlueprint(Jetpack()));
unawaited(addFromBlueprint(Launcher()));
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
}
void spawnBall() {
addFromBlueprint(BallBlueprint(position: plunger.body.position));
}
}
class DebugPinballGame extends PinballGame with TapDetector {
DebugPinballGame({required PinballTheme theme}) : super(theme: theme);
@override
void onTapUp(TapUpInfo info) {
addFromBlueprint(BallBlueprint(position: info.eventPosition.game));
}
}