xxxxxxxxxx
99
//loop based on width
let Loop1= 0;
let lastLoop1= 200;
var img;
var locationx = 0;
//how to declare a vector in javascript
//var velocityx = createVector(40, 50);
var velocityx = 0;
var locationy = 0;
var velocityy = 0;
//create an instance of the class
let r2;
function preload() {
raleway = loadFont('data/Raleway-Medium.ttf');
img = loadImage("data/lowtherMap.png");
}
function setup() {
createCanvas(300, 300, WEBGL);
//render function in 3d changes the origin point to the centre
textFont(raleway);
r2 = new rotScreens2(20, 20);//creates new class with arguments from constructor.
//console.log(r2.width); // prints '1' to the console
}
function draw() {
background(0);
if (Loop1 < lastLoop1)
{
Loop1 += 1;
}
Loop1++;
fill('#00ff00');//green zones
//textSize(width/7);
text('bug', -width/2, -130);
text('data-1',-width/2, -120);
//functions of the class
r2.show();
//image(img, 0, 0);
if ((locationx > width) || (locationx < 0)) {
velocityx = velocityx * +1;
}
if ((locationy > height) || (locationy < 0))
{
velocityy = velocityy * +1;
}
//print(velocityx);
push();
//translate(width/2, height/2);
let m = map(locationx, 0, width, -PI, PI);
rotateY(m);
stroke(255);
for (let i = 0; i < width; i+=width/30)
{
line(i, -height/2, i, height);
line(-i, -height/2, -i, height);
console.log(i);
}
line(0, 20, 0, 75);
texture(img);
textureMode(NORMAL);
beginShape();
//add an array from bug data (rotscreens2), avoid hard coding fixed points place into an array as a function of canvas size.
vertex(-100, -50, 0, 0);
vertex(Loop1, -50, 1, 0);
vertex(50, mouseY, 1, 1);
vertex(-50, 50, 0, 1);
endShape();
pop();
text("Loop1=" + Loop1, 0, 25);
//if ((Loop1 >= 70) && (Loop1 < 80))
//{
text("Bug1", -width/2, width/2);
for (let p = 0; p < y.length; p++)
{
noStroke();
rect(0, y[p]-Loop1/4, 20, y[0]);
rect(width/2, y[p]-Loop1/5.6, 10, y[0]);
}
//}
//internal loop
//else (Loop1 = 0);
//{
//rect(Loop1, width/2, 20, 59);
//}
}