1- // ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, sized_box_for_whitespace, avoid_unnecessary_containers, empty_statements, unused_field
1+ // ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, sized_box_for_whitespace, avoid_unnecessary_containers, empty_statements, unused_field, avoid_print
22import 'dart:async' ;
33import 'package:flappy_bird/Ui/Bird.dart' ;
44import 'package:flappy_bird/Ui/Score.dart' ;
55import 'package:flappy_bird/Ui/barrier.dart' ;
6+ import 'package:flappy_bird/constant/constant.dart' ;
67import 'package:flutter/material.dart' ;
78
89class HomePage extends StatefulWidget {
@@ -13,16 +14,14 @@ class HomePage extends StatefulWidget {
1314}
1415
1516class _HomePageState extends State <HomePage > {
16- int score = 0 ;
1717 // Bird Variables
1818 static double yAxis = 0 ;
19- static double xAxis = 0 ;
2019 double time = 0 ;
2120 double height = 0 ;
2221 double gravity = - 3.9 ; // How strong the Gravity
2322 double velocity = 2.5 ; // How strong the jump
2423 double initialHeight = yAxis;
25- bool gameHasStarted = false ;
24+ bool gameHasStarted = false ; //TODO: Make it Global
2625 // Barrier Variables
2726 static List <double > barrierX = [2 , 3.4 ];
2827 List <List <double >> barrierY = [
@@ -60,7 +59,7 @@ class _HomePageState extends State<HomePage> {
6059 ),
6160 Expanded (
6261 flex: 1 ,
63- child: Score (score ),),
62+ child: Score (),),
6463 ]),
6564 ),
6665 );
@@ -100,15 +99,18 @@ class _HomePageState extends State<HomePage> {
10099 timer.cancel ();
101100 _showDialog ();
102101 };
103- time += 0.04 ;
102+ time += 0.032 ;
104103 });
105104 Timer .periodic (Duration (seconds: 2 ), (timer) {
106105 if (birdIsDead ()){
107106 timer.cancel ();
108- score = 0 ;
107+ SCORE = 0 ;
109108 }else {
110109 setState (() {
111- score ++ ;
110+ if (SCORE == TOP_SCORE ) {
111+ TOP_SCORE ++ ;
112+ }
113+ SCORE ++ ;
112114 });
113115 }
114116 });
@@ -125,7 +127,6 @@ class _HomePageState extends State<HomePage> {
125127 }
126128 // Barrier
127129 for (int i = 0 ; i < barrierX.length; i++ ){
128-
129130 }
130131 return false ;
131132 }
@@ -136,7 +137,7 @@ class _HomePageState extends State<HomePage> {
136137 yAxis = 0 ;
137138 gameHasStarted = false ;
138139 time = 0 ;
139- score = 0 ;
140+ SCORE = 0 ;
140141 initialHeight = yAxis;
141142 barrierX[0 ] = 2 ;
142143 barrierX[1 ] = 3.4 ;
0 commit comments