Skip to content

Instantly share code, notes, and snippets.

View luizbills's full-sized avatar

Luiz Bills luizbills

View GitHub Profile
@luizbills
luizbills / code.js
Created May 4, 2026 20:15
extra sound functions for Litecanvas
/**
* @param {number} frequency
* @param {number} [duration] in seconds
* @param {number} [wavetype] 0 (sine), 1 (triangle), 2 (saw), 3 (tan), 4 (noise) or 5 (square)
* @param {volume}
*/
function beep (frequency, duration = 0.1, wavetype = 1, volume = .5) {
sfx([, 0, frequency, 0.01, duration, 0.01, wavetype], 0, volume)
}
@luizbills
luizbills / 10print.js
Last active May 3, 2026 15:19
Commodore 64 BASIC one-liner "10 PRINT CHR$(205.5+RND(1)); : GOTO 10" in Litecanvas
litecanvas()
framerate(1)
draw()
function draw() {
cls(3)
block = randi(10,100)
for (let y = 0; y < H; y += block) {
for (let x = 0; x < W; x += block) {
@luizbills
luizbills / code.js
Created April 27, 2026 13:56
Simple loading screen #litecanvas
litecanvas({})
function draw() {
cls(0)
textfont("monospace")
textalign("center", "middle")
const dots = ".".repeat(wrap(T*1.5,0,5)+1)
text(W/2, H/2, "LOADING\n"+dots)
@luizbills
luizbills / code.js
Created April 24, 2026 12:50
Basic physics simulation
//! Based on https://slicker.me/javascript/physics/physics_engine.htm
// Vector utilities
class Vec {
constructor(x=0, y=0) {
this.x = x;
this.y = y;
}
add(v) {
return new Vec(this.x + v.x,this.y + v.y);
@luizbills
luizbills / code.js
Created February 11, 2026 14:48
Top-down movement like old pokemons games #litecanvas
litecanvas({
width: 8*8,
autoscale: 3
})
const p = {
x: 0,
y: 0,
dx: 0,
dy: 0,
@luizbills
luizbills / code.js
Created February 1, 2026 23:20
Memory with Litecanvas
litecanvas({})
let cards = [], sprites, opens = [], timer = 0, score = 0
const
SIZE = 64,
OFFSET = SIZE/1.5,
CLOSED_CARD = paint(SIZE, SIZE, () => {
cls(2)
})
@luizbills
luizbills / code.js
Created November 18, 2025 01:05
Draw random asteroid shape in Litecanvas
litecanvas({})
function init() {
framerate(1)
}
function draw() {
cls(0)
// linedash([10,5])
// circ(W/2, H/2, 150, 2)
@luizbills
luizbills / code.js
Created November 13, 2025 17:34
Rect with animated dashed border in Litecanvas
litecanvas({
width: 320,
autoscale: false
})
let offset = 0
let pos = vec(10, 10)
function tapped(x, y) {
vecSet(pos, x, y)
@luizbills
luizbills / code.js
Created October 4, 2025 13:26
Animated background using Litecanvas
let pos = {},
speed = 100,
ts = 32,
bg
litecanvas({
width: 320,
autoscale: 0
})
@luizbills
luizbills / .htaccess
Last active October 27, 2025 21:39
Hotlink protection for Apache or OpenLiteSpeed
# BEGIN HOTLINK PROTECTION
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?bing.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yahoo.com [NC]
RewriteRule \.(jpg|jpeg|png|gif|svg)$ - [NC,F,L]