//////////////////////////////////////////////////////////////////////// MTB 音ベーダー　(06.03.06-)////////////////////////////////////////////////////////////////////////	History:////	06.03.06	作成開始////////////////////////////////////////////////////////////////////////// バージョン作成function makeVersion(){	return( "(C)2006 " + myName() );}//// グローバル変数var	gQCount=9;						// 表示音符数var gQNotes = new Array(gQCount);	// スコア内のデータvar gGameRun=false;					// ゲーム中？var gIntervalTime=2000;				// ゲームスピード（単位ms）var gPoint=0;						// 得点var gIgnoreOct=false;				// オクターブを無視するvar gBassNotes=false;				// 低音部の音符も含むvar gTopNote;						// 左端の音符//// ページ生成// ゲーム操作部HTML作成function makeGemePanel(){	var theSrc='';		theSrc += makeFaceIcon();	theSrc += '<input type="text" size="30" name="MESSAGE">';	theSrc += '&nbsp;&nbsp;';	theSrc += 'スコア <input type="text" size="10" name="POINT">';	theSrc += '&nbsp;&nbsp;';	theSrc += '<img src="../img/game/pad10.gif" name="GAMEOVER" width=200 height=20>'	theSrc += '<br><br>';	theSrc += '&nbsp;&nbsp;';	theSrc += 'スピード <select name="SPEED" onChange="setSpeed(this.form)">';	theSrc += '<option>LOW';	theSrc += '<option>MID';	theSrc += '<option>HIGH';	theSrc += '</select>';	theSrc += '&nbsp;&nbsp;';	theSrc += '<input type="checkbox" name="SW_OCT" onClick="doOption()">';	theSrc += 'オクターブ無視';	theSrc += '&nbsp;&nbsp;';	theSrc += '<input type="checkbox" name="SW_BASS" onClick="doOption()">';	theSrc += '低音部も含む';	theSrc += '&nbsp;&nbsp;';	theSrc += '<input type="button" value="スタート" onClick="doStart()">';	theSrc += '&nbsp;&nbsp;';	theSrc += '<input type="button" value="リセット" onClick="doReset()">';	return( theSrc );}//// イベントハンドラ// ページのロード時処理function doOnload(){	// １回だけの初期化	makeRandNoteArray(4,5); // 2-5	preloadScoreImg();	preloadScoreGuideImg();	preloadGameImg();	doReset();}// タイムアウトハンドラfunction doTimeout(){	if( gGameRun )	{		doQuestion();		setTimeout( "doTimeout()", gIntervalTime );	}}// 鍵盤がクリックされたときの処理function doKeyClick( note ){	//　鍵盤	if( gGameRun ) // テスト中	{		doAnswer( note );		updateScore();	}	else // テスト中でない	{		//playNote( note );	}}// 鍵盤がマウスオーバーされたときの処理function doKeyOver( note ){	if( gGameRun )			{ dispScoreGuide( note ); }	if( isWhiteKey(note) )			{ dispNoteName( note ); }}// スタートボタン処理function doStart(){	doReset();	gGameRun = true;	setTimeout( "doTimeout()", 0 );	showMessage( "鍵盤をクリックしてください" );}// リセットボタン処理function doReset(){	// 変数初期化	for( var i=0; i<gQCount; i++ )	{		gQNotes[i] = "";	}	gGameRun = false;	gPoint = 0;	// 表示初期化	dispClefImage("");	showGameOver( false );	updateScore();	updatePanel();	showMessage( "スタートを押して下さい" );}// スピードセレクタ処理function setSpeed( theForm ){	var index = theForm.SPEED.selectedIndex;	if( index == 0 ) // LOW	{		gIntervalTime = 2000;	}	else if( index == 1 ) // MID	{		gIntervalTime = 1000;	}	else if( index == 2 ) // HIGH	{		gIntervalTime = 500;	}}// オプションボタン処理function doOption(){	gIgnoreOct = document.FORM_MAIN.SW_OCT.checked;	gBassNotes = document.FORM_MAIN.SW_BASS.checked;	if( gBassNotes )	{		makeRandNoteArray(2,5); // 高音部	}	else	{		makeRandNoteArray(4,5); // 全域	}}// パネル更新function updatePanel(){	document.FORM_MAIN.POINT.value = gPoint;	document.FORM_MAIN.SW_OCT.checked = gIgnoreOct;	document.FORM_MAIN.SW_BASS.checked = gBassNotes;}//// ユーティリティfunction showMessage( str ){	document.FORM_MAIN.MESSAGE.value = str;}//// 初期化//// ゲーム進行処理// 音名表示function dispNoteName( note ){	if( note == "" )		{ document.FORM_MAIN.NOTENAME.value = ""; }	else if( gIgnoreOct )		{ document.FORM_MAIN.NOTENAME.value = note.charAt(0); }	else		{ document.FORM_MAIN.NOTENAME.value = note; }}// スコアの更新function updateScore(){	for( var i=0; i<gQCount; i++ )	{		dispScoreNote( gQNotes[i], i );	}}// 出題するfunction doQuestion(){	gTopNote = gQNotes[0];	for( var i=0; i<gQCount-1; i++ )	{		gQNotes[i] = gQNotes[i+1];	}	gQNotes[i] = getRandomNote();	updateScore();	if( gTopNote != "" ) // ゲームオーバー	{		doFinish();	}}// 回答function doAnswer( note ){	var judge;	var isFailed=true;	for( var i=0; i<gQCount; i++ )	{		if( gIgnoreOct )				{ judge = ( gQNotes[i].charAt(0) == note.charAt(0) ); }		else				{ judge = ( gQNotes[i] == note ); }		//		if( judge ) // 当たり		{			gQNotes[i] = "";			gPoint++;			isFailed = false;		}	}	if( isFailed )			{ gPoint--; }	updatePanel();}// ゲームオーバー画像表示function showGameOver( sw ){	if(sw)	document.GAMEOVER.src = getGameImgPath("gameover");	else	document.GAMEOVER.src = getShareImgPath("pad10");}// ゲーム終了時の処理function doFinish(){	dispScoreGuide("");	dispClefImage( gTopNote );	showGameOver( true );	showMessage( "スタートを押すと再開します" );	gGameRun = false;}