-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadingPage.js
66 lines (59 loc) · 1.49 KB
/
loadingPage.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
let numOfLoadedSounds = 0
let angle = 0
let progress1
let progress2
let progress3
let progress4
function finishedLoading() {
return (numOfLoadedSounds == 4)
}
function success(){
numOfLoadedSounds++
}
function updateAngle(){
angle = ((progress1+progress2+progress3+progress4)*TWO_PI)/4
}
function prog1(p){
progress1 = p
updateAngle()
}
function prog2(p){
progress2 = p
updateAngle()
}
function prog3(p){
progress3 = p
updateAngle()
}
function prog4(p){
progress4 = p
updateAngle()
}
function err(){
console.log("Error while Loading Assets!!")
}
function showLoadingScreen(){
background(30,24,80)
stroke(255)
fill(255)
textAlign(CENTER,CENTER)
textSize(38)
text("Loading Assets",windowWidth/2,(windowHeight/2)/5)
arc(windowWidth/2,windowHeight/2,300,300,0,angle+0.062)
fill(30,24,80)
noStroke()
circle(windowWidth/2,windowHeight/2,250)
fill(255)
textAlign(CENTER,CENTER)
textSize(48)
text(round(((angle/TWO_PI)*100)+1,2) +"%",windowWidth/2,windowHeight/2)
}
function loadSounds(){
music = loadSound('SoundTracks/lofimusic.mp3',success,err,prog1)
rainsound = loadSound('SoundTracks/shower.wav',success,err,prog2);
thunder = loadSound('SoundTracks/thunder.mp3',success,err,prog3);
thunder2 = loadSound('SoundTracks/thunder2.mp3',success,err,prog4)
rainsound.setVolume(0.2)
thunder.setVolume(0.2)
thunder2.setVolume(0.2)
}