xxxxxxxxxx
var minutes = .1; // This is the minutes of the timer
var pars=[]
function setup() {
imageMode(CENTER)
createCanvas(windowWidth, windowHeight);
background(255)
background(255);
duckImg.resize(250*2,0)
image(duckImg,width/2,height/2)
for(let i=0;i<500;i++){
let xx=random(width)
let yy=random(height)
while(get(xx,yy)[2]>240){xx=random(width)
yy=random(height)}
pars.push(new Par(xx,yy));}
off=second();
timer=minutes
}
function preload(){
duckImg=loadImage("duck.png");
}
var timeF = 100
var home = 0;
var secs=0;
var oSec=0;
var off=0;
function draw() {
background(0);
if(home==0){
if(second()!==oSec){secs++;}
oSec=second();
imageMode(CENTER)
duckImg.resize(250,0)
image(duckImg,width/2,height/2)
textAlign(CENTER, CENTER)
textSize(150);
if(secs/60>=timer){home=1;frameCount=0}
fill(255,0,0)
noStroke()
if((round(((-secs/60)+timer)*60)%60)>=10){
text(round((-secs/60)+timer-0.5)+":"+(round(((-secs/60)+timer)*60)%60),width/2,100)}else{
text(round((-secs/60)+timer-0.5)+":0"+(round(((-secs/60)+timer)*60)%60),width/2,100)
}
}
if(home==1){
imageMode(CENTER)
noStroke();
for(let i=0;i<pars.length;i++){
pars[i].move();
}if(frameCount<timeF){
duckImg.resize(250,0)
push();
translate(width/2,height/2)
scale((map(round(frameCount),0,timeF,1,2)));
image(duckImg,0,0)
pop()}}
//if(frameCount>=timeF){frameRate(1000);}else{frameRate(1);}
}
function Par(x,y){
this.x=x
this.y=y
this.xVel=0;
this.yVel=0;
this.ran=1//round(random(1))
this.move=function(){
if(frameCount>timeF){this.yVel+=0.1}
if(this.ran==1){ fill(245,215,0)
}else{fill(255,0,0)}
if(frameCount>=timeF){
ellipse(this.x,this.y,5)}
if(this.x>width||this.x<0){this.xVel*=-0.1;this.x+=this.xVel}
if(this.y>height||this.y<0){this.yVel*=-0.1;this.y+=this.yVel}
this.y+=this.yVel
this.x+=this.xVel
if(frameCount==timeF){
if(this.ran==1){
this.xVel=random(-5*10,5*10);
this.yVel=random(-5*10,5*10);}else{this.xVel=random(-5*10,5*10);
this.yVel=random(-5*10,5*10);}}
}
}