Circle lockpick
Try to get all the squares aligned on the line. Move the mouse to lock them into place.
Made as an example of p5.js's screenToWorld function.
function setup() {
createCanvas(600, 600);
angleMode(DEGREES)
rectMode(CENTER)
for (let i = 0; i < 4; i ++) {
a[i] = random(360)
}
}
let a = []
let d = 0
function draw() {
background(220);
noFill()
fill(255, 255 - d * 4)
push()
fill(0)
//text(d, 100,100)
pop()
d = 0
translate(300, 300)
circle(0, 0, 50)
line(25, 0, 225, 0)
for (let i = 0; i < 4; i ++) {
d += abs((a[i] + 270) % 360 - 180)
circle(0, 0, 100 * (i + 1) + 50)
push()
rotate(a[i])
translate(0, 50 * (i + 1))
let p = screenToWorld(mouseX, mouseY)
if (abs(p.x) < 50/2 && p.y < 50/2 && p.y > -50 * (i + 1)) {
fill(255, 255, 0)
} else {
fill(255)
a[i] += 200 / (i + 1) * deltaTime / 1000
}
rect(0, 0, 50, 50)
fill(0)
pop()
}
}(Originally seen at https://editor.p5js.org/bojidar-bg/sketches/2MxBODAbE)
Browse more articles?
← XOR lissajous Experiments tagged p5 (30/85) Splats →
← COTR Experiments tagged game (3/11) Color Match →
← Random planets Experiments tagged wip (2/5) Match sets →
← XOR lissajous Experiments on this site (30/85) Splats →