PlanetJs/utils.js
2022-10-04 22:13:17 +03:00

22 lines
421 B
JavaScript

let dt = 0;
let oldTime = 0;
export function clearScreen(ctx, color) {
ctx.fillStyle = color;
ctx.fillRect(0, 0, ctx.canvas.clientWidth, ctx.canvas.clientHeight);
}
export function random(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
export function getDeltaTime(time) {
dt = time - oldTime;
oldTime = time;
if (dt != 0) {
dt = dt * 0.001;
}
return dt;
}