stars = []; blackHoles = []; levels = []; Level = function(name, description, cameraCoords) { this.name = name; this.description = description; this.cameraCoords = cameraCoords; this.stars = []; this.blackHoles = []; levels.push(this); } Level.prototype.addStar = function(center, size) { this.stars.push(new Star(center, size)); } Level.prototype.addBlackHole = function(center, size) { this.blackHoles.push(new BlackHole(center, size)); } Level.prototype.load = function() { stars = this.stars; blackHoles = this.blackHoles; pos = this.cameraCoords; } function createLevels() { var l1 = new Level( "Star passing behind black hole", "You can see how the black hole (correctly) warps the light of the star behind it when it passes", [1000,0,650]); l1.addStar([1100,0,1000], 10); l1.addBlackHole([1000,0,900], 30); }