Skip to content

Commit

Permalink
Merge pull request #10 from sistemaseltigre/fix/improve-minigame
Browse files Browse the repository at this point in the history
Improve mini game
  • Loading branch information
dnielopez authored Oct 17, 2023
2 parents d184e23 + d8dd955 commit ab918f4
Show file tree
Hide file tree
Showing 24 changed files with 43 additions and 13 deletions.
Binary file modified assets/images/up/green/idle/Idle_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/idle/Idle_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/idle/Idle_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/idle/Idle_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/idle/Idle_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/idle/Idle_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/idle/Idle_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/idle/Idle_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/idle/Idle_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/idle/Idle_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/walk/Walk_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/walk/Walk_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/walk/Walk_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/walk/Walk_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/walk/Walk_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/walk/Walk_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/walk/Walk_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/walk/Walk_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/walk/Walk_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/up/green/walk/Walk_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 40 additions & 10 deletions lib/pages/mini-games/up/down.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ import 'package:solana/anchor.dart' as solana_anchor;
import 'package:solana/encoder.dart' as solana_encoder;
import 'package:solana_common/utils/buffer.dart' as solana_buffer;

final screenSize = Vector2(720, 1280);

// Scaled viewport size
final worldSize = Vector2(7.2, 12.8);

class DownGame extends Forge2DGame with TapDetector {
final void Function(String) endGameCallback;

// setup the game camera to match the device size
DownGame(this.endGameCallback) : super(zoom: 100, gravity: Vector2(0, 15));

Expand Down Expand Up @@ -138,10 +134,15 @@ class DownGame extends Forge2DGame with TapDetector {

@override
Future<void> onLoad() async {
final screenSize = Vector2(size.x, size.y);

// Scaled viewport size
final worldSize = Vector2(7.2, 12.8);

await super.onLoad();

final camera =
CameraComponent.withFixedResolution(width: 720, height: 1280);
CameraComponent.withFixedResolution(width: size.x, height: size.y);
final background = _Background(size: screenSize);
camera.viewport.add(background);
if (dino.isLoaded) {
Expand Down Expand Up @@ -286,6 +287,7 @@ class _GameWidgetDownState extends State<GameWidgetDown> {
),
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"),
Expand Down Expand Up @@ -313,7 +315,7 @@ class _GameWidgetDownState extends State<GameWidgetDown> {
builder: (BuildContext context) => AlertDialog(
title: const Text('Welcome to Down'),
content: const Text(
"The aim of this minigame is avoid all boxes that come from up, while you avoid more boxes you will have great score, good luck and ... \n\n¡Watch out with the boxes! \n\nREMEMBER: you could save your score on the blockchain but you'll need at least 0.5 SOL in your wallet balance"),
"The goal for this minigame is to avoid the boxes coming from above. The more boxes you avoid, the greater your score!\n\nWatch out for the boxes! \n\nREMEMBER: You can save your score on the blockchain but you'll need at least 0.5 SOL in your wallet balance"),
actions: <Widget>[
TextButton(
onPressed: () {
Expand Down Expand Up @@ -342,9 +344,9 @@ class _GameWidgetDownState extends State<GameWidgetDown> {
barrierDismissible: false,
context: context,
builder: (BuildContext context) => AlertDialog(
title: const Text('Ups ... game ended :('),
title: const Text('Oops ... game over :('),
content: Text(
"Thanks for play! Congrats you score was: $score \n\nDo you want to save and share it in Ranking? Remember this has a cost so you must have at least 0.5 SOL in your wallet balance."),
"Thanks for playing! Congrats you score was: $score \n\nDo you want to save and share it in Ranking? Remember this has a cost so you must have at least 0.5 SOL in your wallet balance."),
actions: <Widget>[
TextButton(
onPressed: () {
Expand All @@ -356,7 +358,7 @@ class _GameWidgetDownState extends State<GameWidgetDown> {
TextButton(
onPressed: () {
Navigator.pop(context);
saveScore(int.parse(score));
showConfirmSendMessage(int.parse(score));
},
child: const Text("Send my score"),
),
Expand All @@ -365,6 +367,34 @@ class _GameWidgetDownState extends State<GameWidgetDown> {
);
}

showConfirmSendMessage(int score) {
showDialog<String>(
barrierDismissible: false,
context: context,
builder: (BuildContext context) => AlertDialog(
title: const Text('Rewrite your score'),
content: const Text(
"Are you sure rewrite your last score with this new one?\n\nCAUTION: You can't reverse this transaction and you'll lost your before score."),
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.pop(context);
showWelcome();
},
child: const Text('Play again'),
),
TextButton(
onPressed: () {
Navigator.pop(context);
saveScore(score);
},
child: const Text("Confirm"),
),
],
),
);
}

showrResultMessage(String transaction) {
showDialog<String>(
barrierDismissible: false,
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/mini-games/up/objects/dino.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enum DinoState {
}

class Dino extends BodyComponent with KeyboardHandler {
final _size = Vector2(1.70, 2.4);
final _size = Vector2(1.2, 2.4);
// componentPosition is the position of the dino in the screen
final _componentPosition = Vector2(0, 0);
DinoState state = DinoState.idle;
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/ranking/ranking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class _RankingScreenState extends State<RankingScreen> {
),
),
title: Text(
'${item.dinoPubkey.substring(0, 5)}...${item.dinoPubkey.substring(item.dinoPubkey.length - 5, item.dinoPubkey.length)}',
'${item.playerPubkey.substring(0, 5)}...${item.playerPubkey.substring(item.playerPubkey.length - 5, item.playerPubkey.length)}',
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black)),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dinogrow
description: 2D blockchain game about growing dinosaurs.
version: 1.0.0+3
version: 1.0.1+4

environment:
sdk: ">=3.0.2 <4.0.0"
Expand Down

0 comments on commit ab918f4

Please sign in to comment.