diff --git a/lib/pages/mini-games/up/down.dart b/lib/pages/mini-games/up/down.dart index 524a381..e050e65 100644 --- a/lib/pages/mini-games/up/down.dart +++ b/lib/pages/mini-games/up/down.dart @@ -228,8 +228,8 @@ class DownGame extends Forge2DGame with TapDetector { scoreText = TextComponent( text: 'Score: 000', - anchor: Anchor.topRight, - position: Vector2(3.7, 0.65), + anchor: Anchor.center, + position: Vector2(worldSize.x / 2, 1), textRenderer: btnStyleLetters, ); @@ -265,6 +265,7 @@ class GameWidgetDown extends StatefulWidget { class _GameWidgetDownState extends State { DownGame game = DownGame((String data) {}); bool loading = true; + bool paused = false; @override void initState() { @@ -290,24 +291,35 @@ class _GameWidgetDownState extends State { GoRouter.of(context).pop(); }, ), + actions: [ + IconButton( + iconSize: 42, + icon: Icon(paused ? Icons.play_circle : Icons.pause_circle), + onPressed: () { + setState(() { + game.paused = !game.paused; + paused = !paused; + }); + }, + ) + ], ), body: Container( - height: MediaQuery.of(context).size.height, - width: MediaQuery.of(context).size.width, - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/up/maps/01/up_map_1.jpeg"), - fit: BoxFit.cover, + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/up/maps/01/up_map_1.jpeg"), + fit: BoxFit.cover, + ), ), - ), - child: loading - ? const Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : GameWidget(game: game), - ), + child: loading + ? const Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : GameWidget(game: game)), ); } @@ -336,6 +348,12 @@ class _GameWidgetDownState extends State { setState(() { loading = false; game = DownGame(showEndMessage); + game.paused = true; + + Future.delayed(const Duration(seconds: 1), () { + game.paused = false; + paused = false; + }); }); }, child: const Text("Let's go!"), @@ -346,6 +364,8 @@ class _GameWidgetDownState extends State { } showEndMessage(String score) { + game.paused = true; + showDialog( barrierDismissible: false, context: context, @@ -419,9 +439,9 @@ class _GameWidgetDownState extends State { TextButton( onPressed: () { Navigator.pop(context); - Navigator.pop(context); + showWelcome(); }, - child: const Text("Go to minigames"), + child: const Text("Play again"), ), ], ), diff --git a/lib/pages/mini-games/up/objects/box.dart b/lib/pages/mini-games/up/objects/box.dart index cbdd283..663356a 100644 --- a/lib/pages/mini-games/up/objects/box.dart +++ b/lib/pages/mini-games/up/objects/box.dart @@ -38,12 +38,14 @@ class Box extends BodyComponent with ContactCallbacks { @override Body createBody() { final rnd = Random(); - final xpos = (rnd.nextDouble() * (worldSize.x - 1)).abs(); - print('xpos: ${xpos}'); + final xpos = (rnd.nextDouble() * (worldSize.x - 0.5)).abs(); final bodyDef = BodyDef( userData: this, - //position: Vector2(worldSize.x / 2, worldSize.y - 3), change dino position later - position: Vector2(xpos, -1), + position: Vector2( + xpos > 0.6 + ? (xpos < (worldSize.x - 0.5) ? (xpos) : worldSize.x - 0.5) + : 0.6, + -1), type: BodyType.dynamic, gravityOverride: Vector2(0, rnd.nextDouble() * 3 + 2), ); diff --git a/lib/pages/mini-games/up/objects/dino.dart b/lib/pages/mini-games/up/objects/dino.dart index 2fe02c7..d9ded8c 100644 --- a/lib/pages/mini-games/up/objects/dino.dart +++ b/lib/pages/mini-games/up/objects/dino.dart @@ -284,7 +284,7 @@ class Dino extends BodyComponent with KeyboardHandler { final bodyDef = BodyDef( userData: this, //position: Vector2(worldSize.x / 2, worldSize.y - 3), change dino position later - position: Vector2(2, 3), + position: Vector2(2, 3.5), type: BodyType.dynamic, ); diff --git a/pubspec.yaml b/pubspec.yaml index 33c60ab..d666755 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: dinogrow description: 2D blockchain game about growing dinosaurs. -version: 1.0.1+4 +version: 1.0.2+5 environment: sdk: ">=3.0.2 <4.0.0"