The stats.js
library provides a simple info box that will help you monitor your code performance.
- Add the
stats.js
library in your HTML
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width" /> | |
<style> | |
html, | |
body { | |
height: 100%; | |
} |
#!/usr/bin/env bash | |
for (( i = 0; i < $1; i++ )); do | |
eval "${@:2}" | |
done |
// based on https://www.gafferongames.com/post/fix_your_timestep/ | |
const TARGET_FPS = 60 | |
const dt = 1/TARGET_FPS | |
const eventData = { deltaTime: dt, elapsed: 0 } | |
let _accumulated = 0 | |
let _lastFrameTime = performance.now() | |
requestAnimationFrame(gameLoop); | |
/** |
const gameScale = 2 | |
litecanvas({ | |
width: 640, | |
height: 480, | |
autoscale: false, | |
}) | |
// Art Code: 8x8/# # 6 6 6 6 # # # # 6 6 6 6 # # # # 6 6 6 6 # # 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 # # 6 6 6 6 6 6 # # 6 6 6 | |
const ship = paint(8, 8, [ |
let anim = {} | |
litecanvas() | |
function init() { | |
// each frame of the animation | |
// for this example, lets create 3 circles | |
anim.frames = [ | |
createFrame(3), | |
createFrame(4), |
/** | |
* @version 1.0.0 | |
*/ | |
function rectdither(x, y, w, h, color1, color2) { | |
for (let dy = 0; dy < h; dy++) { | |
for (let dx = 0; dx < w; dx++) { | |
const c = (dx + dy) % 2 === 0 ? color1 : color2 | |
rectfill(x + dx, y + dy, 1, 1, c) | |
} | |
} |
function pluginLospecPaletteLoader(engine, { cache = false }) { | |
if (!engine.LOADING) { | |
engine.setvar("LOADING", 0); | |
} | |
const cachePrefix = "lospec-palette-"; | |
const updateColors = (palette) => { | |
engine.pal(palette.map((c) => '#' + c)) | |
engine.setvar("PALETTE_SIZE", palette.length); | |
}; |
let x, y, speed | |
litecanvas() | |
function init() { | |
x = W/2 | |
y = H/2 | |
speed = 250 | |
} |
/** | |
* @version 1.2.0 | |
* @see https://gist.github.com/luizbills/12ee7520d89e61109897010df8d3a5a5 | |
*/ | |
function pluginReset(engine, config = {}) { | |
return { | |
reset(hard = false) { | |
const settings = engine.stat(0) | |
settings.canvas = engine.canvas() | |
engine.quit() |
The stats.js
library provides a simple info box that will help you monitor your code performance.
stats.js
library in your HTML