File tree Expand file tree Collapse file tree 1 file changed +15
-18
lines changed Expand file tree Collapse file tree 1 file changed +15
-18
lines changed Original file line number Diff line number Diff line change 1-
21var buttonColours = [ "red" , "blue" , "green" , "yellow" ] ;
32
43var gamePattern = [ ] ;
@@ -28,23 +27,23 @@ $(".btn").click(function() {
2827
2928function checkAnswer ( currentLevel ) {
3029
31- if ( gamePattern [ currentLevel ] === userClickedPattern [ currentLevel ] ) {
32- if ( userClickedPattern . length === gamePattern . length ) {
33- setTimeout ( function ( ) {
34- nextSequence ( ) ;
35- } , 1000 ) ;
36- }
37- } else {
38- playSound ( "wrong" ) ;
39- $ ( "body" ) . addClass ( "game-over" ) ;
40- $ ( "#level-title" ) . text ( "Game Over, Press Any Key to Restart" ) ;
41-
30+ if ( userClickedPattern . length > 0 && gamePattern [ currentLevel ] === userClickedPattern [ currentLevel ] ) {
31+ if ( userClickedPattern . length === gamePattern . length ) {
4232 setTimeout ( function ( ) {
43- $ ( "body" ) . removeClass ( "game-over" ) ;
44- } , 200 ) ;
45-
46- startOver ( ) ;
33+ nextSequence ( ) ;
34+ } , 1000 ) ;
4735 }
36+ } else {
37+ playSound ( "wrong" ) ;
38+ $ ( "body" ) . addClass ( "game-over" ) ;
39+ $ ( "#level-title" ) . text ( "Game Over, Press Any Key to Restart" ) ;
40+
41+ setTimeout ( function ( ) {
42+ $ ( "body" ) . removeClass ( "game-over" ) ;
43+ } , 200 ) ;
44+
45+ startOver ( ) ;
46+ }
4847}
4948
5049
@@ -77,5 +76,3 @@ function startOver() {
7776 gamePattern = [ ] ;
7877 started = false ;
7978}
80-
81-
You can’t perform that action at this time.
0 commit comments