-1
毎日9時から5時30分に稼いだお金の量を増やしたいと思っています。特定の時間帯の数字を増やすjavascript
本質的に、夜の5時30分の場合、「お金の稼ぎ」は翌日の9:30まで停止し、5:30まで毎秒増分します。
これまでの説明はここにあります。
//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>
これは私が9時00分の時間の間、毎秒だけ増分に「valuePerSecTax」したい、「valuePerSec」はその日の秒ごとにカウント - 5時30分日常とそれを追加'startDate'以来毎日獲得している金額に相当します。
そして、問題は何ですか? – AxelH
@AxelHオリジナルを更新しました。 –
あなたのコードには何の条件も見当たらないので、あなたが「支払った時間」にいるかどうかを実際に確認することはできません。あなたは解決策について考えましたか? – AxelH