Skip to content

Commit

Permalink
feat: allowing bundle and images loading customization (#12)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcos Sevilla <[email protected]>
Co-authored-by: Marcos Sevilla <[email protected]>
  • Loading branch information
3 people authored Oct 19, 2023
1 parent 7b59cdc commit f412f38
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 45 deletions.
68 changes: 38 additions & 30 deletions examples/standard_platformer/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ packages:
dependency: transitive
description:
name: archive
sha256: "20071638cbe4e5964a427cfa0e86dce55d060bc7d82d56f3554095d7239a8765"
sha256: "7e0d52067d05f2e0324268097ba723b71cb41ac8a6a2b24d1edf9c536b987b03"
url: "https://pub.dev"
source: hosted
version: "3.4.2"
version: "3.4.6"
async:
dependency: transitive
description:
Expand All @@ -21,58 +21,58 @@ packages:
dependency: transitive
description:
name: audioplayers
sha256: "8e94499b5c123df14cf17c16639de5ff3373e57e537f727e367487fbb7491363"
sha256: d9f6ca8e9b3e5af5e73d4c814404566f72698ee7ba35487bdf2baa6749e7503f
url: "https://pub.dev"
source: hosted
version: "5.1.0"
version: "5.2.0"
audioplayers_android:
dependency: transitive
description:
name: audioplayers_android
sha256: "1c12b60cc10a3b8617ca3f88b927e7e03768f470d9b4f747efd3d58a8a07ee1b"
sha256: fb01b9481f431fe04ac60f1f97ce8158383f2dc754558820592f795d81ca9d53
url: "https://pub.dev"
source: hosted
version: "4.0.1"
version: "4.0.2"
audioplayers_darwin:
dependency: transitive
description:
name: audioplayers_darwin
sha256: "2fb6133ffcf28fb3f9d3e11f8a3ef190e5fedb2b7b95ea865b56a21d1163e670"
sha256: "3034e99a6df8d101da0f5082dcca0a2a99db62ab1d4ddb3277bed3f6f81afe08"
url: "https://pub.dev"
source: hosted
version: "5.0.1"
version: "5.0.2"
audioplayers_linux:
dependency: transitive
description:
name: audioplayers_linux
sha256: cca3f272c7186dd2e0025b8864e1413ac5e081d74b17e28b02ceb2df4c110235
sha256: "60787e73fefc4d2e0b9c02c69885402177e818e4e27ef087074cf27c02246c9e"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "3.1.0"
audioplayers_platform_interface:
dependency: transitive
description:
name: audioplayers_platform_interface
sha256: "47eae55e99ced11589998cf27e4eaabf5b475a7bd8bea7516ee6c2536a2e1abf"
sha256: "365c547f1bb9e77d94dd1687903a668d8f7ac3409e48e6e6a3668a1ac2982adb"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
version: "6.1.0"
audioplayers_web:
dependency: transitive
description:
name: audioplayers_web
sha256: "9f155590c6ba9ba469df637f4729264e4234dc3941ece4690dad63ffac19b5af"
sha256: "22cd0173e54d92bd9b2c80b1204eb1eb159ece87475ab58c9788a70ec43c2a62"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
version: "4.1.0"
audioplayers_windows:
dependency: transitive
description:
name: audioplayers_windows
sha256: "8813b712ba919bb324bde5e3ba97edc81bface945953a54a3dea70b5608bcc70"
sha256: "9536812c9103563644ada2ef45ae523806b0745f7a78e89d1b5fb1951de90e1a"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "3.1.0"
characters:
dependency: transitive
description:
Expand Down Expand Up @@ -125,26 +125,26 @@ packages:
dependency: "direct main"
description:
name: flame
sha256: f1ed45b49db36f6650882900f3216516d5c2628400bad8b4e92d83c116d79b12
sha256: "042533edc7ded96c2a439b2eae1a905f2611447d0d106b33686b841371c8d8c5"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
flame_audio:
dependency: "direct main"
description:
name: flame_audio
sha256: "2b21fb18587e4591ed2523ea26f88078e9927b6f6ed0768f24a531f0ea7a1a36"
sha256: dabcbb8fba44aeff62af0d5f9e4bd716f166e4bd4d7d54f0f2e8851fac0e9e4a
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
flame_behaviors:
dependency: transitive
description:
name: flame_behaviors
sha256: "64b6fba612388401d8380af2672eaabe3093108d19319eb12ecf11d9043db5b5"
sha256: e6a7429ed5f16efe7683a63d42f18d6e2c68d6ac3ff0e17f4f62bb224fd294b8
url: "https://pub.dev"
source: hosted
version: "0.2.0"
version: "1.0.0"
flame_lint:
dependency: "direct dev"
description:
Expand All @@ -157,10 +157,10 @@ packages:
dependency: "direct main"
description:
name: flame_tiled
sha256: c3e651e9e3b9c7dae32fbe9e696076bb7532efb42bdffcb8f641e834da84be0b
sha256: "1d40c455612ed5a0b471bff5e86f06964f9be3039a8b69000359b4a27184d39e"
url: "https://pub.dev"
source: hosted
version: "1.14.1"
version: "1.15.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -294,10 +294,10 @@ packages:
dependency: transitive
description:
name: platform
sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102
sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
version: "3.1.3"
plugin_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -327,6 +327,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.10.0"
sprintf:
dependency: transitive
description:
name: sprintf
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
string_scanner:
dependency: transitive
description:
Expand Down Expand Up @@ -371,10 +379,10 @@ packages:
dependency: transitive
description:
name: uuid
sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313"
sha256: b715b8d3858b6fa9f68f87d20d98830283628014750c2b09b6f516c1da4af2a7
url: "https://pub.dev"
source: hosted
version: "3.0.7"
version: "4.1.0"
vector_math:
dependency: transitive
description:
Expand All @@ -395,10 +403,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: c97defd418eef4ec88c0d1652cdce84b9f7b63dd7198e266d06ac1710d527067
sha256: "350a11abd2d1d97e0cc7a28a81b781c08002aa2864d9e3f192ca0ffa18b06ed3"
url: "https://pub.dev"
source: hosted
version: "5.0.8"
version: "5.0.9"
xdg_directories:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions examples/standard_platformer/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies:

dev_dependencies:
flame_lint: ^1.1.1

flutter:
uses-material-design: true
assets:
Expand Down
6 changes: 2 additions & 4 deletions packages/leap/lib/src/input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ class SimpleTapInput extends PositionComponent
bool get isPressed => downEvent != null && upEvent == null;

bool get isPressedLeft {
final upEventInfo = upEvent?.asInfo(game);
if (upEventInfo != null) {
return isPressed &&
upEventInfo.eventPosition.global.x < gameRef.canvasSize.x / 2;
if (upEvent != null) {
return isPressed && upEvent!.devicePosition.x < gameRef.canvasSize.x / 2;
}
return false;
}
Expand Down
6 changes: 6 additions & 0 deletions packages/leap/lib/src/leap_game.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'dart:ui';

import 'package:flame/cache.dart';
import 'package:flame/components.dart';
import 'package:flame/game.dart';
import 'package:flutter/services.dart';
import 'package:leap/src/entities/entities.dart';
import 'package:leap/src/leap_map.dart';
import 'package:leap/src/leap_world.dart';
Expand Down Expand Up @@ -42,6 +44,8 @@ class LeapGame extends FlameGame with HasTrackedComponents {
required String tiledMapPath,
required CameraComponent camera,
String prefix = 'assets/tiles/',
AssetBundle? bundle,
Images? images,
}) async {
camera.world = world;

Expand All @@ -51,6 +55,8 @@ class LeapGame extends FlameGame with HasTrackedComponents {
tileSize: tileSize,
tiledMapPath: tiledMapPath,
prefix: prefix,
bundle: bundle,
images: images,
);

await world.add(leapMap);
Expand Down
6 changes: 6 additions & 0 deletions packages/leap/lib/src/leap_map.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:flame/cache.dart';
import 'package:flame/components.dart';
import 'package:flame_tiled/flame_tiled.dart';
import 'package:flutter/services.dart';
import 'package:leap/src/entities/entities.dart';
import 'package:leap/src/leap_game.dart';

Expand Down Expand Up @@ -77,11 +79,15 @@ class LeapMap extends PositionComponent with HasGameRef<LeapGame> {
required double tileSize,
required String tiledMapPath,
String prefix = 'assets/tiles/',
AssetBundle? bundle,
Images? images,
}) async {
final tiledMap = await TiledComponent.load(
tiledMapPath,
Vector2.all(tileSize),
prefix: prefix,
bundle: bundle,
images: images,
);
return LeapMap(
tileSize: tileSize,
Expand Down
16 changes: 8 additions & 8 deletions packages/leap/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ packages:
dependency: transitive
description:
name: archive
sha256: "20071638cbe4e5964a427cfa0e86dce55d060bc7d82d56f3554095d7239a8765"
sha256: "7e0d52067d05f2e0324268097ba723b71cb41ac8a6a2b24d1edf9c536b987b03"
url: "https://pub.dev"
source: hosted
version: "3.4.2"
version: "3.4.6"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -77,18 +77,18 @@ packages:
dependency: "direct main"
description:
name: flame
sha256: f1ed45b49db36f6650882900f3216516d5c2628400bad8b4e92d83c116d79b12
sha256: "042533edc7ded96c2a439b2eae1a905f2611447d0d106b33686b841371c8d8c5"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
flame_behaviors:
dependency: "direct main"
description:
name: flame_behaviors
sha256: "64b6fba612388401d8380af2672eaabe3093108d19319eb12ecf11d9043db5b5"
sha256: e6a7429ed5f16efe7683a63d42f18d6e2c68d6ac3ff0e17f4f62bb224fd294b8
url: "https://pub.dev"
source: hosted
version: "0.2.0"
version: "1.0.0"
flame_lint:
dependency: "direct dev"
description:
Expand All @@ -101,10 +101,10 @@ packages:
dependency: "direct main"
description:
name: flame_tiled
sha256: c3e651e9e3b9c7dae32fbe9e696076bb7532efb42bdffcb8f641e834da84be0b
sha256: "1d40c455612ed5a0b471bff5e86f06964f9be3039a8b69000359b4a27184d39e"
url: "https://pub.dev"
source: hosted
version: "1.14.1"
version: "1.15.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down
6 changes: 3 additions & 3 deletions packages/leap/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ environment:
flutter: 3.13.2

dependencies:
flame: ^1.9.1
flame_behaviors: ^0.2.0
flame_tiled: ^1.14.1
flame: ^1.10.0
flame_behaviors: ^1.0.0
flame_tiled: ^1.15.0
flutter:
sdk: flutter
tiled: ^0.10.1
Expand Down

0 comments on commit f412f38

Please sign in to comment.