// Cloned by Sagnik Chakraborty on 19 Sep 2022 from World "One Cube World (P5)" by Starter user
// Please leave this clone trail here.
const MUSICFILE = '/uploads/starter/SuspenseStrings.mp3';
// AB.backgroundMusic ( MUSICFILE );
var img;
var cubeimg = new Array(3);
var y=0;
let canvasbg;
function preload()
{
img = loadImage ( '/uploads/sagnikc3/1663611608.png' );
// canvasbg = loadImage ('/uploads/sagnikc3/a19b52945ee7d46bad585fc8113e39a0.gif'); //gif for background
cubeimg[0] = loadImage ( '/uploads/sagnikc3/1663771081.png' );
cubeimg[1] = loadImage ( '/uploads/sagnikc3/1663771050.png' );
cubeimg[2] = loadImage ( '/uploads/sagnikc3/1663770996.png' );
}
//colorb= AB.randomColor();
// make an array of random (x,y,z) positions
const noboxes = 200; // how many boxes to have
var a = new Array(noboxes); // array of the box positions
for ( var i=0; i < noboxes; i++ ) // set up the array
{
a[i] = [ AB.randomIntAtoB(-500,500), AB.randomIntAtoB(-500,500), AB.randomIntAtoB(-500,500) ];
}
const objectsize = 100; // size of object
const anglechange = 0.025; // how much the rotate angle changes each step
var angle = 0; // rotate angle starts at 0
function setup() // "setup" is called once at start of run
{
// canvasbg = loadImage ('/uploads/sagnikc3/1663680001.png'); // image for background
createCanvas ( ABWorld.fullwidth(), ABWorld.fullheight(), WEBGL );
}
function draw() // "draw" is called every timestep during run
{
// background(canvasbg); //background image
background ("black"); // background color
// fill("navy"); // paint box with this color
// texture(img);
var rand = AB.randomIntAtoB(0,50);
if ( rand === 2) // random cube image
{
texture(cubeimg[y])
if ( y >= 2)
{
y=0;
} else {
y++;
}
}
rotateX(angle); // set each dimension rotation angle to "angle"
rotateY(angle);
rotateZ(angle);
for ( var i=0; i < noboxes; i++ )
{
translate ( a[i][0], a[i][1], a[i][2] ); // get box position i
//sphere(objectsize);
//rotateY(millis() / 5000);
if ( i > 100)
{
box(objectsize+100);
rotateX(frameCount * 0.0005);
rotateY(frameCount * 0.0005);
}
else
{
sphere(objectsize);
rotateY(millis() / 50000);
//rotateX(frameCount * 0.0005);
//rotateY(frameCount * 0.0005);
}
//box ( 200, 160 , 1000);
}
// box(objectsize); // draw a cube of this size
//box ( 200, 160 , 1000);
// angle = angle + anglechange
angle = angle + AB.randomFloatAtoB ( 0, 0.005 ) ; //random angles
}