diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 861acea..f497c65 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -3,165 +3,165 @@ "packages": [ { "name": "async", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/async-2.13.0", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/async-2.13.0", "packageUri": "lib/", "languageVersion": "3.4" }, { "name": "boolean_selector", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/boolean_selector-2.1.2", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/boolean_selector-2.1.2", "packageUri": "lib/", "languageVersion": "3.1" }, { "name": "characters", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/characters-1.4.0", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/characters-1.4.0", "packageUri": "lib/", "languageVersion": "3.4" }, { "name": "clock", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/clock-1.1.2", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/clock-1.1.2", "packageUri": "lib/", "languageVersion": "3.4" }, { "name": "collection", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/collection-1.19.1", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/collection-1.19.1", "packageUri": "lib/", "languageVersion": "3.4" }, { "name": "cupertino_icons", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/cupertino_icons-1.0.8", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/cupertino_icons-1.0.8", "packageUri": "lib/", "languageVersion": "3.1" }, { "name": "fake_async", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/fake_async-1.3.3", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/fake_async-1.3.3", "packageUri": "lib/", "languageVersion": "3.3" }, { "name": "flutter", - "rootUri": "file:///home/ashu/app%20development/flutter/packages/flutter", + "rootUri": "file:///home/biraj01/flutter/packages/flutter", "packageUri": "lib/", - "languageVersion": "3.7" + "languageVersion": "3.8" }, { "name": "flutter_lints", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/flutter_lints-5.0.0", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/flutter_lints-5.0.0", "packageUri": "lib/", "languageVersion": "3.5" }, { "name": "flutter_test", - "rootUri": "file:///home/ashu/app%20development/flutter/packages/flutter_test", + "rootUri": "file:///home/biraj01/flutter/packages/flutter_test", "packageUri": "lib/", - "languageVersion": "3.7" + "languageVersion": "3.8" }, { "name": "leak_tracker", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/leak_tracker-10.0.9", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/leak_tracker-11.0.2", "packageUri": "lib/", "languageVersion": "3.2" }, { "name": "leak_tracker_flutter_testing", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/leak_tracker_flutter_testing-3.0.9", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/leak_tracker_flutter_testing-3.0.10", "packageUri": "lib/", "languageVersion": "3.2" }, { "name": "leak_tracker_testing", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/leak_tracker_testing-3.0.1", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/leak_tracker_testing-3.0.2", "packageUri": "lib/", "languageVersion": "3.2" }, { "name": "lints", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/lints-5.1.1", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/lints-5.1.1", "packageUri": "lib/", "languageVersion": "3.6" }, { "name": "matcher", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/matcher-0.12.17", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/matcher-0.12.17", "packageUri": "lib/", "languageVersion": "3.4" }, { "name": "material_color_utilities", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/material_color_utilities-0.11.1", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/material_color_utilities-0.11.1", "packageUri": "lib/", "languageVersion": "2.17" }, { "name": "meta", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/meta-1.16.0", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/meta-1.16.0", "packageUri": "lib/", "languageVersion": "2.12" }, { "name": "path", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/path-1.9.1", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/path-1.9.1", "packageUri": "lib/", "languageVersion": "3.4" }, { "name": "sky_engine", - "rootUri": "file:///home/ashu/app%20development/flutter/bin/cache/pkg/sky_engine", + "rootUri": "file:///home/biraj01/flutter/bin/cache/pkg/sky_engine", "packageUri": "lib/", - "languageVersion": "3.7" + "languageVersion": "3.8" }, { "name": "source_span", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/source_span-1.10.1", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/source_span-1.10.1", "packageUri": "lib/", "languageVersion": "3.1" }, { "name": "stack_trace", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/stack_trace-1.12.1", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/stack_trace-1.12.1", "packageUri": "lib/", "languageVersion": "3.4" }, { "name": "stream_channel", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/stream_channel-2.1.4", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/stream_channel-2.1.4", "packageUri": "lib/", "languageVersion": "3.3" }, { "name": "string_scanner", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/string_scanner-1.4.1", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/string_scanner-1.4.1", "packageUri": "lib/", "languageVersion": "3.1" }, { "name": "term_glyph", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/term_glyph-1.2.2", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/term_glyph-1.2.2", "packageUri": "lib/", "languageVersion": "3.1" }, { "name": "test_api", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/test_api-0.7.4", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/test_api-0.7.6", "packageUri": "lib/", "languageVersion": "3.5" }, { "name": "vector_math", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/vector_math-2.1.4", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/vector_math-2.2.0", "packageUri": "lib/", - "languageVersion": "2.14" + "languageVersion": "3.1" }, { "name": "vm_service", - "rootUri": "file:///home/ashu/.pub-cache/hosted/pub.dev/vm_service-15.0.0", + "rootUri": "file:///home/biraj01/.pub-cache/hosted/pub.dev/vm_service-15.0.2", "packageUri": "lib/", - "languageVersion": "3.3" + "languageVersion": "3.5" }, { "name": "flappy_bird", @@ -171,8 +171,8 @@ } ], "generator": "pub", - "generatorVersion": "3.8.1", - "flutterRoot": "file:///home/ashu/app%20development/flutter", - "flutterVersion": "3.32.7", - "pubCache": "file:///home/ashu/.pub-cache" + "generatorVersion": "3.9.2", + "flutterRoot": "file:///home/biraj01/flutter", + "flutterVersion": "3.35.6", + "pubCache": "file:///home/biraj01/.pub-cache" } diff --git a/.dart_tool/package_graph.json b/.dart_tool/package_graph.json index 0a2f9ea..4fc973a 100644 --- a/.dart_tool/package_graph.json +++ b/.dart_tool/package_graph.json @@ -26,28 +26,18 @@ "name": "flutter_test", "version": "0.0.0", "dependencies": [ - "async", - "boolean_selector", - "characters", "clock", "collection", "fake_async", "flutter", - "leak_tracker", "leak_tracker_flutter_testing", - "leak_tracker_testing", "matcher", - "material_color_utilities", "meta", "path", - "source_span", "stack_trace", "stream_channel", - "string_scanner", - "term_glyph", "test_api", - "vector_math", - "vm_service" + "vector_math" ] }, { @@ -72,23 +62,6 @@ "version": "5.1.1", "dependencies": [] }, - { - "name": "vm_service", - "version": "15.0.0", - "dependencies": [] - }, - { - "name": "term_glyph", - "version": "1.2.2", - "dependencies": [] - }, - { - "name": "string_scanner", - "version": "1.4.1", - "dependencies": [ - "source_span" - ] - }, { "name": "stream_channel", "version": "2.1.4", @@ -96,76 +69,19 @@ "async" ] }, - { - "name": "source_span", - "version": "1.10.1", - "dependencies": [ - "collection", - "path", - "term_glyph" - ] - }, { "name": "meta", "version": "1.16.0", "dependencies": [] }, - { - "name": "material_color_utilities", - "version": "0.11.1", - "dependencies": [ - "collection" - ] - }, - { - "name": "leak_tracker_testing", - "version": "3.0.1", - "dependencies": [ - "leak_tracker", - "matcher", - "meta" - ] - }, - { - "name": "leak_tracker", - "version": "10.0.9", - "dependencies": [ - "clock", - "collection", - "meta", - "path", - "vm_service" - ] - }, { "name": "collection", "version": "1.19.1", "dependencies": [] }, - { - "name": "characters", - "version": "1.4.0", - "dependencies": [] - }, - { - "name": "boolean_selector", - "version": "2.1.2", - "dependencies": [ - "source_span", - "string_scanner" - ] - }, - { - "name": "async", - "version": "2.13.0", - "dependencies": [ - "collection", - "meta" - ] - }, { "name": "leak_tracker_flutter_testing", - "version": "3.0.9", + "version": "3.0.10", "dependencies": [ "flutter", "leak_tracker", @@ -176,7 +92,7 @@ }, { "name": "vector_math", - "version": "2.1.4", + "version": "2.2.0", "dependencies": [] }, { @@ -217,7 +133,7 @@ }, { "name": "test_api", - "version": "0.7.4", + "version": "0.7.6", "dependencies": [ "async", "boolean_selector", @@ -234,6 +150,80 @@ "name": "sky_engine", "version": "0.0.0", "dependencies": [] + }, + { + "name": "material_color_utilities", + "version": "0.11.1", + "dependencies": [ + "collection" + ] + }, + { + "name": "characters", + "version": "1.4.0", + "dependencies": [] + }, + { + "name": "async", + "version": "2.13.0", + "dependencies": [ + "collection", + "meta" + ] + }, + { + "name": "leak_tracker_testing", + "version": "3.0.2", + "dependencies": [ + "leak_tracker", + "matcher", + "meta" + ] + }, + { + "name": "leak_tracker", + "version": "11.0.2", + "dependencies": [ + "clock", + "collection", + "meta", + "path", + "vm_service" + ] + }, + { + "name": "term_glyph", + "version": "1.2.2", + "dependencies": [] + }, + { + "name": "string_scanner", + "version": "1.4.1", + "dependencies": [ + "source_span" + ] + }, + { + "name": "source_span", + "version": "1.10.1", + "dependencies": [ + "collection", + "path", + "term_glyph" + ] + }, + { + "name": "boolean_selector", + "version": "2.1.2", + "dependencies": [ + "source_span", + "string_scanner" + ] + }, + { + "name": "vm_service", + "version": "15.0.2", + "dependencies": [] } ], "configVersion": 1 diff --git a/.dart_tool/version b/.dart_tool/version index 490717c..eb4861a 100644 --- a/.dart_tool/version +++ b/.dart_tool/version @@ -1 +1 @@ -3.32.7 \ No newline at end of file +3.35.6 \ No newline at end of file diff --git a/lib/homepage.dart b/lib/homepage.dart index 006474f..61f94d2 100644 --- a/lib/homepage.dart +++ b/lib/homepage.dart @@ -1,5 +1,4 @@ -// import 'dart:async'; - +import 'dart:async'; import 'package:flappy_bird/barriers.dart'; import 'package:flappy_bird/bird.dart'; import 'package:flutter/material.dart'; @@ -43,26 +42,63 @@ class _HomepageState extends State { } void startGame() { - // TODO: Implement the game loop logic here. - // Hint: Use a Timer to periodically update the bird's position and barriers. - // Hint: Update the bird's position using physics equations. - // Hint: Check if the bird is dead and stop the game if necessary. + setState(() { + isGameStarted = true; + time = 0; + initialPos = birdY; + }); + + const double gravity = -4.9; + const double velocity = 2.8; + + Timer.periodic(const Duration(milliseconds: 30), (timer) { + time += 0.03; + + final double displacement = gravity * time * time + velocity * time; + + setState(() { + birdY = initialPos - displacement; + barrierx1 -= 0.05; + barrierx2 -= 0.05; + + if (barrierx1 < -2) barrierx1 += 3.5; + if (barrierx2 < -2) barrierx2 += 3.5; + }); + + if (birdisDead()) { + timer.cancel(); + setState(() => isGameStarted = false); + _showDialog(); + } + }); } void resetGame() { - // TODO: Reset the game state to its initial values. - // Hint: Reset birdY, initialPos, time, and isGameStarted. + if (Navigator.canPop(context)) { + Navigator.pop(context); + } + + setState(() { + birdY = 0.0; + initialPos = birdY; + time = 0; + isGameStarted = false; + barrierx1 = 1; + barrierx2 = barrierx1 + 1.5; + }); + + startGame(); } void jump() { - // TODO: Implement the jump logic. - // Hint: Reset the time and update the initial position of the bird. + setState(() { + time = 0; + initialPos = birdY; + }); } bool birdisDead() { - // TODO: Check if the bird is out of bounds. - // Hint: Return true if birdY is greater than 1 or less than -1. - return false; // Replace this with the correct condition. + return birdY > 1 || birdY < -1; } @override diff --git a/pubspec.lock b/pubspec.lock index 63806a4..d1027d1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -79,26 +79,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" url: "https://pub.dev" source: hosted - version: "10.0.9" + version: "11.0.2" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" url: "https://pub.dev" source: hosted - version: "3.0.9" + version: "3.0.10" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.2" lints: dependency: transitive description: @@ -188,26 +188,26 @@ packages: dependency: transitive description: name: test_api - sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd + sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" url: "https://pub.dev" source: hosted - version: "0.7.4" + version: "0.7.6" vector_math: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.2.0" vm_service: dependency: transitive description: name: vm_service - sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02 + sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" url: "https://pub.dev" source: hosted - version: "15.0.0" + version: "15.0.2" sdks: - dart: ">=3.7.2 <4.0.0" + dart: ">=3.8.0-0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54"