Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Computer Graphics with WebGL / Project / level.js
diff options
context:
space:
mode:
Commit8608f2c0e0d02e58df9280eab03a6b7a96acd5f1 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-08-27 14:58:32 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-08-27 14:58:32 +0300
Files35b68a6658b87c4770f632ce31e85cec725eb334 /Year 2/Computer Graphics with WebGL/Project/level.js
uni-projects-8608f2c0e0d02e58df9280eab03a6b7a96acd5f1.tar
uni-projects-8608f2c0e0d02e58df9280eab03a6b7a96acd5f1.tar.gz
uni-projects-8608f2c0e0d02e58df9280eab03a6b7a96acd5f1.zip
Parent2ca6d751de5c6933e6d75289d184a980131036a2 (diff)
[WGL/P] Added a proper level management system, added more options to the menu
1 files changed, 32 insertions, 0 deletions
-rw-r--r--Year 2/Computer Graphics with WebGL/Project/level.js32
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);
+}