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

리버티게임, 모두가 만들어가는 자유로운 게임
백괴게임>Riemann
(새 문서: {{플러그인|사용자:Riemann/msgame}} 분류:백괴게임)
 
백괴게임>Riemann
편집 요약 없음
1번째 줄: 1번째 줄:
{{#css:
.button {background: black; color: white; border-radius: 5px; text-align: center; padding: 5px; grid-column: 1 / 3;}
#clock, #scoreboard {vertical-align: middle; text-align: center;}
#clock, #console, #scoreboard {background: white; color: black; border: 3px solid black; font-family: monospace; padding-left: 5px; padding-right: 5px;}
}}
{{플러그인|사용자:Riemann/msgame}}
{{플러그인|사용자:Riemann/msgame}}
 
<div style="display: grid; width: 100%; grid-template-columns: 80px 1fr; grid-template-rows: unset;">
<div id="clock" style="grid-column: 1 / 3;">
<h2>
&nbsp;<span id="clockText">00"000</span>&nbsp;
</h2>
</div>
<div class="button" id="start">Start</div>
<div class="button" id="stop" style="display: none;">Stop</div>
<div id="scoreboard">점수: <span id="score">0</span></div>
<div id="console">Placeholder</div>
</div>
[[분류:백괴게임]]
[[분류:백괴게임]]

2018년 3월 21일 (수) 17:53 판




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);

}

 00"000 

Start
점수: 0
Placeholder