Skip to content

Commit

Permalink
fix: Finishing touches to use v1.9.x+ world and camera and complete I…
Browse files Browse the repository at this point in the history
…ssue #2799 (#2824)

Previously, as part of Issue #2798, I fixed the Klondike Tutorial app's
step4 executable to use the Flame 1.9.x `world` and `camera` built-in
objects and described the new code in the Step 2 tutorial, where it
first appears in the discussion. However, the Step 2 and Step 3 tutorial
texts have options to execute code and those did not include the new
code. Accordingly, I have cloned the relevant code into
`app/lib/step2/klondike_game.dart` and
`app/lib/step3/klondike_game.dart`. I have also checked that there are
no `*.md` files to be updated. The `step2.md` tutorial file covers Issue
#2799 AFAICS.
  • Loading branch information
IanWadham authored Oct 18, 2023
1 parent 95197c6 commit 276d2b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
20 changes: 8 additions & 12 deletions doc/tutorials/klondike/app/lib/step2/klondike_game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,15 @@ class KlondikeGame extends FlameGame {
),
);

final world = World()
..add(stock)
..add(waste)
..addAll(foundations)
..addAll(piles);
add(world);
world.add(stock);
world.add(waste);
world.addAll(foundations);
world.addAll(piles);

final camera = CameraComponent(world: world)
..viewfinder.visibleGameSize =
Vector2(cardWidth * 7 + cardGap * 8, 4 * cardHeight + 3 * cardGap)
..viewfinder.position = Vector2(cardWidth * 3.5 + cardGap * 4, 0)
..viewfinder.anchor = Anchor.topCenter;
add(camera);
camera.viewfinder.visibleGameSize =
Vector2(cardWidth * 7 + cardGap * 8, 4 * cardHeight + 3 * cardGap);
camera.viewfinder.position = Vector2(cardWidth * 3.5 + cardGap * 4, 0);
camera.viewfinder.anchor = Anchor.topCenter;
}
}

Expand Down
20 changes: 8 additions & 12 deletions doc/tutorials/klondike/app/lib/step3/klondike_game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,15 @@ class KlondikeGame extends FlameGame {
),
);

final world = World()
..add(stock)
..add(waste)
..addAll(foundations)
..addAll(piles);
add(world);
world.add(stock);
world.add(waste);
world.addAll(foundations);
world.addAll(piles);

final camera = CameraComponent(world: world)
..viewfinder.visibleGameSize =
Vector2(cardWidth * 7 + cardGap * 8, 4 * cardHeight + 3 * cardGap)
..viewfinder.position = Vector2(cardWidth * 3.5 + cardGap * 4, 0)
..viewfinder.anchor = Anchor.topCenter;
add(camera);
camera.viewfinder.visibleGameSize =
Vector2(cardWidth * 7 + cardGap * 8, 4 * cardHeight + 3 * cardGap);
camera.viewfinder.position = Vector2(cardWidth * 3.5 + cardGap * 4, 0);
camera.viewfinder.anchor = Anchor.topCenter;

final random = Random();
for (var i = 0; i < 7; i++) {
Expand Down

0 comments on commit 276d2b7

Please sign in to comment.