Code viewer for World: Game of Crowns season 2 (c...
const MUSICFILE = '/uploads/eoghan/TheKillers-Mr.Brightside.mp3'; // Music Time
AB.backgroundMusic(MUSICFILE);

function getRandomInt(max) {
  return Math.floor(Math.random() * max);
}

const noboxes = 30; // 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)];
}

var img;

function preload() {
  img = loadImage('/uploads/eoghan/1758018620.png'); // Make sure the path is correct
}

const objectsize = 250; // Size of object
const anglechange = 0.01; // How much the rotate angle changes each step
var angle = 1; // Rotate angle starts at 0

function setup() {
  createCanvas(ABWorld.fullwidth(), ABWorld.fullheight(), WEBGL);
}

function draw() {
  texture(img);
  background(255); // Clear background with white color

  rotateX(angle); // Set each dimension rotation angle to "angle"
  rotateY(angle);
  rotateZ(angle);

  for (var i = 0; i < noboxes; i++) {
    push(); // Save the current transformation matrix
    translate(a[i][0], a[i][1], a[i][2]); // Get box position i
    box(objectsize);
    pop(); // Restore the transformation matrix
  }

  angle += anglechange; // Update the rotation angle
}