By [[Ron-liu| ron liu]] =====Code===== let canvasWidth = 1920; let canvasHeight = 1080; let x, y; function pick(inputArray) { return inputArray[Math.floor(inputArray.length * Math.random())]; } function randomRange(min, max) { return min + (max - min) * Math.random(); } function buildArray(n, fillFunction) { let outputArray = []; for (let i = 0; i < n; i++) { outputArray.push(fillFunction(i)); } return outputArray; } function setup() { createCanvas(canvasWidth, canvasHeight); background(0, 0, 0); angleMode(DEGREES); x = width / 2; y = height; textSize(10); textAlign(LEFT); } class BackgroundPattern { constructor(size, gColor, x, y) { this.backgroundSize = size; this.backgroundColor = gColor; this.xposition = randomRange(20, canvasWidth - 20); this.yposition = randomRange(y, 5 + y); } } class Geometry { constructor(ssize, scolor, maxX, maxY, randomN, ) { this.Geometrysize = ssize; this.Geometry = scolor; this.xposition = randomRange(300, maxX); this.yposition = randomRange(30, maxY); this.n = randomN; } draw(number) { let color1 = "beige"; if (Math.random() * 255 > 0) { color1 = "white"; } fill(color(color1)); translate(this.xposition, this.yposition); //planet fill(145, 141, 150) circle(350,280,500) //line line(200, 200, 300, 150); line(430, 160, 380, 160); line(500, 330, 470, 160); line(300, 400, 180, 200); line(500, 350, 300, 400); //bubbles fill(245, 230, 66) circle(190,245,95) fill(110, 165, 255) circle(470,380,125) circle(340,160,90) fill(150, 117, 115) circle(480,190,115) fill(125, 300, 180) circle(300,440,105) //sun fill(252, 102, 3) circle(800,120,210) //other planet fill(26, 237, 213) circle(80,100,100) fill(235, 40, 222) circle(700,500,210) resetMatrix(); } } class Spaceship { constructor(ssize, scolor, maxX, maxY, randomN, ) { this.Spaceshipsize = ssize; this.Spaceship = scolor; this.xposition = randomRange(300, maxX); this.yposition = randomRange(30, maxY); this.n = randomN; } draw(number) { let color1 = "beige"; if (Math.random() * 255 > 0) { color1 = "white"; } fill(color(color1)); translate(this.xposition, this.yposition); //spaceship fill(255,255,255) triangle(50, 190, 120, 80, 75, 125) resetMatrix(); } } let random1 = Math.random(); let geometry1 = buildArray(20,(i) => new Geometry(0.25, "white", 1000, 800, 10)); let spaceship1 = buildArray(20,(i) => new Spaceship(0.25, "white", 1000, 800, 10)); console.log(Geometry[Geometry.length-1]) function backgroundPatternArray(number, x, y) { let outputArray = []; for (let i = 0; i < number; i++) { outputArray.push(new BackgroundPattern(10, "purple", x + i * 35, y)); } return outputArray; } function Background2(startingX, startingY, numberOfArrays, arrayLength) { for (let i = 0; i < numberOfArrays; i++) { let myBackground = backgroundPatternArray( arrayLength, startingX, startingY + i * 35 ); for (let i = 0; i < myBackground.length; i++) { myBackground[i].draw(); } } } let g1 = new Geometry(300, 200, 1, "black", "no"); let s1 = new Spaceship(200, 100, 1, "black", "no"); function draw() { background(20,3,23); if (Math.random() < 0.5) stroke(0); g1.draw(); spaceship1.forEach(x => x.draw()) }