xxxxxxxxxx
82
var h;
var m;
var c;
var type; // 0:escape,1:from,2:insomnia
var offsetX;
var speedX;
var maxSpeed;
var col;
var escape;
var from;
var insomnia;
var ratioe;
var ratiof;
var ratioi;
function preload(){
escape = loadImage("logo_liner_escape.png");
from = loadImage("logo_liner_from.png");
insomnia = loadImage("logo_liner_insomnia.png");
}
function setup() {
createCanvas(windowWidth, windowHeight);
frameRate(30);
colorMode(HSB,360,100,100);
pixelDensity(1);
//高さを揃える。Calculate only once!
h = 60; //height
mX = 10; //margin
mY = 5; //margin
c = 0; //count
ratioe = escape.width/escape.height;
ratiof = from.width/from.height;
ratioi = insomnia.width/insomnia.height;
maxSpeed = 1;
initialize();
}
function draw() {
background(col);
for(var y=0;y<height/h;y++){
for(var x=offsetX[y];x<width;x){
//
if(offsetX[y]>0) offsetX[y]-=(ratioe*h+mX);
if(offsetX[y]<-escape.width-mX) offsetX[y]+=(ratioe*h+mX);
image(escape,x,(h+mY)*y,ratioe*h,h);
x+=(ratioe*h+mX);
offsetX[y]+=speedX[y]*deltaTime/60;
}
}
}
function initialize(){
offsetX = [];
speedX = [];
for(var i=0;i<height/h;i++){
offsetX[i] = -int(random(width/2));
speedX[i] = (random(-maxSpeed,maxSpeed));
while(speedX[i]<0.05&&speedX[i]>-0.05){
speedX[i] = (random(-maxSpeed,maxSpeed));
}
}
col = color(int(random(360)),int(random(50,100)),int(random(75,100)));
if(c%3==0){mX=10;mY=5;}
if(c%3==1){mX=10;mY=5;}
if(c%3==2){mX=20;mY=40;}
c++;
}
function mousePressed(){
initialize();
}
function touchStarted(){
initialize();
}