인간 스톱워치: 두 판 사이의 차이

리버티게임, 모두가 만들어가는 자유로운 게임
백괴게임>Riemann
잔글편집 요약 없음
백괴게임>Riemann
잔글편집 요약 없음
19번째 줄: 19번째 줄:
<div class="button" id="stop" style="display: none;">Stop</div>
<div class="button" id="stop" style="display: none;">Stop</div>
<div id="scoreboard">점수: <span id="score">0</span></div>
<div id="scoreboard">점수: <span id="score">0</span></div>
<div id="console">환영합니다. 위의 Start 버튼이나 '''아무 키'''를 눌러 주세요.</div>
<div id="console">환영합니다. 위의 '''Start''' 버튼이나 '''아무 키'''를 눌러 주세요.</div>
</div>
</div>
[[분류:백괴게임]]
[[분류:백괴게임]]

2018년 3월 21일 (수) 18:25 판




sc = 0;

cb = 0;

bl = false; $(document.body).on("keydown", function(ev) {

 if(ev.which == 13) {
   if (bl == false) {
 	  bl = true;
     startF();
   } else {
     bl = false;
     stopF();
   }
 }

});

$("#msgame-start").on("click", function() {

 bl = true;

startF(); });

$("#msgame-stop").on("click", function() {

 bl = false;

stopF(); });

function startF() {

 obj = Math.floor(Math.random() * 5) + 5;
 $("#msgame-start").css("display", "none");
 $("#msgame-stop").css("display", "block");
 it = new Date();
 si = setInterval(clockUpdate, 20);
 $("#msgame-console").text(obj + " 초를 세세요.");

}

function stopF() {

 $("#msgame-clockText").css("display", "inline");
 $("#msgame-stop").css("display", "none");
 $("#msgame-start").css("display", "block");
 clearInterval(si);
 ie = new Date();
 ifin = ie - it;
 $("#msgame-clockText").text(toMilliSec(ifin));
 finished(obj, ifin);

}

function clockUpdate() {

 ic = new Date();
 id = ic - it;
 ii = toMilliSec(id);
 $("#msgame-clockText").text(ii);
 if (obj * 1000 - id < 500 * cb && cb > 4 ) {
   $("#msgame-clockText").fadeOut();
 }

}

function toMilliSec(d) {

 return (Math.floor(d / 1000) + "\"" + ("" + d % 1000).padStart(3, "0")).padStart(6, "0");

}

function finished(a, b) {

 ath = a * 1000;
 if (ath == b) {
   cbm = Math.floor(Math.pow(800, (1 + cb / 10)));
   $("#msgame-console").text("정확하시군요. " + cbm + " 점 드리겠습니다.");
   sc += cbm;
   cb += 1;
 } else if (Math.abs(ath - b) < 100) {
   cbm = Math.floor(Math.pow((500 / Math.abs(ath - b)), (1 + cb / 10)));
   $("#msgame-console").text("정확하시군요. " + cbm + " 점 드리겠습니다.");
   sc += cbm;
   cb += 1;
 } else {
   $("#msgame-console").text("안타깝습니다. 조금 더 노력해 보세요!");
   cb = 0;
 }
 $("#msgame-score").text(sc);
 $("#msgame-combo").text(cb);

} 시간을 천 분의 일 초까지 정확하게 지키는 습관을 들여봅시다. (주의: 컴퓨터 사양에 따라 천 분의 일 초까지는 의미가 없을 수도 있습니다.)

0.1초 이내로 근접하면 5점, 0.05초 이내는 10점, 0.01초 이내는 30점을 드립니다. 점수가 100점이 넘기 시작하면 게임 도중 시계가 사라집니다.

 00"000 

Start
점수: 0
환영합니다. 위의 Start 버튼이나 아무 키를 눌러 주세요.