const consoleCode = document.querySelector("#console-code"); export const width = 480; export const height = 360; const canvas = document.querySelector("canvas"); canvas.width = width; canvas.height = height; const cx = canvas.getContext("2d"); cx.imageSmoothingEnabled = false; export function rgb(red, green, blue) { return `rgb(${red}, ${green}, ${blue})`; } export function clear(color) { cx.fillStyle = color; cx.fillRect(0, 0, width, height); } export function drawRect(x, y, width, height, color) { cx.fillStyle = color; cx.fillRect(x, y, width, height); } export function println(msg) { consoleCode.textContent += `${msg}\n`; } export function startGameLoop(loopFunction) { let before = Date.now(); setInterval(() => { const now = Date.now(); const deltaT = (now - before) / 1000; before = now; loopFunction(deltaT); }, 16); }