Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game 2048 #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release
/ios/Runner
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.4.32'
repositories {
google()
jcenter()
Expand Down
14 changes: 10 additions & 4 deletions lib/2048Screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,17 @@ class _Game2048State extends State<Game2048Screen> with TickerProviderStateMixin

}


//Save game progress
void saveState(){
if(isGameRunning){

//save columnSize, rowSize, score and values
String saveGame = "$columnSize;$rowSize;$_score;" + values.join(',');
Provider.of<StatisticsModel>(context, listen: false).setValue(StatConst.KEY_GAME_2048, StatConst.KEY_SAVEGAME_1, saveGame);
}
//save moves done
String movesDone = Provider.of<StatisticsModel>(context, listen: false).getValue(StatConst.KEY_GAME_2048, StatConst.KEY_MOVES_PERFORMED);
//TODO update value here

int updatedMovesDone = int.parse(movesDone) + _movesPerformed;
Provider.of<StatisticsModel>(context, listen: false).setValue(StatConst.KEY_GAME_2048, StatConst.KEY_MOVES_PERFORMED, "$updatedMovesDone");
_movesPerformed = 0;
Expand Down Expand Up @@ -226,7 +227,10 @@ class _Game2048State extends State<Game2048Screen> with TickerProviderStateMixin
values = valuesAfter;
_isInAnimation = false;
});

//save current game progress
if(isGameRunning){
saveState();
}
startTimerAppearing();


Expand Down Expand Up @@ -291,6 +295,8 @@ class _Game2048State extends State<Game2048Screen> with TickerProviderStateMixin
}
}

//Update strings for final stats on the screen and game stats in the key-value store
//Delete existing savegame
void setGameOver(){
isGameRunning = false;
//save stats
Expand Down Expand Up @@ -605,7 +611,7 @@ class _Game2048State extends State<Game2048Screen> with TickerProviderStateMixin
}

void onExitPressed(){
saveState();
saveState(); //save game progress
Navigator.pop(context);
}

Expand Down
1 change: 0 additions & 1 deletion lib/ConnectFourScreen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:audioplayers/audio_cache.dart';
import 'package:audioplayers/audioplayers.dart';
import 'dart:io';
import 'dart:math';
Expand Down
95 changes: 72 additions & 23 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ packages:
source: hosted
version: "2.0.0"
async:
dependency: transitive
dependency: "direct main"
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0"
version: "2.6.1"
audioplayers:
dependency: "direct main"
description:
name: audioplayers
url: "https://pub.dartlang.org"
source: hosted
version: "0.19.1"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -70,7 +77,7 @@ packages:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
version: "1.0.3"
fake_async:
dependency: transitive
description:
Expand All @@ -84,14 +91,14 @@ packages:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.1.2"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.0"
version: "6.1.2"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -114,6 +121,20 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.3"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
image:
dependency: transitive
description:
Expand Down Expand Up @@ -163,13 +184,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
path_provider:
dependency: transitive
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.2"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
path_provider_platform_interface:
dependency: transitive
description:
Expand All @@ -183,35 +218,42 @@ packages:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.3"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.1"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.2"
version: "4.1.0"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.0.2"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.1"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.1"
version: "4.2.3"
provider:
dependency: "direct main"
description:
Expand All @@ -225,28 +267,28 @@ packages:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.0.1"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
version: "2.0.6"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.2"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.2"
shared_preferences_platform_interface:
dependency: transitive
description:
Expand All @@ -260,14 +302,14 @@ packages:
name: shared_preferences_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.1"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.2"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -279,7 +321,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -314,7 +356,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19"
version: "0.3.0"
tuple:
dependency: "direct main"
description:
Expand All @@ -329,6 +371,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
uuid:
dependency: transitive
description:
name: uuid
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.4"
vector_math:
dependency: transitive
description:
Expand All @@ -342,7 +391,7 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
version: "2.2.5"
xdg_directories:
dependency: transitive
description:
Expand All @@ -356,7 +405,7 @@ packages:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.2"
version: "5.1.2"
yaml:
dependency: transitive
description:
Expand All @@ -365,5 +414,5 @@ packages:
source: hosted
version: "3.1.0"
sdks:
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.20.0"
dart: ">=2.13.0 <3.0.0"
flutter: ">=2.0.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies:
provider: ^5.0.0
# json_annotation: ^4.0.0
shared_preferences: ^2.0.5
audioplayers: any
audioplayers: ^0.19.0
page_transition: "^1.1.7+6"
async: any

Expand Down