Skip to content

Instantly share code, notes, and snippets.

View luizbills's full-sized avatar
I may be slow to respond.

Luiz Bills luizbills

I may be slow to respond.
View GitHub Profile
@luizbills
luizbills / code.js
Created March 28, 2025 15:40
Confetti emitter for Litecanvas
// based on https://play.kaplayjs.com/?example=confetti
litecanvas({})
function init() {
loadScript('https://cdn.jsdelivr.net/npm/[email protected]/build/stats.min.js', () => {
stats = new Stats()
document.body.appendChild(stats.dom)
listen('before:update', () => stats.begin())
listen('after:draw', () => stats.end())
@luizbills
luizbills / readme.md
Created March 11, 2025 14:25
Random webrings sites in bookmarklet

Create a new bookmark in your browser:

  • Name: Random Page
  • URL: javascript:%28%28%29%3D%3E%7Blet%20n%3D%5B%22https%3A//baccyflap.com/noai/%3Frnd%22%2C%22https%3A//geekring.net/site/6/random%22%2C%22https%3A//webring.dinhe.net/random%22%2C%22https%3A//webring.theoldnet.com/random/navigate%22%5D%3Bwindow.open%28n%5BMath.random%28%29*n.length%7C0%5D%29%7D%29%28%29%3B

Javascript code decoded:

@luizbills
luizbills / code.js
Created March 10, 2025 17:16
DOOM fire in Litecanvas
// based on https://fabiensanglard.net/doom_fire_psx/
const FIRE_WIDTH = 128;
const FIRE_HEIGHT = 128;
litecanvas({
width: FIRE_WIDTH,
})
const firePalette = [0,0,0,0,0,0,10,10,10,10,10,10,10,10,4,4,4,4,4,4,4,4,5,5,5,5,5,5,3,3,3,3],
@luizbills
luizbills / code.html
Created February 24, 2025 16:52
How to make an html5 canvas center horizontally and vertically
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<style>
html,
body {
height: 100%;
}
@luizbills
luizbills / runn
Last active February 23, 2025 14:34
Bash script to run a command N times
#!/usr/bin/env bash
for (( i = 0; i < $1; i++ )); do
eval "${@:2}"
done
@luizbills
luizbills / code.js
Last active February 18, 2025 13:10
JavaScript Game Loop
// based on https://www.gafferongames.com/post/fix_your_timestep/
const TARGET_FPS = 60
const dt = 1/TARGET_FPS
let _accumulated = 0
let _lastFrameTime = performance.now()
/**
* @param {number} now
*/
@luizbills
luizbills / code.js
Last active February 18, 2025 13:11
Simple shmup demo in Litecanvas
let scale = 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, [
@luizbills
luizbills / code.js
Created February 7, 2025 18:47
Tutorial: Simple Sprite Frame Animation
let anim = {}
litecanvas()
function init() {
// each frame of the animation
// for this example, lets create 3 circles
anim.frames = [
createFrame(3),
createFrame(4),
@luizbills
luizbills / code.js
Created February 3, 2025 18:43
Litecanvas - Draw a rect using dithering pattern
/**
* @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)
}
}
@luizbills
luizbills / code.js
Last active January 27, 2025 12:44
Litecanvas Plugin: LOSPEC color palette loader
function pluginLospecPaletteLoader(engine, { colors }, { cache = false }) {
if (!engine.LOADING) {
engine.setvar("LOADING", 0);
}
const cachePrefix = "lospec-palette-";
const updateColors = (palette) => {
const len = palette.length;
colors.length = 0;
for (let i = 0; i < len; i++) {
colors[i] = "#" + palette[i];