사용자:Bd3076/UncyBeat/LevelMaker/plugin
< 사용자:Bd3076 | UncyBeat | LevelMaker
이 플러그인에 대한 설명문서는 사용자:Bd3076/UncyBeat/LevelMaker/plugin/설명문서에서 만들 수 있습니다.
// 이부분에 코드 입력 // var getParameters = function (paramName) { var returnValue; var url = location.href; console.log(url); if(url[8] == 'f'){ return 0; } var parameters = (url.slice(url.indexOf('?') + 1, url.length)).split('&'); for (var i = 0; i < parameters.length; i++) { var varName = parameters[i].split('=')[0]; if (varName.toUpperCase() == paramName.toUpperCase()) { returnValue = parameters[i].split('=')[1]; return decodeURIComponent(returnValue); } } }; function updateURLParameter(url, param, paramVal){ var newAdditionalURL = ""; var tempArray = url.split("?"); var baseURL = tempArray[0]; var additionalURL = tempArray[1]; var temp = ""; if (additionalURL) { tempArray = additionalURL.split("&"); for (var i=0; i<tempArray.length; i++){ if(tempArray[i].split('=')[0] != param){ newAdditionalURL += temp + tempArray[i]; temp = "&"; } } } var rows_txt = temp + "" + param + "=" + paramVal; return baseURL + "?" + newAdditionalURL + rows_txt; } function Queue(){ this.arr = []; this.s = 0; this.e = 0; this.size = 0; this.front = function(){ return arr[s]; } this.pop = function(){ s++; size--; return; } this.push = function(k){ arr[e++] = k; size--; return; } this.empty = function(){ return size==0; } } var timer = 0; function calculateTimer(){ timer += 1; } var cvs = document.getElementById('spanArea'); cvs.innerHTML = "<canvas width='720' height='720' id='spanCanvas'></canvas>" var canvas = document.getElementById('spanCanvas'); var ctx = canvas.getContext('2d'); var level = getParameters('level'); const levelCount = 1; const levelNames = [ 'Dreams' ]; const levelMusicLink = [ 'https://k003.kiwi6.com/hotlink/9f13ktbumx/bensound-dreams.mp3' ]; function clearCanvas(){ ctx.clearRect(0, 0, 720, 720); } function makeGameArea(){ clearCanvas(); ctx.strokeStyle = "black"; ctx.strokeRect(20, 20, 680, 680); for(var i=0; i<5; i++){ for(var j=0; j<5; j++){ ctx.strokeRect(40+i*132, 40+j*132, 112, 112); } } } function playGameMusic(){ console.log(level); var audioElement = new Audio(levelMusicLink[level]); var audio = audioElement.play(); audioElement.onended = function(){ setTimeout(levelEnd, 3000); }; setInterval(calculateTimer, 50); } var x = 2; var y = 2; var color = 0; var perfect = 0; var good = 0; var miss = 0; var score = 0; var lvData; function levelEnd(){ location.href = updateURLParameter(location.href, levelData, lvData); } var noteTimer = new Array(5); for(var i=0; i<5; i++){ noteTimer[i] = new Array(5); for(var j=0; j<5; j++){ noteTimer[i][j] = -400; } } var noteColor = new Array(5); for(var i=0; i<5; i++){ noteColor[i] = new Array(5); } function showCursor(){ for(var i=0; i<5; i++){ for(var j=0; j<5; j++){ ctx.fillStyle = color==0?"red":"blue"; if(noteTimer[i][j] > 0){ ctx.fillRect(40+i*132, 40+j*132, (400-noteTimer[i][j]) * 112 / 400, 112); } else{ ctx.clearRect(40+i*132, 40+j*132, 112, 112); } if(i==x && j==y){ ctx.strokeStyle = color==0?"red":"blue"; } else{ ctx.strokeStyle = "black"; } ctx.strokeRect(40+i*132, 40+j*132, 112, 112); } } } function onKeyDown(e){ var ek = e.keyCode; console.log(ek); if(37 <= ek && ek <= 40){ if(ek == 37){ if(x!=0) x--; } else if(ek==38){ if(y!=0) y--; } else if(ek==39){ if(x!=4) x++; } else if(ek==40){ if(y!=4) y++; } console.log(x + "and" + y); lvData = lvData + timer + '|' + x + '|' + y + '|' + color + '/'; } else if(ek==32){ color = !color; } } window.addEventListener("keydown", onKeyDown, false); var startIndex = 0; var endIndex = 0; var data; var dataLength; function playGame(){ makeGameArea(); setInterval(showCursor, 30); setTimeout(playGameMusic, 3000); } playGame(); // 여기까지 코드 입력 //