Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
feat: leap and tiled configs for better perfomance (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzanardo authored Nov 15, 2023
1 parent a4087da commit cfa61b4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
12 changes: 10 additions & 2 deletions lib/game/dash_run_game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ bool _tsxPackingFilter(Tileset tileset) {
return !(tileset.source ?? '').startsWith('anim');
}

Paint _layerPaintFactory(double opacity) {
return Paint()
..color = Color.fromRGBO(255, 255, 255, opacity)
..isAntiAlias = false;
}

class DashRunGame extends LeapGame
with TapDetector, HasKeyboardHandlerComponents {
DashRunGame({
Expand All @@ -33,6 +39,8 @@ class DashRunGame extends LeapGame
atlasMaxX: 4048,
atlasMaxY: 4048,
tsxPackingFilter: _tsxPackingFilter,
useAtlas: !kIsWeb,
layerPaintFactory: _layerPaintFactory,
),
),
);
Expand Down Expand Up @@ -302,12 +310,12 @@ class DashRunGame extends LeapGame
}

@override
void onMapUnload() {
void onMapUnload(LeapMap map) {
player?.velocity.setZero();
}

@override
void onMapLoaded() {
void onMapLoaded(LeapMap map) {
player?.loadSpawnPoint();
player?.loadRespawnPoints();
player?.walking = true;
Expand Down
11 changes: 3 additions & 8 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,23 @@ dependencies:

dev_dependencies:
bloc_test: ^9.1.2
flame_test: ^1.13.2
flame_test: ^1.14.0
flutter_launcher_icons: ^0.13.1
flutter_test:
sdk: flutter
mocktail: ^1.0.0
very_good_analysis: ^5.0.0

dependency_overrides:
flame_test:
git:
url: https://github.com/flame-engine/flame.git
ref: main
path: packages/flame_test
flame_tiled:
git:
url: https://github.com/flame-engine/flame.git
ref: main
path: packages/flame_tiled
leap:
git:
url: https://github.com/VeryGoodOpenSource/leap.git
ref: feat/map-transition-ground-improv
url: https://github.com/kurtome/leap.git
ref: feat/tiled-options-use-atlas
path: packages/leap

flutter:
Expand Down
6 changes: 3 additions & 3 deletions test/game/behaviors/follow_path_behavior_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void main() {
_TestGame.new,
(game) async {
final pathxp = Pathxp('{L, R}');
final parent = LeapMapGroundTile(Tile(localId: 0), 0, 0, 0);
final parent = LeapMapGroundTile(Tile(localId: 0), 0, 0);
final behavior = FollowPathBehavior(pathxp);

await game.ensureAdd(parent);
Expand All @@ -45,7 +45,7 @@ void main() {
_TestGame.new,
(game) async {
final pathxp = Pathxp('{2L, R}');
final parent = LeapMapGroundTile(Tile(localId: 0), 0, 0, 0);
final parent = LeapMapGroundTile(Tile(localId: 0), 0, 0);
final behavior = FollowPathBehavior(pathxp);

await game.ensureAdd(parent);
Expand All @@ -69,7 +69,7 @@ void main() {
_TestGame.new,
(game) async {
final pathxp = Pathxp('{L, R}');
final parent = LeapMapGroundTile(Tile(localId: 0), 0, 0, 0);
final parent = LeapMapGroundTile(Tile(localId: 0), 0, 0);
final behavior = FollowPathBehavior(pathxp);

await game.ensureAdd(parent);
Expand Down
3 changes: 1 addition & 2 deletions test/game/entities/player_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class _TestDashRunGame extends DashRunGame {
AssetBundle? bundle,
Images? images,
Map<String, TiledObjectHandler> tiledObjectHandlers = const {},
LeapMapTransition Function(LeapGame p1) mapTransitionFactory =
LeapMapTransition.defaultFactory,
LeapMapTransition? transitionComponent,
}) async {
// noop
}
Expand Down

0 comments on commit cfa61b4

Please sign in to comment.