Skip to content

Commit f1b834d

Browse files
committed
added new game confirmation, added score variable
1 parent c02b426 commit f1b834d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

repo.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@ function clicked(){
66
}
77

88
audio_start('boop');
9-
109
core_ui_update({
1110
'ids': {
12-
'score': Number.parseInt(
13-
core_elements['score'].textContent,
14-
10
15-
) + 1,
11+
'score': ++score,
1612
},
1713
});
1814
generate();
@@ -74,6 +70,7 @@ function repo_init(){
7470
},
7571
},
7672
'globals': {
73+
'score': 0,
7774
'time': 0,
7875
},
7976
'info': '<button id=start-button type=button>Restart</button>',
@@ -95,6 +92,10 @@ function repo_init(){
9592
}
9693

9794
function reset(){
95+
if(score > 0
96+
&& !globalThis.confirm('Start new game?')){
97+
return;
98+
}
9899
stop();
99100
if(core_menu_open){
100101
core_escape();
@@ -103,6 +104,7 @@ function reset(){
103104
}
104105

105106
function start(){
107+
score = 0;
106108
time = core_storage_data['time-max'];
107109

108110
core_ui_update({

0 commit comments

Comments
 (0)