xxxxxxxxxx
45
function setup() {
createCanvas(600, 600);
frameRate(2.5)
}
let dx = 1;
let dy = 0.5;
function draw() {
background(220);
candle(50, 70, 100, 100);
fire(117, 97, 15, 29, "#fcb303")
if (mouseIsPressed){
print(mouseX, mouseY);
}
if (frameCount%4==0){
fire(120, 95, 10, 25, "RGBA(252, 227, 3, 0.8)")
}else if(frameCount%4==1){
fire(120+dx, 95+dy, 10, 25, "RGBA(252, 227, 3, 0.9)")
}else if(frameCount%4==2){
fire(120, 95+2*dy, 10, 25, "RGBA(252, 227, 3, 0.7)")
}else if(frameCount%4==3){
fire(120-dx, 95+dy, 10, 25, "RGBA(252, 227, 3, 0.8)")
}
}
function candle(w, h, x, y){
noStroke();
fill("#D6BA7E");
rect(x, y, w, h);
ellipse((x+w/2), y+h, w, 20);
fill("#D6B16E");
ellipse((x+w/2), y, w, 20);
}
function fire(x, y, w, h, c){
noStroke();
fill(c);
triangle(x, y, x+w/2, y-h, x+w, y);
arc(x+w/2, y-dy, 10, 10, 0, PI);
}