src/scripts/modules/gameutils.js
/**
   * this can be bound to eventhandler for user input detection to trigger stop and will call stop-CB
   */
this can be bound to eventhandler for user input detection to trigger stop and will call stop-CB
this can be bound to eventhandler for user input detection to trigger stop and will call stop - CB
function click(evt) {
    if(!data.run) return;
    let prevKey = data.lastKey;
    if((prevKey !==evt.key && (evt.key==='a' || evt.key==='ArrowLeft' || evt.key==='d'|| evt.key==='ArrowRight'))) {
      data.lastKey=evt.key,data.value+=5;
      data.bargraph.style.left=data.value+'%';
    } 
    var left = data.value+data.barsize/2;
    var res =-1; 
    for(var i=data.areas.length-1; i>=0;i--) {
      if(data.areas[i].a<=left && left<=data.areas[i].b) {
        res=i; data.speed2=(i+1)*2; } 
    }
    if(res===data.areas.length-1) {
      stop();
      if(data.stopCB) data.stopCB(res); 
    }
  }
function click ( evt ) { if ( ! data . run ) return ; let prevKey = data . lastKey ; if ( ( prevKey !== evt . key && ( evt . key === 'a' || evt . key === 'ArrowLeft' || evt . key === 'd' || evt . key === 'ArrowRight' ) ) ) { data . lastKey = evt . key , data . value += 5 ; data . bargraph . style . left = data . value + '%' ; } var left = data . value + data . barsize / 2 ; var res = - 1 ; for ( var i = data . areas . length - 1 ; i >= 0 ; i -- ) { if ( data . areas [ i ] . a <= left && left <= data . areas [ i ] . b ) { res = i ; data . speed2 = ( i + 1 ) * 2 ; } } if ( res === data . areas . length - 1 ) { stop ( ) ; if ( data . stopCB ) data . stopCB ( res ) ; } }
this can be bound to eventhandler for user input detection to trigger stop and will call stop-CB
this can be bound to eventhandler for user input detection to trigger stop and will call stop - CB
//detect if area was hit or not