// make an array of random (x,y,z) positions
const noboxes = 1; // 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/mchenrp2/1663682335.png' );
}
// Cloned by Peadar McHenry on 20 Sep 2022 from World "One Cube World (P5)" by Starter user
// Please leave this clone trail here.
const gridsize = 20 ;
const objectsize = 200; // size of object
const anglechange = 0.02; // how much the rotate angle changes each step
var angle = 0; // rotate angle starts at 0
const MAXPOS = gridsize * squaresize;
const startRadiusConst = MAXPOS * 0.8 ; // distance from centre to start the camera at
const skyboxConst = MAXPOS * 3 ; // where to put skybox
const maxRadiusConst = MAXPOS * 10 ; // maximum distance from camera we will render things
const BACKWALLPOS = -299;
const GRID_BLANK = 0;
const GRID_WALL = 1;
const GRID_MAZE = 2;
const GRID_BOTTOM = 3;
const GRID_BOTTOM2 = 4;
const GRID_STONE = 5
var BOXHEIGHT; // 3d or 2d box height
var GRID = new Array(gridsize);
var GRID2 = new Array(gridsize);
var GRID3 = new Array(gridsize);// can query GRID about whether squares are occupied, will in fact be initialised as a 2D array
var WALLS = new Array ( 4 * gridsize );
var WALLS2 = new Array ( 4 * gridsize );// need to keep handles to wall and maze objects so can find them later to paint them
var MAZE = new Array ( NOBOXES );
var STONE = new Array ( NOBOXES );
var BOTTOM = new Array (gridsize ) // created an array for the bottom of the shooting zone.
var BOTTOM2 = new Array (gridsize )
function initGrid()
{
for (var i = 0; i < gridsize ; i++)
{
GRID[i] = new Array(gridsize); // each element is an array
for (var j = 0; j < gridsize ; j++)
{
GRID[i][j] = GRID_BLANK ;
}
}
}
function initGrid2()
{
for (var i = 0; i < gridsize ; i++)
{
GRID2[i] = new Array(gridsize); // each element is an array for the bottom part of the grid.
for (var j = 0; j < gridsize ; j++)
{
GRID2[i][j] = GRID_BLANK ;
}
}
}
function setup() // "setup" is called once at start of run
{
createCanvas ( ABWorld.fullwidth(), ABWorld.fullheight(), WEBGL );
}
function draw() // "draw" is called every timestep during run
{
texture(img);
background("yellow"); // background color
//fill("green"); // paint box with this color
for ( var i=0; i < noboxes; i++ )
{
translate ( a[i][0], a[i][1], a[i][2] ); // get box position i
box(objectsize);
}
}