diff --git a/packages/trashy_road/assets/images/sprites/player__down-down.png b/packages/trashy_road/assets/images/sprites/player__down-down.png new file mode 100644 index 00000000..0df00bcc Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__down-down.png differ diff --git a/packages/trashy_road/assets/images/sprites/player__down-left.png b/packages/trashy_road/assets/images/sprites/player__down-left.png new file mode 100644 index 00000000..c3b3e2cc Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__down-left.png differ diff --git a/packages/trashy_road/assets/images/sprites/player__down-right.png b/packages/trashy_road/assets/images/sprites/player__down-right.png new file mode 100644 index 00000000..eb783c7d Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__down-right.png differ diff --git a/packages/trashy_road/assets/images/sprites/player__down-up.png b/packages/trashy_road/assets/images/sprites/player__down-up.png new file mode 100644 index 00000000..513dd92a Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__down-up.png differ diff --git a/packages/trashy_road/assets/images/sprites/player__left-down.png b/packages/trashy_road/assets/images/sprites/player__left-down.png new file mode 100644 index 00000000..f2635623 Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__left-down.png differ diff --git a/packages/trashy_road/assets/images/sprites/player__left-left.png b/packages/trashy_road/assets/images/sprites/player__left-left.png new file mode 100644 index 00000000..72bab448 Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__left-left.png differ diff --git a/packages/trashy_road/assets/images/sprites/player__left-right.png b/packages/trashy_road/assets/images/sprites/player__left-right.png new file mode 100644 index 00000000..7cfce914 Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__left-right.png differ diff --git a/packages/trashy_road/assets/images/sprites/player__left-up.png b/packages/trashy_road/assets/images/sprites/player__left-up.png new file mode 100644 index 00000000..8af028f5 Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__left-up.png differ diff --git a/packages/trashy_road/assets/images/sprites/player__right-down.png b/packages/trashy_road/assets/images/sprites/player__right-down.png new file mode 100644 index 00000000..f9731200 Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__right-down.png differ diff --git a/packages/trashy_road/assets/images/sprites/player__right-left.png b/packages/trashy_road/assets/images/sprites/player__right-left.png new file mode 100644 index 00000000..538ce1ed Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__right-left.png differ diff --git a/packages/trashy_road/assets/images/sprites/player__right-right.png b/packages/trashy_road/assets/images/sprites/player__right-right.png new file mode 100644 index 00000000..b43edb5b Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__right-right.png differ diff --git a/packages/trashy_road/assets/images/sprites/player__right-up.png b/packages/trashy_road/assets/images/sprites/player__right-up.png new file mode 100644 index 00000000..7a3ba8fd Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__right-up.png differ diff --git a/packages/trashy_road/assets/images/sprites/player__up-down.png b/packages/trashy_road/assets/images/sprites/player__up-down.png new file mode 100644 index 00000000..b94e97fe Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__up-down.png differ diff --git a/packages/trashy_road/assets/images/sprites/player__up-left.png b/packages/trashy_road/assets/images/sprites/player__up-left.png new file mode 100644 index 00000000..97037c77 Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__up-left.png differ diff --git a/packages/trashy_road/assets/images/sprites/player__up-right.png b/packages/trashy_road/assets/images/sprites/player__up-right.png new file mode 100644 index 00000000..20a082f0 Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__up-right.png differ diff --git a/packages/trashy_road/assets/images/sprites/player__up-up.png b/packages/trashy_road/assets/images/sprites/player__up-up.png new file mode 100644 index 00000000..4bab5bc9 Binary files /dev/null and b/packages/trashy_road/assets/images/sprites/player__up-up.png differ diff --git a/packages/trashy_road/assets/images/sprites/player_hop-shadow.png b/packages/trashy_road/assets/images/sprites/player_hop-shadow.png index e0c52dcc..9e508aa3 100644 Binary files a/packages/trashy_road/assets/images/sprites/player_hop-shadow.png and b/packages/trashy_road/assets/images/sprites/player_hop-shadow.png differ diff --git a/packages/trashy_road/assets/images/sprites/player_hop.png b/packages/trashy_road/assets/images/sprites/player_hop.png deleted file mode 100644 index 6a46080a..00000000 Binary files a/packages/trashy_road/assets/images/sprites/player_hop.png and /dev/null differ diff --git a/packages/trashy_road/lib/gen/assets.gen.dart b/packages/trashy_road/lib/gen/assets.gen.dart index 99c89cbc..ba38d66a 100644 --- a/packages/trashy_road/lib/gen/assets.gen.dart +++ b/packages/trashy_road/lib/gen/assets.gen.dart @@ -137,6 +137,15 @@ class $AssetsTilesGen { /// File path: assets/tiles/building_4.tx String get building4 => 'assets/tiles/building_4.tx'; + /// File path: assets/tiles/building_5.tx + String get building5 => 'assets/tiles/building_5.tx'; + + /// File path: assets/tiles/building_6.tx + String get building6 => 'assets/tiles/building_6.tx'; + + /// File path: assets/tiles/building_7.tx + String get building7 => 'assets/tiles/building_7.tx'; + /// File path: assets/tiles/bus_stop.tx String get busStop => 'assets/tiles/bus_stop.tx'; @@ -234,6 +243,9 @@ class $AssetsTilesGen { building2, building3, building4, + building5, + building6, + building7, busStop, bush1, bush2, @@ -622,6 +634,10 @@ class $AssetsImagesSpritesGen { AssetGenImage get crumpledPaper1 => const AssetGenImage('assets/images/sprites/crumpled_paper1.png'); + /// File path: assets/images/sprites/dirt--grass-south-east.png + AssetGenImage get dirtGrassSouthEast => + const AssetGenImage('assets/images/sprites/dirt--grass-south-east.png'); + /// File path: assets/images/sprites/dirt.png AssetGenImage get dirt => const AssetGenImage('assets/images/sprites/dirt.png'); @@ -734,14 +750,74 @@ class $AssetsImagesSpritesGen { AssetGenImage get plasticStraw => const AssetGenImage('assets/images/sprites/plastic_straw.png'); + /// File path: assets/images/sprites/player__down-down.png + AssetGenImage get playerDownDown => + const AssetGenImage('assets/images/sprites/player__down-down.png'); + + /// File path: assets/images/sprites/player__down-left.png + AssetGenImage get playerDownLeft => + const AssetGenImage('assets/images/sprites/player__down-left.png'); + + /// File path: assets/images/sprites/player__down-right.png + AssetGenImage get playerDownRight => + const AssetGenImage('assets/images/sprites/player__down-right.png'); + + /// File path: assets/images/sprites/player__down-up.png + AssetGenImage get playerDownUp => + const AssetGenImage('assets/images/sprites/player__down-up.png'); + + /// File path: assets/images/sprites/player__left-down.png + AssetGenImage get playerLeftDown => + const AssetGenImage('assets/images/sprites/player__left-down.png'); + + /// File path: assets/images/sprites/player__left-left.png + AssetGenImage get playerLeftLeft => + const AssetGenImage('assets/images/sprites/player__left-left.png'); + + /// File path: assets/images/sprites/player__left-right.png + AssetGenImage get playerLeftRight => + const AssetGenImage('assets/images/sprites/player__left-right.png'); + + /// File path: assets/images/sprites/player__left-up.png + AssetGenImage get playerLeftUp => + const AssetGenImage('assets/images/sprites/player__left-up.png'); + + /// File path: assets/images/sprites/player__right-down.png + AssetGenImage get playerRightDown => + const AssetGenImage('assets/images/sprites/player__right-down.png'); + + /// File path: assets/images/sprites/player__right-left.png + AssetGenImage get playerRightLeft => + const AssetGenImage('assets/images/sprites/player__right-left.png'); + + /// File path: assets/images/sprites/player__right-right.png + AssetGenImage get playerRightRight => + const AssetGenImage('assets/images/sprites/player__right-right.png'); + + /// File path: assets/images/sprites/player__right-up.png + AssetGenImage get playerRightUp => + const AssetGenImage('assets/images/sprites/player__right-up.png'); + + /// File path: assets/images/sprites/player__up-down.png + AssetGenImage get playerUpDown => + const AssetGenImage('assets/images/sprites/player__up-down.png'); + + /// File path: assets/images/sprites/player__up-left.png + AssetGenImage get playerUpLeft => + const AssetGenImage('assets/images/sprites/player__up-left.png'); + + /// File path: assets/images/sprites/player__up-right.png + AssetGenImage get playerUpRight => + const AssetGenImage('assets/images/sprites/player__up-right.png'); + + /// File path: assets/images/sprites/player__up-up.png + AssetGenImage get playerUpUp => + const AssetGenImage('assets/images/sprites/player__up-up.png'); + /// File path: assets/images/sprites/player_hop-shadow.png AssetGenImage get playerHopShadow => const AssetGenImage('assets/images/sprites/player_hop-shadow.png'); - /// File path: assets/images/sprites/player_hop.png - AssetGenImage get playerHop => - const AssetGenImage('assets/images/sprites/player_hop.png'); - /// File path: assets/images/sprites/post_box-shadow.png AssetGenImage get postBoxShadow => const AssetGenImage('assets/images/sprites/post_box-shadow.png'); @@ -871,6 +947,7 @@ class $AssetsImagesSpritesGen { crumbledPaper2, crumbledPaper3, crumpledPaper1, + dirtGrassSouthEast, dirt, fireHydrantShadow, fireHydrant, @@ -899,8 +976,23 @@ class $AssetsImagesSpritesGen { plasticBottle2, plasticStrawShadow, plasticStraw, + playerDownDown, + playerDownLeft, + playerDownRight, + playerDownUp, + playerLeftDown, + playerLeftLeft, + playerLeftRight, + playerLeftUp, + playerRightDown, + playerRightLeft, + playerRightRight, + playerRightUp, + playerUpDown, + playerUpLeft, + playerUpRight, + playerUpUp, playerHopShadow, - playerHop, postBoxShadow, postBox, road, diff --git a/packages/trashy_road/lib/src/game/entities/player/player.dart b/packages/trashy_road/lib/src/game/entities/player/player.dart index 684cf54c..935ca3c5 100644 --- a/packages/trashy_road/lib/src/game/entities/player/player.dart +++ b/packages/trashy_road/lib/src/game/entities/player/player.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:ui' as ui; import 'package:flame/collisions.dart'; import 'package:flame/components.dart'; @@ -103,47 +102,44 @@ class _PlayerSpriteComponent extends SpriteAnimationComponent _PlayerSpriteComponent() : super( position: Vector2(-0.4, -2.5)..toGameSize(), - scale: Vector2.all(0.45), + scale: Vector2.all(0.9), ); final Map> _animations = {}; - static final List> _animationDirectionOrder = - List.unmodifiable([ - [Direction.right, Direction.right], - [Direction.right, Direction.up], - [Direction.right, Direction.down], - [Direction.right, Direction.left], - [Direction.up, Direction.right], - [Direction.up, Direction.up], - [Direction.up, Direction.down], - [Direction.up, Direction.left], - [Direction.down, Direction.right], - [Direction.down, Direction.up], - [Direction.down, Direction.down], - [Direction.down, Direction.left], - [Direction.left, Direction.right], - [Direction.left, Direction.up], - [Direction.left, Direction.down], - [Direction.left, Direction.left], - ]); + static final Map<(Direction, Direction), AssetGenImage> _animationSpriteMap = + { + (Direction.right, Direction.right): Assets.images.sprites.playerRightRight, + (Direction.right, Direction.up): Assets.images.sprites.playerUpUp, + (Direction.right, Direction.down): Assets.images.sprites.playerRightDown, + (Direction.right, Direction.left): Assets.images.sprites.playerRightLeft, + (Direction.up, Direction.right): Assets.images.sprites.playerUpRight, + (Direction.up, Direction.up): Assets.images.sprites.playerUpUp, + (Direction.up, Direction.down): Assets.images.sprites.playerUpDown, + (Direction.up, Direction.left): Assets.images.sprites.playerUpLeft, + (Direction.down, Direction.right): Assets.images.sprites.playerDownRight, + (Direction.down, Direction.up): Assets.images.sprites.playerDownUp, + (Direction.down, Direction.down): Assets.images.sprites.playerDownDown, + (Direction.down, Direction.left): Assets.images.sprites.playerDownLeft, + (Direction.left, Direction.right): Assets.images.sprites.playerLeftRight, + (Direction.left, Direction.up): Assets.images.sprites.playerLeftUp, + (Direction.left, Direction.down): Assets.images.sprites.playerLeftDown, + (Direction.left, Direction.left): Assets.images.sprites.playerLeftLeft, + }; Direction _previousDirection = Direction.up; - SpriteAnimation _createAnimation(ui.Image image, int row) { + Future _createAnimation(AssetGenImage image) async { + final spriteSheet = await game.images.load(image.path); const frameCount = 7; + return SpriteAnimation.fromFrameData( - image, - SpriteAnimationData.range( - amount: frameCount * _animationDirectionOrder.length, - amountPerRow: frameCount, - textureSize: Vector2.all(512), - start: row * frameCount, - end: row * frameCount + frameCount - 1, - stepTimes: List.filled( - 7, - (PlayerMovingBehavior.moveDelay.inMilliseconds / 1000) / frameCount, - ), + spriteSheet, + SpriteAnimationData.sequenced( + amount: frameCount, + stepTime: + (PlayerMovingBehavior.moveDelay.inMilliseconds / 1000) / frameCount, + textureSize: Vector2.all(256), loop: false, ), ); @@ -153,19 +149,14 @@ class _PlayerSpriteComponent extends SpriteAnimationComponent Future onLoad() async { await super.onLoad(); - final image = await game.images.fetchOrGenerate( - Assets.images.sprites.playerHop.path, - () => game.images.load(Assets.images.sprites.playerHop.path), - ); - - for (var i = 0; i < _animationDirectionOrder.length; i++) { - final [startingDirection, endDirection] = _animationDirectionOrder[i]; + for (final entry in _animationSpriteMap.entries) { + final (startingDirection, endDirection) = entry.key; + final image = entry.value; + final spriteSheet = await _createAnimation(image); _animations[startingDirection] ??= {}; - _animations[startingDirection]![endDirection] = _createAnimation( - image, - i, - ); + _animations[startingDirection]![endDirection] = spriteSheet; } + playing = false; animation = _animations[Direction.up]![Direction.up]; } @@ -183,7 +174,7 @@ class _PlayerShadowSpriteComponent extends SpriteAnimationComponent _PlayerShadowSpriteComponent() : super( position: Vector2(-0.4, -2.5)..toGameSize(), - scale: Vector2.all(0.45), + scale: Vector2.all(1.8), ); @override @@ -202,7 +193,7 @@ class _PlayerShadowSpriteComponent extends SpriteAnimationComponent SpriteAnimationData.sequenced( amount: frameCount, amountPerRow: 3, - textureSize: Vector2.all(512), + textureSize: Vector2.all(128), stepTime: (PlayerMovingBehavior.moveDelay.inMilliseconds / 1000) / frameCount, loop: false,