xxxxxxxxxx
129
// noiseDetail/noiseVal/noiseSeed https://p5js.org/reference/#/p5/noiseDetail
let noiseVal;
let noiseScale = 0.02;
var r = 0;
var k = 0;
let rb2;
let rbs = [];
var img;
let value = 0;
let t;
let z;
let m;
function preload() {
//img = loadImage("plane3.png");
img = loadImage("plane4.jpg");
}
function setup() {
createCanvas(400, 400);
angleMode(RADIANS);
rectMode(CENTER);
background(66,185,244);
noiseDetail(100, 0.95);
noiseVal = noise(
(mouseX + width / 2) * noiseScale,
(mouseY) * noiseScale);
//stroke(noiseVal * 300);
noStroke();
noiseSeed(92);
fill(noiseVal*300,80);
let rb = new Plane(
0,0,0,
0,0,0,
img,
img,
0.0000001, // xspeed
0.00000001, // yspeed
0.000000001 // rspeed
);
for (var i = 0; i < 10; i++) {
w = 400;
h = w;
let rb = new RotatorBouncer(
10,2,0, // x
10,2,0, // y
img, // width
img, // height
0.000000001, // xspeed
0.0000000001, // yspeed
0.000000001 // rspeed
);
rbs.push(rb);
}
}
function draw() {
//background(66,185,244);
for (var i = 0; i < rbs.length; i++){
//translate(this.x,this.y);
image(img,this.x,this.y,60);
rotate(22,50,40,20);
rect(this.x,this.y,20,2);
rbs[i].update();
}
//rotate(200,200/100,20);
}
class RotatorBouncer {
constructor(x,y,w,h,xSpeed,ySpeed,rSpeed) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.xSpeed = xSpeed;
this.ySpeed = ySpeed;
this.rSpeed = rSpeed;
this.a = 0;
}
update() {
//rotate(0,10,m,m,30);
rect(this.x,this.y,20,2);
image(img,this.x,this.y,60);
this.x = this.x + this.xSpeed;
this.y = this.y + this.ySpeed;
this.a = this.a + this.rSpeed;
if (mouseIsPressed) {
//rotate(0,40,0,200);
//rect(this.x,this.y,pmouseX/20,this.h);
//image(img,this.x,this.y);
m = m - 10;
this.ySpeed = this.ySpeed - 0.3; }
function mouseDragged() {
value = value - 15;
if (value > 255) {
this.ySpeed = this.ySpeed - 0.3;
value = (t,z); }
}
if (this.x >= w - this.w/2 || this.x <= this.w/2) {
this.xSpeed = this.xSpeed * -1; }
if (this.y >= h - this.h/2 || this.y <= this.h/2 ) {
this.ySpeed = this.ySpeed * -1;
rotate(0,-100); }
}
}
class Plane {
constructor (twoX,twoY,twoW,twoH,twoxSpeed,twoySpeed) {
this.x = twoX;
this.y = twoY;
this.w = twoW;
this.h = twoH;
this.xSpeed = twoxSpeed;
this.ySpeed = twoySpeed; }
}