← Volver
🧪
Laboratorio de Ideas
p5.js · Python · MiauBot
📝
✦ p5.js
🐍 Python
🟦 Bloques
Fuegos Artificiales
▶ Ejecutar
⏹ Detener
📤
💾
⬇️
📂
🗑️
// 🎆 Fuegos Artificiales — haz clic para lanzar cohetes let cohetes = [], chispas = []; function setup() { createCanvas(windowWidth, windowHeight); colorMode(HSB, 360, 100, 100, 100); background(0, 0, 5); } function draw() { background(0, 0, 5, 18); for (let c of cohetes) { c.y += c.vy; c.vy += 0.2; noStroke(); fill(60, 100, 100); circle(c.x, c.y, 5); if (c.y <= c.meta) explotar(c); } cohetes = cohetes.filter(c => c.y > c.meta); noStroke(); for (let i = chispas.length - 1; i >= 0; i--) { let p = chispas[i]; p.x += p.vx; p.y += p.vy; p.vy += 0.07; p.vida -= 1.8; fill(p.tono, 90, 100, p.vida); circle(p.x, p.y, map(p.vida, 0, 100, 0, 6)); if (p.vida <= 0) chispas.splice(i, 1); } if (!cohetes.length && !chispas.length) { fill(0, 0, 100, 25); noStroke(); textAlign(CENTER, CENTER); textSize(14); text('Haz clic para lanzar 🎆', width / 2, height / 2); } } function mousePressed() { cohetes.push({ x: mouseX, y: height, vy: -14, meta: random(height * 0.1, height * 0.5) }); } function explotar(c) { let t = random(360); for (let i = 0; i < 90; i++) { let a = random(TWO_PI), v = random(2, 7); chispas.push({ x: c.x, y: c.y, vx: cos(a) * v, vy: sin(a) * v, vida: 100, tono: t }); } } function windowResized() { resizeCanvas(windowWidth, windowHeight); }
⟨/⟩ Ver JS generado
💾 Ideas guardadas
0
▾
🎨 Vista Previa
En espera
⛶
▶ Pulsa Ejecutar para ver tu sketch
🐱 MiauBot Coder
👁 Leyendo código
🐾