[Flash]高橋名人の連射に挑戦

CPSとは? →Click per Secondの略で「1秒間のクリック数」を意味する。

ActionScriptの記述は以下の通り。
onClipEvent(load)
{
  cps = 0;			/*クリック速度*/
  max_cps = 0;		/*瞬間最大クリック速度*/
  start_time = new Array(30);		/*クリック開始時間*/
  for ( i = 0 ; i < 30 ; i++ ) start_time[i] = -1;
  cur_index = 0;
  end_index = 0;
  click_count = 0;
}

onClipEvent(mouseDown)
{
  start_time[cur_index] = getTimer();	/*クリック開始時間の格納*/
  click_count++;
  cur_index++;
  if (cur_index == 30) cur_index = 0;
}

onClipEvent(enterFrame)
{
  while (1) {
    if (start_time[end_index] != -1) {
      if ((getTimer() - start_time[end_index]) >= 1000) {
        start_time[end_index] = -1;
        end_index++;
        click_count--;
        if (end_index == 30) end_index = 0;
        continue;
      }
    }
    cps = click_count;
    if (max_cps < cps) max_cps = cps;
    break;
  }
  this._parent.gotoAndStop(cps+1);
}