crowds/js/main.js

79 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-03-27 17:39:08 +00:00
window.onload = function(){
// Start Preloading!
publish("prepreload");
}
subscribe("prepreload/done", function(){
// Bye Pre-Preloader!
var pre_preloader = $("#pre_preloader");
pre_preloader.parentNode.removeChild(pre_preloader);
2018-03-27 17:39:08 +00:00
// Setting up the main stuff
window.slideshow = new Slideshow();
window.pencil = new Pencil();
2018-04-04 15:57:35 +00:00
window.navigation = new Navigation();
2018-03-27 17:39:08 +00:00
// Initializing the Mouse
Mouse.init(document.body);
// Animation loop IS update loop for now, whatever
2018-03-27 17:39:08 +00:00
function update(){
// Update
2018-03-27 17:39:08 +00:00
slideshow.update();
pencil.update();
Mouse.update();
// Draw
2018-03-28 17:12:05 +00:00
slideshow.draw();
pencil.draw();
2018-04-02 17:43:20 +00:00
// Update
publish("update");
2018-03-27 17:39:08 +00:00
window.requestAnimationFrame(update);
2018-03-27 17:39:08 +00:00
}
window.requestAnimationFrame(update);
// Go to THE SPLASH
2018-04-27 12:57:59 +00:00
slideshow.gotoChapter("Preloader");
2018-04-26 14:15:00 +00:00
// HACK - MOBILE IS HORRIBLE
$all("a").forEach(function(a){
a.ontouchstart = function(event){
event.stopPropagation();
}; // so you CAN click links
});
2018-03-27 17:39:08 +00:00
});
2018-04-16 15:44:14 +00:00
subscribe("START", function(){
// Music
2018-05-15 19:27:28 +00:00
SOUNDS.bg_music.stop();
2018-04-18 14:51:44 +00:00
SOUNDS.bg_music.volume(0.5);
SOUNDS.bg_music.loop(true);
2018-04-16 19:51:08 +00:00
SOUNDS.bg_music.play();
2018-04-16 15:44:14 +00:00
2018-04-23 17:53:36 +00:00
// Hide translations, show navigation
$("#translations").style.display = "none";
2018-04-18 21:00:04 +00:00
$("#navigation").style.display = "block";
// Show Skip Button
var skippy = $("#skip");
skippy.style.display = "block";
skippy.onclick = function(){
2018-04-20 18:47:58 +00:00
publish("sound/button");
2018-04-18 21:00:04 +00:00
slideshow.next();
};
_stopPropButton(skippy);
2018-04-16 15:44:14 +00:00
// Introduction
slideshow.next();
2018-05-15 19:27:28 +00:00
});