-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloading.js
More file actions
33 lines (30 loc) · 1.21 KB
/
loading.js
File metadata and controls
33 lines (30 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
document.addEventListener('DOMContentLoaded', (event) => {
const loadingManager = {
assetCounter: 0,
totalAssets: 523, // Update this number based on the actual total assets being loaded + 1
progressBar: document.getElementById('progress-bar'),
loadingScreen: document.getElementById('loading-screen'),
gameRoot: document.getElementById('game-root'),
assetLoaded: function() {
this.assetCounter++;
const progress = (this.assetCounter / this.totalAssets) * 100;
if (this.progressBar) {
this.progressBar.style.width = progress + '%';
}
if (this.assetCounter === this.totalAssets) {
if (this.loadingScreen) {
this.loadingScreen.style.display = 'none';
}
if (this.gameRoot) {
this.gameRoot.style.display = 'block';
}
setCameraOverlay(true);
menu = "main";
}
}
};
// Make assetLoaded globally accessible for p5.js callbacks
window.assetLoaded = function() {
loadingManager.assetLoaded();
};
});