File tree 1 file changed +4
-6
lines changed
1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ var pipeBodySprite;
19
19
var pipePeakSprite ;
20
20
var bgImg ;
21
21
var bgX ;
22
- var gameisover = false ;
22
+ var gameoverFrame = 0 ;
23
23
24
24
var touched = false ;
25
25
var prevTouched = touched ;
@@ -75,7 +75,7 @@ function draw() {
75
75
bird . update ( ) ;
76
76
bird . show ( ) ;
77
77
78
- if ( frameCount % 150 = == 0 ) {
78
+ if ( ( frameCount - gameoverFrame ) % 150 == 0 ) {
79
79
pipes . push ( new Pipe ( ) ) ;
80
80
}
81
81
@@ -97,9 +97,6 @@ function draw() {
97
97
prevTouched = touched ;
98
98
99
99
100
- if ( gameisover ) {
101
- noLoop ( ) ;
102
- }
103
100
}
104
101
105
102
function showScores ( ) {
@@ -113,14 +110,15 @@ function gameover() {
113
110
text ( 'HIT' , width / 2 , height / 2 ) ;
114
111
maxScore = max ( score , maxScore ) ;
115
112
score = 0 ;
116
- gameisover = true ;
113
+ reset ( ) ;
117
114
}
118
115
119
116
function reset ( ) {
120
117
bgX = 0 ;
121
118
pipes = [ ] ;
122
119
bird = new Bird ( ) ;
123
120
pipes . push ( new Pipe ( ) ) ;
121
+ gameoverFrame = frameCount - 1 ;
124
122
}
125
123
126
124
function keyPressed ( ) {
You can’t perform that action at this time.
0 commit comments