xxxxxxxxxx
99
let pannasnowboard,pannaimg;
let snowbg = [];
let snowimg =[];
let xx = 0;
let yy =0;
let len = 50;
let angle = 10;
let slider;
let cd = false;
let imgcnt = 0;
let imgFrameCount = 0;
let imgFrameRate = 30;//30FPS
function preload(){
pannasnowboard = loadImage('pannasnowboardsmall.png');
for (let i = 1; i < 7;i++){
snowbg[i-1] = loadImage(i+'.png');
}
}
function setup() {
createCanvas(800, 800);
pannaimg = new Dogimage(width/2,height/2,100,100,pannasnowboard);
for(let i = 1; i< 7;i++){
snowimg.push(new Dogimage(width/2,height/2-500,4238,3669,snowbg[i-1]));
}
frameRate(15);
slider = createSlider(0,200,5);
}
function mousePressed() {
angle = 0;
if(mouseX<=width && mouseY <= height){
cd =!cd;
}
}
function draw() {
if(imgcnt < 6 && imgcnt >= 0){
if (frameCount % (60 / imgFrameRate) == 0) {
snowimg[imgcnt].show(0);
pannaimg.show(1);
imgFrameCount++;
}
}
else{
imgcnt = 0;
}
imgcnt++;
len = slider.value();
}
class Dogimage{
constructor(x,y,w,h,img){
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.img = img;
}
show(imgtype){
if(imgtype==0){
push();
scale(0.25);
image(this.img, -this.x, this.y);
pop();
}
else{
translate(width/2,height/2);
if(cd){
rotate((angle/PI));
}
xx = random(-5,5) + cos(angle)*len;
this.x = xx;
this.y = this.y + random(-15,15);
image(this.img, this.x, this.y-500);
if(this.y > height/2 -200){
this.y = height/2;
}
angle++;
}
}
}