-1
매일 9시에서 5시 30 분 사이에 벌어 들인 돈을 늘리려고합니다.하루 중 특정 시간 동안 숫자가 증가합니다.
그래서 오늘 밤 5시 30 분 밤에 '돈 벌기'가 9시 30 분까지 중지되고 5시 30 분까지 초당 증가합니다.
여기까지 지금까지의 내용이 있습니다. 및 추가 5시 반 일상 -
이
//Different toolkits for different browsers. If none work, set to null.
var animFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || null;
//Creating instances of canvas and the canvas' 2d drawing, allowing us to manipulate it in JS
var c = document.getElementById("canvas");
var ctx = c.getContext("2d");
var startDate = new Date(2016, 07, 01, 00, 00, 00);
var currentDate = 0;
var valuePerSec = 0.00088776157;
var valuePerSecTax = 0.00307364672;
var todaysDate = new Date();
var todaysWorkStart = new Date(todaysDate.getFullYear(), todaysDate.getMonth(), todaysDate.getDay(), 09, 00, 00);
var yesterday = new Date(todaysDate.getFullYear(), todaysDate.getMonth(), todaysDate.getDay() - 1, 09, 00, 00);
//Loops through to draw the graphics. this function is called through the recursiveAnim function
function mainLoop() {
clearScreen();
var currentTime = new Date().getTime();
var timeSinceDate = Math.floor((currentTime - startDate.getTime())/1000);
var yesterdaySinceDate = Math.floor((yesterday.getTime() - startDate.getTime())/1000);
//var daysSinceBegin = //
textPart(timeSinceDate, yesterdaySinceDate);
}
function textPart(timeSinceDate, yesterdaySinceDate) {
ctx.fillStyle = "#008000";
ctx.font = "70px Helvetica";
ctx.fillText("£" + (timeSinceDate * valuePerSec).toFixed(2), 150, 260);
ctx.fillText(Math.round(yesterdaySinceDate/86400), 250, 150);
ctx.font = "20px Helvetica";
ctx.fillText(yesterday, 150, 400);
ctx.fillText("money", c.width - 175, c.height - 6);
}
function clearScreen() {
ctx.fillStyle = "#33cc33";
ctx.fillRect(0, 0, c.width, c.height);
}
//This loops the animation frames for creating animation
function recursiveAnim() {
mainLoop();
animFrame(recursiveAnim);
}
animFrame(recursiveAnim);
<html>
<head>
<title>money</title>
</head>
<body>
<canvas id="canvas" width="600" height="500" style="border:1px solid #000000"></canvas>
<script src="game.js"></script>
</body>
</html>
그리고 문제는 무엇인가? – AxelH
@AxelH 원본을 업데이트했습니다. –
코드에 어떤 조건도 표시되지 않으므로 "유료 시간"인지 여부를 확인하기 위해 실제 시간을 확인하지 않습니다. 해결책에 대해 생각해 봤어? – AxelH