blockn.htm

戻る

<!DOCTYPE HTML>
<HTML LANG="ja">

<HEAD>
<META CHARSET="Shift_JIS">
<TITLE>BLOCK'N</TITLE>

<STYLE TYPE="text/css">
<!--

.text {
  font-family:monospace;
  font-size:16px;
  line-height:1;
  transform-origin:0%;
}

@keyframes highlighting {
  from {
    color:white;
    background-color:black;
  }
  to {
    color:black;
    background-color:white;
  }
}

-->
</STYLE>

</HEAD>

<BODY STYLE="background-color:#CCFFFF">
<BR><BR>

<DIV ID="back" STYLE="position:relative; width:640px; height:400px; margin-left:auto; margin-right:auto; text-align:center; color:white; background-color:black; -moz-user-select:none; user-select:none">

<DIV ID="opening" STYLE="position:absolute; left:0; top:0; width:640px; height:384px; overflow:hidden; visibility:hidden">
<DIV ID="prompt" CLASS="text" STYLE="position:absolute; left:128px; top:272px; animation:highlighting 1s steps(2, jump-none) infinite; visibility:hidden">HIT SPACE KEY!</DIV>
<DIV CLASS="text" STYLE="position:absolute; left:400px; top:224px">Programed by</DIV>
<DIV CLASS="text" STYLE="position:absolute; left:464px; top:240px">Masato.T</DIV>
<DIV CLASS="text" STYLE="position:absolute; left:400px; top:272px">Character by</DIV>
<DIV CLASS="text" STYLE="position:absolute; left:480px; top:288px">Haruo.M</DIV>
<DIV CLASS="text" STYLE="position:absolute; left:400px; top:320px">Members of</DIV>
<DIV CLASS="text" STYLE="position:absolute; left:432px; top:336px; color:yellow">R E D U A</DIV>
<DIV ID="floor" STYLE="position:absolute; left:496px; top:368px; width:160px; height:32px; background-size:32px; image-rendering:crisp-edges; image-rendering:pixelated"></DIV>
</DIV>

<DIV ID="side" STYLE="position:absolute; left:496px; top:0; width:144px; height:384px; background-size:16px; image-rendering:crisp-edges; image-rendering:pixelated; visibility:hidden">
<DIV ID="side1" STYLE="position:absolute; left:16px; top:16px; width:112px; height:48px; background-color:black">
<DIV CLASS="text" STYLE="position:absolute; left:0; top:16px; color:cyan">BLOCK'N</DIV>
</DIV>
<DIV ID="side2" STYLE="position:absolute; left:16px; top:112px; width:112px; height:144px; background-color:black">
<DIV CLASS="text" STYLE="position:absolute; left:16px; top:16px">ROUND</DIV>
<DIV ID="stage" CLASS="text" STYLE="position:absolute; right:16px; top:48px; transform-origin:100%; color:yellow"></DIV>
<DIV CLASS="text" STYLE="position:absolute; left:16px; top:80px">LEFT</DIV>
<DIV ID="balls" CLASS="text" STYLE="position:absolute; right:16px; top:112px; transform-origin:100%; color:yellow"></DIV>
</DIV>
<DIV ID="side3" STYLE="position:absolute; left:16px; top:288px; width:112px; height:80px; background-color:black">
<DIV CLASS="text" STYLE="position:absolute; left:16px; top:16px">FROM</DIV>
<DIV CLASS="text" STYLE="position:absolute; left:16px; top:48px; color:cyan">REDUA</DIV>
</DIV>
</DIV>

<DIV ID="items" STYLE="position:absolute; left:0; top:0; width:640px; height:384px; overflow:hidden"></DIV>
<DIV ID="ball" STYLE="position:absolute; width:32px; height:32px; background-size:32px; image-rendering:crisp-edges; image-rendering:pixelated; visibility:hidden"></DIV>

<DIV ID="start" CLASS="text" STYLE="position:absolute; left:64px; top:176px; visibility:hidden">LET'S INSERT BLOCKS!</DIV>
<DIV ID="clear" CLASS="text" STYLE="position:absolute; left:112px; top:176px; color:red; background-color:black; visibility:hidden">CONGRATULATIONS!</DIV>
<DIV ID="win1" STYLE="position:absolute; left:0; top:0; width:640px; height:400px; visibility:hidden">
<DIV CLASS="text" STYLE="position:absolute; left:80px; top:80px; color:lime">CONGRATULATIONS!!</DIV>
<DIV CLASS="text" STYLE="position:absolute; left:128px; top:112px; color:yellow">YOU FINISHED</DIV>
<DIV CLASS="text" STYLE="position:absolute; left:64px; top:144px; color:yellow">THIS GAME AT LAST!!</DIV>
<DIV CLASS="text" STYLE="position:absolute; left:128px; top:192px">PRESENTED BY</DIV>
<DIV CLASS="text" STYLE="position:absolute; left:160px; top:224px; color:red">R E D U A</DIV>
<DIV CLASS="text" STYLE="position:absolute; left:80px; top:256px">MASATO.T & HARUO.M</DIV>
</DIV>
<DIV ID="win2" CLASS="text" STYLE="position:absolute; left:160px; top:192px; visibility:hidden">BE CONTINUED...</DIV>
<DIV ID="over" CLASS="text" STYLE="position:absolute; left:80px; top:176px; color:red; background-color:black; visibility:hidden">G A M E&nbsp;&nbsp;&nbsp;O V E R&nbsp;</DIV>

<DIV ID="sound" STYLE="display:inline-block; position:relative; margin-top:100px; padding:20px; color:black; background-color:white; border-radius:5px">
<DIV STYLE="font-size:14px">サウンドを使用しますか?</DIV>
<BUTTON ID="sound-on" TYPE="BUTTON" STYLE="margin-top:10px; font-size:14px" onClick="sound(true)">使用する</BUTTON>
<BUTTON ID="sound-off" TYPE="BUTTON" STYLE="margin-left:10px; margin-top:10px; font-size:14px" onClick="sound(false)">使用しない</BUTTON>
</DIV>
</DIV>

<SCRIPT TYPE="text/javascript">
<!--
// このプログラムは高家磨佐人さん作のシャープ X1 用のゲーム“BLOCK'N”を移植したものです.
// 画面に表示されるクレジットは原作についてのものです.

function sound(on) {
  document.getElementById("sound").style.visibility = "hidden";
  // Firefox で必要
  document.getElementById("sound-on").blur();
  document.getElementById("sound-off").blur();

  if(on) {
    // サウンド
    sound_opening = ["V13O5C1O4GR1GRGRGO5DO4GRGRGRGO5C5O4B4G5",
                     "V13O3E2R0E2R0E0R0E2R0E1F2R0F2R0F0R0F2R0F1O3E0RERFRFR#FR#F3G5"];
    sound_start = ["V14O5D1#C#CG#F#FO6D#C#CG#F#FO7D#CD#CD#CD#C",
                   "V14O4F3R1B3R1O5F3R1B3R1O6#F1#G4#G5",
                   "V14O3-A1A-A0AD1+DD0+DO4-A1A-A0AD1+DD0+DA7"];
    sound_clear = ["V11O4C1GFGEDO3CGFGEDO4CBABFEO3CBABFEV10O4CDFGABO5CDFGAB+C5",
                   "V11O3E1BABGFO2E1BABGFO3E+CB+CAGO2E+CB+CAGV10O5+CBAGFDCO4BAGFDC5",
                   "V15O3C4R1C3-G4R1-G3D4R1D3-G4R1-G3C4R1C3-G4R1-G3C4"];
    sound_give_up = ["V14O5#D5D0CO4#AAGF#DDCO3#AA0A3",
                     "V14O4A3G0F#DDCO3#AA5G0F#DD1",
                     "V14O4#D3D0CO3#AAA1G0F#DD5C0-A"];
    sound_over1 = ["V14O5C0O4B#AA#GG#FFE#DD#CC",
                   "V14O3B0#AA#GG#FFE#DD#CC-B"];
    sound_over2 = ["V14O1G0O2GO3GO4GO5GO6GO7GO8G".repeat(2),
                   "V14O1E0O2EO3EO4EO5EO6EO7EO8E".repeat(2),
                   "V14O1C0O2CO3CO4CO5CO6CO7CO8C".repeat(2)];

    n_i = [9, 11, 0, 2, 4, 5, 7];  // 音名 - 周波数インデックス 変換

    aud_ctx = new AudioContext();
    sound_gain = aud_ctx.createGain();
    sound_gain.connect(aud_ctx.destination);
    var gain_b = aud_ctx.createGain();
    gain_b.connect(aud_ctx.destination);
    var gain_c = aud_ctx.createGain();
    gain_c.connect(aud_ctx.destination);
    gain_nodes = [sound_gain, gain_b, gain_c];

    // ノイズ
    noise_buf = aud_ctx.createBuffer(1, 1250, 12500);
    var pcm = noise_buf.getChannelData(0);
    for(var i = 0; i < 1250; i += 2)
      pcm[i] = pcm[i + 1] = Math.floor(Math.random() * 2) * 2 - 1;

    // 音階周波数テーブル作成
    // [45] が 440Hz
    freq = new Float32Array(96);
    for(var i = 0; i < 96; i++)
      freq[i] = 440 * Math.pow(2, (i - 45) / 12);

    sound1 = sound2 = sound3 = undefined;
  }
  else {
    aud_ctx = undefined;
  }

  opening();
}

// オープニング
function opening() {
  elem_opening.style.visibility = "visible";
  place_items(opening_items);
  elem_ball.style.visibility = "visible";
  stoppers = 2;  // CONGRATULATIONS! が出ないように
  setTimeout(opening2, 1000);
}

function opening2() {
  jump(opening3);
}

function opening3() {
  setTimeout(opening4, 800);
}

function opening4() {
  jump(opening5);
}

function opening5() {
  setTimeout(opening6, 800);
}

function opening6() {
  if(aud_ctx == undefined)
    opening8();
  else
    opening7();
}

function opening7() {
  play(120, sound_opening, opening8);
}

function opening8() {
  addEventListener("keydown", opening10, false);
  elem_prompt.style.visibility = "visible";
  if(aud_ctx != undefined)
    to_id = setTimeout(opening9, 20000);
}

function opening9() {
  removeEventListener("keydown", opening10, false);
  elem_prompt.style.visibility = "hidden";
  opening7();
}

function opening10(e) {
  if(e.key == " ") {
    if(aud_ctx != undefined)
      clearTimeout(to_id);
    removeEventListener("keydown", opening10, false);
    jump(opening11);
  }
}

function opening11() {
  setTimeout(opening12, 1000);
}

function opening12() {
  elem_opening.style.visibility = elem_prompt.style.visibility = "hidden";
  elem_side.style.visibility = "visible";
  stage = 1;
  balls = 3;
  start(false);
}

function start(again) {
  clear_items();
  elem_stage.textContent = String(stage);
  elem_balls.textContent = String(balls);
  elem_start.style.visibility = "visible";
  if(aud_ctx != undefined) {
    sound1 = aud_ctx.createOscillator();
    sound1.type = "square";
    sound1.frequency.value = 488.28;
    sound1.onended = sound_ended;
    sound1.connect(sound_gain);

    sound2 = aud_ctx.createOscillator();
    sound2.type = "square";
    sound2.frequency.value = 244.14;
    sound2.connect(sound_gain);

    sound3 = aud_ctx.createOscillator();
    sound3.type = "square";
    sound3.frequency.value = 162.76;
    sound3.connect(sound_gain);

    // Firefox では直接 sound_gain.gain.value に値をセットすると linearRampToValueAtTime() が正しく動作しない.
    sound_gain.gain.setValueAtTime(0.3, 0);
    sound1.start();
    sound2.start();
    sound3.start();
    var time = aud_ctx.currentTime + 1;
    sound1.stop(time);
    sound2.stop(time);
    sound3.stop(time);
    sound_gain.gain.linearRampToValueAtTime(0.26, time);
  }
  setTimeout(start2, 1000, again);
}

function start2(again) {
  elem_start.style.visibility = "hidden";
  place_items(items_list[stage - 1]);
  if(again || aud_ctx == undefined)
    start3();
  else
    play(150, sound_start, start3);
}

function start3() {
  elem_ball.style.visibility = "visible";
  disable_key = false;
  addEventListener("keydown", keyin, false);
  setTimeout(start4, 500);
}

function start4() {
  if(!disable_key) {
    disable_key = true;
    fall(keyin_end);
  }
}

// アイテムを配置
function place_items(items) {
  stoppers = 0;
  for(var y = 0; y < 13; y++) {
    var map_y = map[y] = items[y].concat();

    map_elem[y] = [];
    var style_y = String((y << 5) - 16) + "px";
    for(var x = 0; x < 16; x++) {
      var item = map_y[x];
      if(item) {  // アイテムあり
        var elem = document.createElement("DIV");
        elem.style.position = "absolute";
        elem.style.left = String((x << 5) - 16) + "px";
        elem.style.top = style_y;
        elem.style.width = elem.style.height = "32px";
        elem.style.backgroundImage = "url(" + images[item] + ")";
        elem.style.backgroundSize = "32px";
        elem.style.imageRendering = "crisp-edges";
        elem.style.imageRendering = "pixelated";

        elem_items.appendChild(elem);
        map_elem[y][x] = elem;

        switch(item) {
        case 2:  // ストッパー
        case 3:
          stoppers++;
          break;
        }
      }
    }
  }

  ball_x = ball_y = 0;
  move_ball(items[13], items[14]);
}

// アイテムをクリア
function clear_items() {
  while(elem_items.childElementCount)
    elem_items.firstElementChild.remove();
  elem_ball.style.visibility = "hidden";
}

// キー入力
function keyin(e) {
  if(disable_key)
    return;

  var dx = 0;
  var dy = 0;
  switch(e.key) {
  case " ":
    // ジャンプ
    disable_key = true;
    jump(keyin_end);
    return;

  case "ArrowLeft":  // ←
  case "4":
    dx = -1;
    break;

  case "ArrowRight":  // →
  case "6":
    dx = 1;
    break;

  case "ArrowUp":  // ↑
  case "8":
    if(map[ball_y][ball_x] != 5)  // マグネット以外
      return;
    dy = -1;
    break;

  case "ArrowDown":  // ↓
  case "2":
    dy = 1;
    break;

  case "G":  // ギブ アップ
  case "g":
    give_up();
    return;

  default:
    return;
  }

  switch(map[ball_y + dy][ball_x + dx]) {
  case 1:  // ハード
  case 6:  // 穴 上
  case 7:  // 穴 下
    return;
  }

  disable_key = true;
  if(aud_ctx != undefined) {
    stop_sound();

    sound1 = aud_ctx.createBufferSource();
    sound1.loop = true;
    sound1.buffer = noise_buf;
    sound1.onended = sound_ended;
    sound1.connect(sound_gain);

    // Firefox では直接 sound_gain.gain.value に値をセットすると linearRampToValueAtTime() が正しく動作しない.
    sound_gain.gain.setValueAtTime(0.3, 0);
    sound1.start();
    var time = aud_ctx.currentTime + 0.013;
    sound1.stop(time);
    sound_gain.gain.linearRampToValueAtTime(0, time);
  }
  setTimeout(keyin2, 100, dx, dy);
}

function keyin2(dx, dy) {
  switch(map[ball_y + dy][ball_x + dx]) {
  case 0:  // 空
  case 5:  // マグネット
    move_ball(dx, dy);
    fall(keyin_end);
    return;

  case 8:  // ワープ 左
    switch(map[ball_y][14]) {
    case 0:  // 空
    case 5:  // マグネット
      move_ball(13, 0);
      fall(keyin_end);
      return;
    }
    break;

  case 9:  // ワープ 右
    switch(map[ball_y][1]) {
    case 0:  // 空
    case 5:  // マグネット
      move_ball(-13, 0);
      fall(keyin_end);
      return;
    }
    break;

  default:
    if(dx) {  // 横方向の移動
      if(!map[ball_y][ball_x + (dx << 1)]) {  // 空
        move_block(ball_x + dx, ball_y, dx, 0);
        move_ball(dx, 0);
        fall(keyin_end);
        return;
      }
    }
  }

  disable_key = false;
}

function keyin_end() {
  disable_key = false;
}

// ジャンプ
function jump(end) {
  if(map[ball_y][ball_x] == 5) {  // マグネット
    end();
    return;
  }
  jump2(3, end);
}

function jump2(cnt, end) {
  var upper1 = map[ball_y - 1][ball_x];
  switch(upper1) {
  case 0:  // 空
    setTimeout(jump3, 100, cnt, end);
    return;

  case 1:  // ハード
  case 6:  // 穴 上
    break;

  case 5:  // マグネット
    move_ball(0, -1);
    end();
    return;

  default:
    if(ball_y == 1)
      break;
    var upper2 = map[ball_y - 2][ball_x];
    if(upper1 == 2 && upper2 == 6) {  // 上がストッパー(上)でその上が穴
      map_elem[ball_y - 2][ball_x].remove();  // 穴のエレメントを削除
      move_block(ball_x, ball_y - 1, 0, -1);
      move_ball(0, -1);
      stoppers--;
      if(aud_ctx != undefined)
        push_sound();
      break;
    }
    if(!upper2) {  // 空
      move_block(ball_x, ball_y - 1, 0, -1);
      move_ball(0, -1);
      if(aud_ctx != undefined)
        push_sound();
    }
  }

  fall(end);
}

function jump3(cnt, end) {
  move_ball(0, -1);
  if(cnt == 1) {
    fall(end);
    return;
  }
  jump2(cnt - 1, end);
}

// 落下
function fall(end) {
  if(map[ball_y][ball_x] == 5) {  // マグネット
    end();
    return;
  }
  fall2(0, end);
}

function fall2(cnt, end) {
  var pushed = false;
  var lower1 = map[ball_y + 1][ball_x];
  switch(lower1) {
  case 0:  // 空
    setTimeout(fall3, 100, cnt, end);
    return;

  case 1:  // ハード
  case 5:  // マグネット
  case 7:  // 穴 下
    break;

  default:
    if(cnt < 2)
      break;
    if(ball_y == 11)
      break;
    var lower2 = map[ball_y + 2][ball_x];
    if(lower1 == 3 && lower2 == 7) {  // 下がストッパー(下)でその下が穴
      map_elem[ball_y + 2][ball_x].remove();  // 穴のエレメントを削除
      move_block(ball_x, ball_y + 1, 0, 1);
      move_ball(0, 1);
      stoppers--;
      if(aud_ctx != undefined) {
        push_sound();
        pushed = true;
      }
      break;
    }
    if(!lower2) {  // 空
      move_block(ball_x, ball_y + 1, 0, 1);
      move_ball(0, 1);
      if(aud_ctx != undefined) {
        push_sound();
        pushed = true;
      }
    }
  }

  if(cnt && aud_ctx != undefined && !pushed) {
    stop_sound();

    sound1 = aud_ctx.createBufferSource();
    sound1.loop = true;
    sound1.buffer = noise_buf;
    sound1.onended = sound_ended;
    sound1.connect(sound_gain);

    // Firefox では直接 sound_gain.gain.value に値をセットすると linearRampToValueAtTime() が正しく動作しない.
    sound_gain.gain.setValueAtTime(0.3, 0);
    sound1.start();
    var time = aud_ctx.currentTime + 0.066;
    sound1.stop(time);
    sound_gain.gain.linearRampToValueAtTime(0, time);
  }

  end();

  if(!stoppers)  // ストッパーをすべてはめ込んだ
    clear();
}

function fall3(cnt, end) {
  move_ball(0, 1);
  fall2(cnt + 1, end);
}

function push_sound() {
  stop_sound();

  sound1 = aud_ctx.createOscillator();
  sound1.type = "square";
  sound1.frequency.value = 34.88;
  sound1.onended = sound_ended;
  sound1.connect(sound_gain);

  sound2 = aud_ctx.createOscillator();
  sound2.type = "square";
  sound2.frequency.value = 122.07;
  sound2.connect(sound_gain);

  // Firefox では直接 sound_gain.gain.value に値をセットすると linearRampToValueAtTime() が正しく動作しない.
  sound_gain.gain.setValueAtTime(0.3, 0);
  sound1.start();
  sound2.start();
  var time = aud_ctx.currentTime + 0.72;
  sound1.stop(time);
  sound2.stop(time);
  sound_gain.gain.linearRampToValueAtTime(0, time);
}

// ボール移動
function move_ball(dx, dy) {
  ball_x += dx;
  ball_y += dy;
  elem_ball.style.left = String((ball_x << 5) - 16) + "px";
  elem_ball.style.top = String((ball_y << 5) - 16) + "px";
}

// ブロック移動
function move_block(x, y, dx, dy) {
  var dst_x = x + dx;
  var dst_y = y + dy;

  map[dst_y][dst_x] = map[y][x];
  map[y][x] = 0;

  var elem = map_elem[dst_y][dst_x] = map_elem[y][x];
  elem.style.left = String((dst_x << 5) - 16) + "px";
  elem.style.top = String((dst_y << 5) - 16) + "px";
}

// 1 ステージ クリア
function clear() {
  removeEventListener("keydown", keyin, false);
  setTimeout(clear2, 800);
}

function clear2() {
  elem_clear.style.visibility = "visible";
  if(aud_ctx == undefined)
    clear3();
  else
    play(180, sound_clear, clear3);
}

function clear3() {
  setTimeout(clear4, 2000);
}

function clear4() {
  elem_clear.style.visibility = "hidden";
  if(stage == 15) {  // 全ステージ クリア
    clear_items();
    elem_stage.textContent = "16";
    elem_balls.textContent = "3";
    (elem_win1 = document.getElementById("win1")).style.visibility = "visible";
    setTimeout(clear5, 5000);
    return;
  }
  stage++;
  balls = 3;
  start(false);
}

function clear5() {
  elem_win1.style.visibility = "hidden";
  elem_side.style.visibility = "hidden";
  (elem_win2 = document.getElementById("win2")).style.visibility = "visible";
  setTimeout(clear6, 1000);
}

function clear6() {
  elem_win2.style.visibility = "hidden";
}

// ギブアップ
function give_up() {
  removeEventListener("keydown", keyin, false);
  if(aud_ctx == undefined)
    give_up2();
  else
    play(180, sound_give_up, give_up2);
}

function give_up2() {
  if(--balls) {
    // やり直し
    start(true);
  }
  else {
    // ゲーム オーバー
    elem_balls.textContent = "0";
    (elem_over = document.getElementById("over")).style.visibility = "visible";
    if(aud_ctx == undefined)
      give_up4();
    else
      play(125, sound_over1, give_up3);
  }
}

function give_up3() {
  play(255, sound_over2, give_up4);
}

function give_up4() {
  setTimeout(give_up5, 2000);
}

function give_up5() {
  clear_items();
  elem_side.style.visibility = "hidden";
  elem_over.style.visibility = "hidden";
  elem_opening.style.visibility = "visible";
  opening();
}

// サウンド発生
function play(tempo, data, end) {
  var max_time = 0;
  var start = aud_ctx.currentTime;
  for(var i_ch = 0; i_ch < data.length; i_ch++) {
    var notes = data[i_ch];
    var gain = gain_nodes[i_ch];
    var oct = 0;
    var oct_mod = 0;
    var len = 0;
    var time = start;
    for(var i_note = 0; i_note < notes.length; ) {
      var c = notes.charAt(i_note++);
      if(c == "O") {  // オクターブ
        if(i_note == notes.length)
          break;
        c = notes.charAt(i_note);
        if(c < "1" || c > "8")
          continue;
        i_note++;
        oct = c.charCodeAt() - "1".charCodeAt();
        oct_mod = 0;
      }
      else if(c == "+") {  // 1 オクターブ上
        oct_mod = 1;
      }
      else if(c == "-") {  // 1 オクターブ下
        oct_mod = -1;
      }
      else if(c == "V") {  // 音量
        if(i_note == notes.length)
          break;
        c = notes.charAt(i_note);
        if(c < "0" || c > "9")
          continue;
        i_note++;
        var volume = c.charCodeAt() - "0".charCodeAt();
        if(i_note == notes.length)
          break;
        c = notes.charAt(i_note);
        if(c >= "0" && c <= "9") {
          i_note++;
          volume = volume * 10 + (c.charCodeAt() - "0".charCodeAt());
        }
        gain.gain.setValueAtTime(volume * 0.02, time);
      }
      else {
        var i_freq;
        if(c == "R") {  // 休符
          i_freq = -1;
        }
        else {
          var sharp;
          if(c == "#") {  // 半音上
            if(i_note == notes.length)
              break;
            c = notes.charAt(i_note);
            if(c < "A" || c > "G")
              continue;
            i_note++;
            sharp = 1;
          }
          else {
            if(c < "A" || c > "G")
              continue;
            sharp = 0;
          }
          i_freq = (oct + oct_mod) * 12 + n_i[c.charCodeAt() - "A".charCodeAt()] + sharp;
          if(i_freq >= 96)
            i_freq = -1;
          oct_mod = 0;
        }

        // 音符/休符の長さ
        if(i_note < notes.length) {
          var f = true;
          switch(notes.charAt(i_note)) {
          case "0":  // 32分音符
            len = 7.5;
            break;
          case "1":  // 16分音符
            len = 15;
            break;
          case "2":  // 付点16分音符
            len = 22.5;
            break;
          case "3":  // 8分音符
            len = 30;
            break;
          case "4":  // 付点8分音符
            len = 45;
            break;
          case "5":  // 4分音符
            len = 60;
            break;
          case "6":  // 付点4分音符
            len = 90;
            break;
          case "7":  // 2分音符
            len = 120;
            break;
          case "8":  // 付点2分音符
            len = 180;
            break;
          case "9":  // 全音符
            len = 240;
            break;
          default:
            f = false;
          }
          if(f) {
            i_note++;
            len /= tempo;
          }
        }

        if(i_freq >= 0) {  // 休符でない
          var note = aud_ctx.createOscillator();
          note.type = "square";
          note.frequency.value = freq[i_freq];
          note.onended = note_ended;
          note.connect(gain);
          note.start(time);
          note.stop(time + len * 0.98);
        }
        time += len;
      }
    }

    if(time > max_time)
      max_time = time;
  }

  setTimeout(end, (max_time - start) * 1000);
}

function note_ended(e) {
  e.currentTarget.disconnect();
}

function sound_ended() {
  sound1.disconnect();
  sound1 = undefined;
  if(sound2 != undefined) {
    sound2.disconnect();
    sound2 = undefined;
    if(sound3 != undefined) {
      sound3.disconnect();
      sound3 = undefined;
    }
  }
}

function stop_sound() {
  if(sound1 != undefined) {
    sound1.onended = null;
    sound1.stop();
    if(sound2 != undefined) {
      sound2.stop();
      if(sound3 != undefined)
        sound3.stop();
    }
    sound_ended();
  }
}

  // 画像
  images = [
    undefined,  // ダミー
    // ハード ブロック
    "data:image/gif;base64,"
      + "R0lGODlhEAAQAPEAAAAAAP//AAAA/////ywAAAAAEAAQAAACM0R0iXs28SKcT7CrGgV48LMAxiVqVYZZ"
      + "6Co4LJqybnzRqOt1n9qOStma2BbDH+fYSiJFBQA7",
    // ストッパー ブロック 上
    "data:image/gif;base64,"
      + "R0lGODlhEAAQAPIAAAAAAP8AAP//AP8A/////wAAAAAAAAAAACwAAAAAEAAQAAADPAgS2/xLEUcfCA/r"
      + "rRX/2JVpBDFw3laWm7hga/mGcyy/rrqiM7x3mF6MxxkCR6BOLxkQXZ7NKBQwlVqpCQA7",
    // ストッパー ブロック 下
    "data:image/gif;base64,"
      +  "R0lGODlhEAAQAPIAAAAAAP8AAP//AP8A/////wAAAAAAAAAAACwAAAAAEAAQAAADQAgS2/xLEUcfCA/r"
      +  "rRX/2JVhRElw3maeHbZoK/rC5ia+axzOwSrMN1XNNhsEBgJWawTq8JoB0WUarVIBV6sWmwAAOw==",
    // ノーマル ブロック
    "data:image/gif;base64,"
      + "R0lGODlhEAAQAPIAAAAAAAD/AAAA/wD//////wAAAAAAAAAAACwAAAAAEAAQAAADNwhEw96QqPVqE4GO"
      + "sDv/AvR5HsaMaCmSqMm+QXjCm5veMg1mujrfNR6wtRraMMiYEglYOpMCQAIAOw==",
    // マグネット ブロック
    "data:image/gif;base64,"
      + "R0lGODlhEAAQAPEAAAAAAP//AAAA/////ywAAAAAEAAQAAACNkR0iXs28SKcT7Cr2gS8+7UYwUhOgpNh"
      + "YMqemwevbklWqJriKgrHR0iraSothS7FOSkByyWgAAA7",
    // 穴 上
    "data:image/gif;base64,"
      + "R0lGODlhEAAQAPEAAAAAAP//AAAA/////ywAAAAAEAAQAAACHISPqcvtD6OctNqLR9B8+yME4SiWIQgI"
      + "6aqqRgEAOw==",
    // 穴 下
    "data:image/gif;base64,"
      + "R0lGODlhEAAQAPEAAAAAAP//AAAA/////ywAAAAAEAAQAAACHAQWqMkGEqCMFDrxMt6u+w+G4kiW5omm"
      + "6sq2XQEAOw==",
    // ワープ 左
    "data:image/gif;base64,"
      + "R0lGODlhEAAQAPIAAAAAAP8AAP//AAAA/////wAAAAAAAAAAACwAAAAAEAAQAAADKwi6OuKQSUGoHXK5"
      + "zMELneSA4fKVmkCiJwqMrjesJey2qM1iMfQ8tZcQkAAAOw==",
    // ワープ 右
    "data:image/gif;base64,"
      + "R0lGODlhEAAQAPIAAAAAAP8AAP//AAAA/////wAAAAAAAAAAACwAAAAAEAAQAAADOwgy2/xLETErvXOA"
      + "zaHnXOBQwAMCwadop+g57Wu2oxrKEY2zd52Drgah9NukYKvTxvfY1TaaaGkqBSQAADs="
  ];
  // ボール
  ball_image =
    "data:image/gif;base64,"
      + "R0lGODlhEAAQAPEAAAAAAAAA/wD//////ywAAAAAEAAQAAACPoQdmccY8lRoIAkxBlTM5nxxR/Jp0DZV"
      + "T3lyE/m1KIKBkVSpWIunES956X7BnMNSTCFUSeNS6KJAc0oK1VoAADs=";
  // 小ブロック
  small_image =
    "data:image/gif;base64,"
      + "R0lGODlhCAAIAPEAAAAAAP//AAAA/////ywAAAAACAAIAAACEkR0ZxPMgqJqKcq46rkKCA8CBQA7";

  opening_items = [
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0],
    [0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0],
    [0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0],
    [0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    [1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,1],
    2, 9
  ];

  // アイテム配置リスト
  items_list = [
    // ステージ 1
    [[1,1,1,6,1,6,1,6,1,1,1,1,1,1,1,1],
     [1,0,0,2,0,2,0,0,0,0,0,5,0,0,0,1],
     [1,0,1,0,0,0,1,2,0,0,0,0,5,0,0,1],
     [1,0,1,0,0,0,1,0,5,0,0,4,5,0,0,1],
     [1,0,0,5,0,5,0,5,0,5,0,0,5,0,0,1],
     [1,0,0,5,0,5,0,0,0,0,0,0,5,0,0,1],
     [1,0,0,0,1,0,0,0,0,0,0,0,5,0,0,1],
     [1,0,0,0,1,0,0,1,3,1,0,0,5,0,0,1],
     [1,0,0,5,0,5,0,0,0,0,0,0,5,0,0,1],
     [1,0,0,5,0,5,0,0,0,0,0,0,5,0,0,1],
     [1,0,5,0,0,0,5,0,0,0,0,0,5,0,0,1],
     [1,0,5,0,3,0,5,0,0,0,0,5,1,3,1,1],
     [1,1,1,1,7,1,1,7,1,1,1,1,1,7,1,1],
     9, 11],
    // ステージ 2
    [[1,6,1,6,1,1,1,1,1,1,6,1,1,1,1,1],
     [1,0,0,0,0,0,0,0,0,0,0,4,0,0,0,1],
     [1,0,0,0,0,0,0,0,0,0,2,1,1,0,0,1],
     [1,0,2,2,5,0,0,0,0,5,0,1,0,1,0,1],
     [1,0,0,0,0,0,5,0,5,1,0,1,0,0,0,1],
     [1,1,1,1,1,1,0,5,1,0,5,1,5,0,3,1],
     [1,0,0,0,0,0,5,1,0,0,5,1,5,0,0,1],
     [1,0,0,0,0,5,1,0,0,0,5,1,5,0,0,1],
     [1,0,0,0,5,1,0,0,0,3,5,1,5,3,0,1],
     [1,0,0,5,1,0,0,0,3,0,5,1,5,0,0,1],
     [1,0,5,1,0,0,0,3,0,0,5,1,5,0,0,1],
     [8,0,0,0,0,0,3,0,0,0,5,1,5,0,0,9],
     [1,1,1,1,1,1,7,7,7,7,1,1,1,7,7,1],
     10, 1],
    // ステージ 3
    [[1,6,1,6,1,1,1,6,1,6,1,6,1,1,1,1],
     [1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
     [1,0,0,2,0,0,0,0,0,2,0,2,0,0,0,1],
     [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
     [1,0,0,0,0,0,0,2,5,1,1,1,1,5,0,1],
     [1,4,5,4,5,4,5,0,5,0,0,0,0,5,0,1],
     [1,0,0,0,0,0,5,0,5,0,1,0,0,5,0,1],
     [1,0,0,0,0,0,5,3,5,0,0,0,0,0,5,1],
     [1,0,0,0,5,0,0,0,5,0,0,0,0,3,5,1],
     [1,0,0,5,0,0,0,1,0,3,0,3,0,0,5,1],
     [1,0,5,0,0,0,0,0,0,0,0,0,0,5,0,1],
     [1,5,0,0,0,0,0,0,0,0,0,0,0,5,0,1],
     [1,1,1,1,1,7,1,1,1,7,1,7,7,1,1,1],
     10, 5],
    // ステージ 4
    [[1,6,6,1,1,1,1,1,1,1,6,1,1,1,1,1],
     [1,2,2,0,0,0,0,0,0,2,0,0,0,5,0,1],
     [1,0,0,0,0,1,0,0,5,0,0,0,0,0,0,1],
     [1,0,0,0,0,0,0,0,5,0,5,0,0,0,0,1],
     [8,0,0,0,0,0,0,0,5,0,0,0,0,5,0,9],
     [1,0,4,1,1,1,1,1,5,3,0,0,0,0,1,1],
     [1,0,0,0,0,0,0,0,5,0,5,3,0,5,0,1],
     [1,0,5,1,1,1,1,1,5,0,1,0,0,5,0,1],
     [1,0,0,0,0,0,0,0,0,0,0,1,0,5,0,1],
     [8,0,0,0,0,0,0,0,0,0,0,0,0,5,0,9],
     [1,1,5,0,5,0,5,0,5,0,0,0,0,1,1,1],
     [1,0,0,3,0,3,0,3,0,0,0,0,0,0,0,1],
     [1,1,1,7,1,7,1,7,1,7,1,1,7,1,1,1],
     5, 1],
    // ステージ 5
    [[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
     [1,5,5,5,5,5,0,0,0,0,0,0,0,0,0,1],
     [1,5,0,0,0,0,5,0,0,0,0,0,0,0,0,1],
     [1,5,0,0,0,1,0,0,0,4,0,0,0,0,0,1],
     [8,5,0,0,1,0,1,1,3,1,3,1,1,1,0,9],
     [1,0,0,0,1,0,0,1,0,1,0,1,0,0,5,1],
     [1,0,0,1,1,4,0,1,0,1,0,1,0,0,5,1],
     [1,0,0,1,0,0,0,4,0,1,0,0,0,0,5,1],
     [1,0,0,1,0,0,3,1,0,1,0,1,3,4,5,1],
     [1,0,3,1,0,0,0,1,0,1,0,1,0,4,5,1],
     [1,0,0,1,0,0,0,1,0,1,0,1,0,0,5,1],
     [8,0,0,0,0,0,0,1,0,1,0,0,0,0,5,9],
     [1,1,7,1,1,1,7,1,7,1,7,1,7,1,1,1],
     3, 5],
    // ステージ 6
    [[1,1,1,1,1,6,1,1,1,1,6,1,6,1,6,1],
     [1,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1],
     [1,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1],
     [1,0,5,4,4,0,4,5,1,0,0,0,0,0,0,1],
     [1,0,5,0,0,0,0,5,4,2,0,5,1,5,0,1],
     [1,0,5,0,0,2,1,5,0,0,3,5,0,5,0,1],
     [1,5,1,4,1,0,0,5,1,0,0,5,1,1,4,1],
     [1,5,0,0,0,3,1,5,0,0,1,5,0,0,0,1],
     [1,5,0,0,0,0,0,5,0,0,0,1,1,5,1,1],
     [1,0,1,4,1,1,1,1,5,0,0,0,0,5,0,1],
     [1,0,0,0,0,0,0,0,5,0,0,0,0,5,0,1],
     [1,0,0,0,0,0,0,0,5,0,0,0,0,5,0,1],
     [1,1,1,7,1,1,1,1,1,7,1,1,1,1,1,1],
     6, 11],
    // ステージ 7
    [[1,1,6,1,1,1,6,1,1,1,1,6,1,1,1,1],
     [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
     [1,0,2,0,1,0,2,0,5,0,2,0,1,0,0,1],
     [1,0,0,5,0,4,0,1,0,1,0,4,0,1,0,1],
     [1,0,1,0,4,0,4,0,5,0,5,0,4,0,0,1],
     [1,0,0,4,0,5,0,5,0,4,0,1,0,5,0,1],
     [1,0,4,0,5,0,1,0,1,0,5,0,5,0,0,1],
     [1,0,0,1,0,5,0,4,0,4,0,1,0,5,0,1],
     [1,0,1,0,4,0,5,0,5,0,4,0,1,0,0,1],
     [1,0,0,1,0,5,0,1,0,4,0,4,0,5,0,1],
     [1,0,1,0,3,0,1,0,1,0,1,0,1,0,0,1],
     [1,0,0,1,0,1,0,1,0,1,0,1,0,0,0,1],
     [1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1],
     13, 11],
    // ステージ 8
    [[1,1,1,1,1,6,1,1,1,1,1,1,1,1,1,1],
     [1,0,0,0,0,0,0,0,0,5,0,0,0,5,0,1],
     [8,0,0,0,0,0,0,0,1,0,1,1,1,0,0,9],
     [1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1],
     [8,0,0,0,3,0,5,0,0,0,0,0,0,0,0,9],
     [1,5,0,5,0,0,0,5,0,0,0,0,0,5,0,1],
     [1,0,0,0,2,0,4,5,0,4,0,0,0,0,0,1],
     [1,0,0,0,0,0,5,0,4,0,0,0,0,0,0,1],
     [1,0,0,1,1,1,0,1,0,0,0,0,0,0,0,1],
     [1,5,0,0,0,1,0,0,0,3,0,0,0,1,1,1],
     [1,0,0,0,0,5,0,5,3,0,0,0,3,0,0,1],
     [1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1],
     [1,1,1,1,1,1,7,1,7,1,7,1,7,1,1,1],
     12, 9],
    // ステージ 9
    [[1,1,1,1,1,1,6,1,1,1,1,1,1,1,1,1],
     [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
     [1,1,4,1,0,5,2,5,0,4,5,0,1,0,4,1],
     [1,0,5,0,0,5,0,0,0,1,0,0,5,0,4,1],
     [1,0,5,0,0,1,4,0,0,3,0,0,4,5,4,1],
     [1,0,5,0,0,1,0,0,0,4,4,0,1,0,4,1],
     [1,0,0,0,0,1,1,1,0,0,0,0,1,0,4,1],
     [1,5,5,3,0,0,0,0,0,5,0,0,0,0,0,1],
     [1,5,0,5,0,4,5,1,0,4,0,0,0,5,0,1],
     [1,5,1,1,0,1,0,1,0,1,0,0,0,5,0,1],
     [1,5,0,0,0,1,5,4,0,4,3,4,0,5,0,1],
     [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
     [1,1,1,1,7,1,1,1,7,1,7,1,1,1,1,1],
     3, 1],
    // ステージ 10
    [[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
     [1,4,4,4,4,4,0,0,0,0,0,4,4,4,4,1],
     [1,4,4,4,4,4,0,4,0,4,0,4,4,4,4,1],
     [1,4,4,4,4,4,1,0,0,0,1,4,4,4,4,1],
     [1,4,4,4,4,1,0,0,0,0,0,1,4,4,4,1],
     [1,4,4,4,1,0,0,0,0,0,0,0,1,4,4,1],
     [1,4,4,1,0,0,5,0,0,0,5,0,0,1,4,1],
     [1,4,4,4,1,0,4,0,0,0,4,0,1,4,4,1],
     [1,4,4,4,4,1,0,4,0,4,0,1,4,4,4,1],
     [1,4,4,4,4,4,1,0,0,0,1,4,4,4,4,1],
     [1,4,4,4,4,4,4,1,0,1,4,4,4,4,4,1],
     [1,4,4,4,4,4,4,4,3,4,4,4,4,4,4,1],
     [1,1,1,1,1,1,1,1,7,1,1,1,1,1,1,1],
     8, 1],
    // ステージ 11
    [[1,1,1,1,6,1,1,1,6,1,1,1,6,1,1,1],
     [1,0,0,0,0,0,1,0,0,0,0,2,0,0,0,1],
     [1,0,5,0,0,0,0,4,0,1,5,0,0,5,0,1],
     [1,5,0,2,5,0,1,0,0,0,2,0,0,0,0,1],
     [8,0,0,0,0,0,1,0,0,5,1,1,1,0,0,9],
     [1,0,1,1,1,1,5,0,5,0,0,0,0,0,4,1],
     [1,1,0,5,0,5,0,1,0,0,0,1,0,1,0,1],
     [8,0,0,0,0,0,1,0,0,0,0,0,1,0,0,9],
     [1,4,1,0,0,0,0,0,0,3,0,0,0,0,4,1],
     [1,0,5,0,0,0,0,0,0,0,1,1,1,0,0,1],
     [1,0,0,1,1,1,1,3,0,0,0,0,0,0,0,1],
     [1,0,0,0,0,0,0,0,0,0,0,4,0,0,0,1],
     [1,7,1,1,1,1,1,1,1,1,1,1,1,7,1,1],
     4, 9],
    // ステージ 12
    [[1,6,1,1,1,6,1,1,6,6,1,1,6,1,6,1],
     [1,0,5,5,5,0,0,0,0,0,0,0,0,1,0,1],
     [8,0,1,0,1,0,0,0,0,0,0,4,2,1,0,9],
     [1,0,5,5,2,0,0,5,0,0,0,2,0,5,0,1],
     [1,0,4,0,5,0,0,0,4,0,0,1,1,0,2,1],
     [1,2,0,5,0,4,5,0,2,5,1,0,0,0,0,1],
     [1,0,5,0,5,0,5,4,0,0,0,1,0,5,0,1],
     [1,3,0,5,0,1,1,0,5,5,1,0,0,0,4,1],
     [1,0,5,0,5,0,0,5,1,1,5,5,5,5,0,1],
     [1,0,4,0,5,0,0,1,0,0,0,5,0,5,0,1],
     [1,0,5,5,5,0,4,0,4,0,0,5,0,3,0,1],
     [1,0,5,0,5,0,0,1,0,0,0,1,5,0,0,1],
     [1,7,1,1,1,1,1,1,1,1,1,1,1,1,7,1],
     7, 10],
    // ステージ 13
    [[1,1,1,1,1,1,1,1,1,1,1,1,1,1,6,1],
     [1,0,5,1,0,0,0,0,0,0,0,0,0,0,0,1],
     [8,0,0,1,0,4,5,1,1,1,1,1,1,1,0,1],
     [1,1,0,5,0,0,1,0,5,5,5,0,5,5,0,1],
     [1,0,1,1,4,1,0,0,0,0,0,5,0,0,4,9],
     [1,0,5,1,0,1,0,4,0,4,0,2,0,0,0,1],
     [1,0,5,5,4,1,1,1,1,1,1,5,4,0,0,1],
     [1,0,0,0,5,5,0,0,0,5,0,1,4,0,1,1],
     [1,3,0,1,0,0,5,1,1,0,0,1,0,1,0,1],
     [1,0,0,0,1,0,1,5,4,0,5,1,0,5,5,9],
     [8,0,0,0,0,1,0,0,0,0,0,1,0,5,0,1],
     [1,0,3,0,0,0,0,0,0,0,0,1,3,5,0,1],
     [1,7,7,1,1,1,1,1,1,1,1,1,7,1,1,1],
     9, 1],
    // ステージ 14
    [[1,1,1,6,1,6,1,1,1,1,1,1,1,1,1,1],
     [1,0,0,0,0,0,0,0,0,0,5,5,5,5,5,1],
     [1,0,5,2,2,0,1,0,1,0,1,0,0,0,1,1],
     [8,0,5,0,0,0,1,0,1,0,0,0,0,1,5,1],
     [1,5,5,0,0,0,1,0,1,0,0,0,5,5,1,1],
     [1,0,1,1,1,4,1,0,1,3,0,0,0,5,5,9],
     [1,5,5,0,0,0,1,0,1,0,3,0,0,0,5,1],
     [1,0,0,0,0,0,1,0,1,0,0,3,0,0,5,1],
     [1,0,0,0,0,5,1,0,1,0,0,0,3,0,5,1],
     [1,0,0,0,3,5,1,0,1,0,0,0,0,3,5,1],
     [1,0,0,3,0,5,1,0,1,0,0,0,0,0,5,1],
     [1,0,3,0,0,5,0,0,1,0,0,0,0,0,5,1],
     [1,1,7,7,7,1,1,1,1,7,7,7,7,7,1,1],
     7, 1],
    // ステージ 15
    [[1,6,6,1,1,1,6,6,6,1,1,1,1,1,6,1],
     [1,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1],
     [1,0,2,0,5,0,0,0,2,5,1,5,0,5,0,1],
     [1,0,5,2,0,0,1,2,0,0,0,0,0,0,5,1],
     [8,0,0,0,0,0,0,0,5,1,0,0,4,0,0,9],
     [1,1,5,4,4,0,0,1,0,0,0,0,0,0,5,1],
     [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
     [1,0,0,0,5,0,0,0,0,0,0,3,2,0,0,1],
     [1,0,0,3,0,4,0,0,0,0,0,0,5,0,0,1],
     [1,5,1,0,0,0,5,0,3,0,4,0,5,3,0,1],
     [1,0,0,0,5,0,0,0,0,0,3,4,0,0,0,1],
     [8,0,1,0,4,0,0,0,0,0,0,0,0,0,0,9],
     [1,1,1,7,1,1,1,1,7,7,1,1,1,7,7,1],
     10, 1]
  ];

  map = [];
  map_elem = [];

  elem_items = document.getElementById("items");
  elem_ball = document.getElementById("ball");
  elem_opening = document.getElementById("opening");
  elem_prompt = document.getElementById("prompt");
  elem_side = document.getElementById("side");
  elem_stage = document.getElementById("stage");
  elem_balls = document.getElementById("balls");
  elem_start = document.getElementById("start");
  elem_clear = document.getElementById("clear");

  // 文字サイズ調整
  document.styleSheets[0].insertRule(".text{transform:scaleX("
                                       + String(224/* 14*16 */ / elem_prompt.clientWidth) + ")}", 0);

  elem_ball.style.backgroundImage = "url(" + ball_image + ")";

  // オープニング画面 “LOCK'N”
  s_x = [ 0, 0, 0, 0, 0, 0, 1, 2, 3, 6, 7, 5, 8, 5, 8, 5, 8, 5, 8, 6, 7,11,12,10,13,10,10,10,13,11,12,
         15,18,15,18,15,17,15,16,15,17,15,18,19,20,20,21,24,21,24,21,22,24,21,23,24,21,24,21,24];
  s_y = [ 0, 1, 2, 3, 4, 5, 5, 5, 5, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 0, 0, 1, 1, 2, 3, 4, 4, 5, 5,
          0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5,-3,-3,-2, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5];
  for(i = 0; i < s_x.length; i++) {
    elem = document.createElement("DIV");
    elem.style.position = "absolute";
    elem.style.left = String((13 + s_x[i]) << 4) + "px";
    elem.style.top = String((7 + s_y[i]) << 4) + "px";
    elem.style.width = elem.style.height = "16px";
    elem.style.backgroundImage = "url(" + small_image + ")";
    elem.style.backgroundSize = "16px";
    elem.style.imageRendering = "crisp-edges";
    elem.style.imageRendering = "pixelated";

    elem_opening.appendChild(elem);
  }

  // オープニング画面 最下部のハード ブロック追加
  document.getElementById("floor").style.backgroundImage = "url(" + images[1] + ")";

  elem_side.style.backgroundImage = "url(" + small_image + ")";

//-->
</SCRIPT>

</BODY>

</HTML>