mirror of
https://github.com/gwenhael-le-moine/c-urs_-toil-s.git
synced 2024-12-26 09:58:48 +01:00
show final alert only once, stop handling event then
This commit is contained in:
parent
b7bb9f32d6
commit
396cefca7d
1 changed files with 70 additions and 66 deletions
|
@ -65,7 +65,8 @@ function initialize_a_star( dom_container ) {
|
|||
moving: cell.BALL,
|
||||
distance_travelled: 0,
|
||||
level: 0,
|
||||
board: ""
|
||||
board: "",
|
||||
it_s_over: false
|
||||
};
|
||||
|
||||
////// FUNCTIONS //////
|
||||
|
@ -238,6 +239,7 @@ function initialize_a_star( dom_container ) {
|
|||
}
|
||||
|
||||
function event_handler( e ) {
|
||||
if ( !state.it_s_over ) {
|
||||
if ( e.type === "click" ) {
|
||||
var movingpos = get_pos( state.moving );
|
||||
var notmovingpos = get_pos( ( state.moving != cell.BALL ) ? cell.BALL : cell.CUBE );
|
||||
|
@ -312,10 +314,12 @@ function initialize_a_star( dom_container ) {
|
|||
display_level( );
|
||||
}
|
||||
else {
|
||||
state.it_s_over = true;
|
||||
alert( "You won!" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function start_loop( ) {
|
||||
|
|
Loading…
Reference in a new issue