8 Commits

Author SHA1 Message Date
b283b82f6c refactor: Modernize switch; use switch-expressions and no break; (#3133)
Replaces the switch cases that can be replaces with switch expressions
and removes `break;` where it isn't needed.

https://dart.dev/language/branches#switch-statements
2024-04-18 23:41:08 +02:00
63994ebcd8 fix!: Add DisplacementEvent to fix delta coordinate transformations for drag events (#2871)
This adds `DisplacementEvent` to fix delta coordinate transformations
for drag events, to be used instead of `PositionEvent`.
Drag Events now expose the start and end position, as well as the delta,
correctly transformed by the camera and zoom.
This also ensures that drag events, once starts, do not get lost if the
drag update leaves the component bounds.



* if you are using `DragUpdateEvent` events, the `devicePosition`,
`canvasPosition`, `localPosition`, and `delta` are deprecated as they
are unclear.
* use `xStartPosition` to get the position at the start of the drag
event ("from")
* use `xEndPosition` to get the position at the end of the drag event
("to")
* if you want the delta, use `localDelta`. it now already considers the
camera zoom. no need to manually account for that
* now you keep receiving drag events for the same component even if the
mouse leaves the component (breaking)

---------

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
2023-11-30 16:40:26 +01:00
212cc206b9 docs: Klondike Tutorial Step 5 (#2842)
Primarily this PR is completing Step 5 of Flame's Klondike Tutorial and removing the tbc.md file ("To be continued...").

As at the end of Step 4, the Klondike Game had no animation, other than the drag-and-drop moves to play the game. It also had no ways to detect a win, react to a win or play again without re-loading and re-running the whole app. Step 4 played the Klondike Draw 3 variation of Klondike. Step 5 introduces the easier Klondike Draw 1 variation and provides buttons to:

Choose between Draw 1 and Draw 3,

Start the game again with a new deal, or

Start again with the same deal as before.

The new code and step5.md tutorial text cover Effects and EffectControllers in some detail, with complex examples of their use. The animations include:

Returning dropped but misplaced cards to the places they came from,

Settling dropped and validly placed cards into position,

Flipping cards from Stock Pile to Waste Pile,

Turning cards over on the Tableau piles when the cards above them are moved away,

Collecting multiple cards when the game is over,

Dealing and re-dealing multiple cards,

Allowing a card to be auto-moved onTapUp() to its Foundation Pile if it is ready to go out,

Providing a display of moving cards when/if the player wins.
2023-11-24 07:27:24 +00:00
93dcb3a117 fix: HasGameReference should default to FlameGame (#2710)
It doesn't make any sense for HasGameReference to have Game as a base instead of FlameGame since the mixin is on Component and clearly in a component tree context, so this PR sets the base to be FlameGame (like HasGameRef).
2023-09-10 13:15:39 +00:00
87b8a067f3 refactor!: Move CameraComponent and events out of experimental (#2505)
This moves the CameraComponent and the new event system out of experimental since this now is the recommended way of handling things.
2023-04-19 09:55:32 +02:00
dbda37b81a refactor: Add new lint rules (#2477)
This PR adds the following lint rules to our list:

```
always_put_required_named_parameters_first
avoid_multiple_declarations_per_line
avoid_positional_boolean_parameters
avoid_returning_null_for_void
avoid_returning_this
avoid_unnecessary_containers
enable_null_safety
library_private_types_in_public_api
no_leading_underscores_for_library_prefixes
no_leading_underscores_for_local_identifiers
prefer_null_aware_method_calls
tighten_type_of_initializing_formals
unnecessary_late
use_setters_to_change_properties
```

And these rules were considered, and some changes were made according to
them as a clean-up, but in many places they didn't make sense
(`prefer_asserts_with_message` I would have included, but there were too
many places that needed to be changes):

```
collection_methods_unrelated_type
prefer_asserts_with_message
avoid_renaming_method_parameters
```
2023-04-13 19:42:00 +00:00
de630a1c3a feat: Add isDragged in DragCallbacks mixin (#2472)
Adding a isDragged state for DragCallbacks mixin. This was available in the Draggable mixin.
2023-04-07 13:39:28 +02:00
02d0b71b23 docs: Klondike tutorial, part 4 (#1740)
This PR adds step 4 for the Klondike tutorial: "Gameplay".
2022-06-27 20:31:23 +00:00