From 8608f2c0e0d02e58df9280eab03a6b7a96acd5f1 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 27 Aug 2023 14:58:32 +0300 Subject: [WGL/P] Added a proper level management system, added more options to the menu --- .../Computer Graphics with WebGL/Project/level.js | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Year 2/Computer Graphics with WebGL/Project/level.js (limited to 'Year 2/Computer Graphics with WebGL/Project/level.js') diff --git a/Year 2/Computer Graphics with WebGL/Project/level.js b/Year 2/Computer Graphics with WebGL/Project/level.js new file mode 100644 index 0000000..65c3cc6 --- /dev/null +++ b/Year 2/Computer Graphics with WebGL/Project/level.js @@ -0,0 +1,32 @@ +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); +} -- cgit v1.3.1-26-gb76a