function loopSound(sound) {
sound.play({
onfinish: function() {
loopSound(sound);
}
});
}
function GLOBAL_BeginMinigame(){
$("#loadingScreen").delay(3500).fadeOut();
setTimeout("spawn_speedCloud1();", 500);
setTimeout("movePlaneDown();", 4500); //4500 //2500
setTimeout("planeAnimation()", 3000); //3000 //1000
//setTimeout("loopSound(stage2a);", 3000); //3000 //1000
placeMeepsInsidePlane()
}
stopSpeedClouds = false;
stopSpeedClouds2 = false;
function spawn_speedCloud1(){
y = rand1(10, 1000);
x = 1200;
c = rand1(1,10);
r = rand1(1000000,99999999);
div = "

";
$("#blueSky").prepend(div);
$("#item_"+r).stop();
$("#item_"+r).animate({
left: -300
}, 400);
setTimeout("$('#item_"+r+"').remove();", 400);
if (stopSpeedClouds == false){
setTimeout("spawn_speedCloud1();", 100);
}
}
function moveUser(u, xx){
if (u != me){
pleft = xx - 60;
$("#meep_"+u).stop();
$("#meep_"+u).animate({
left: xx
}, 500);
$("#parachute_"+u).stop();
$("#parachute_"+u).animate({
left: pleft
}, 500);
}
}
function spawn_speedCloud2(){
rr = rand1(1,15)
y = 700;
if (rr == 1){ //Super fast cloud.
x = rand1(-30, 1000);
c = rand1(1,10);
r = rand1(1000000,99999999);
speed = 400;
size = "100";
}else{
x = rand1(-30, 1000);
c = rand1(1,10);
r = rand1(1000000,99999999);
rrr = rand1(1,2);
if (rrr==1){
speed = 6000;
size = "30";
}else{
speed = 2500;
size = "70";
}
}
div = "
";
$("#blueSky").prepend(div);
$("#item_"+r).stop();
$("#item_"+r).animate({
top: -400
}, speed);
setTimeout("$(\'#item_"+r+"\').remove();", speed);
if (stopSpeedClouds2 == false){
setTimeout("spawn_speedCloud2();", 150);
}
}
function rand1(min1, max1){
return Math.floor(Math.random() * (max1 - min1 + 1)) + min1;
}
function movePlaneDown(){ //// ANIMATION TO MOVE THE PLANE DOWN \\\\
$("#thePlane").animate({
top: -200
},{
duration: 2500,
easing: "easeOutBack"
})
$("#planeInside").animate({
top: -200
},{
duration: 2500,
easing: "easeOutBack"
})
$("#planeDoor").animate({
top: -200
},{
duration: 2500,
easing: "easeOutBack"
})
setTimeout("PDA();", 3200);
}
function movePlaneUp(){ //// ANIMATION TO MOVE THE PLANE UP \\\\
$("#thePlane").animate({
top: -600
},{
duration: 1500,
easing: "easeInBack"
})
$("#planeInside").animate({
top: -600
},{
duration: 1500,
easing: "easeInBack"
})
$("#planeDoor").animate({
top: -600
},{
duration: 1500,
easing: "easeInBack"
})
setTimeout("panCameraDown1(); $('#planeStuff').remove(); $('#thePlane').remove(); $('#planeInside').remove(); $('#planeDoor').remove(); ", 2000);
}
function panCameraDown1(){
stopSpeedClouds = true;
}
function PDA(){
$("#planeDoor").animate({
top: -265
},{
duration: 1000
})
setTimeout("planeJump()", 3000);
}
function PDA2(){
setTimeout("movePlaneUp()", 0);
setTimeout("spawn_speedCloud2();", 2500);
setTimeout("spawnMainMeeps();", 3000);
}
function planeAnimation(){
suboradd = rand1(1,2);
if (suboradd == 1){ //add
xPos = parseInt(document.getElementById("planeStuff").style.left.replace('px', '')) + 5;
yPos = parseInt(document.getElementById("planeStuff").style.top.replace('px', '')) + 2;
}else if (suboradd == 2){ //add
xPos = parseInt(document.getElementById("planeStuff").style.left.replace('px', '')) - 5;
yPos = parseInt(document.getElementById("planeStuff").style.top.replace('px', '')) - 2;
}
$("#planeStuff").stop();
$("#planeStuff").animate({
top: yPos,
left: xPos
}, 300)
setTimeout("planeAnimation()", 300);
}
theMeeps = [];
function planeJump(){
ii=0;
for (var m in theMeeps){
setTimeout("jfp(\'"+theMeeps[m]+"\');", ii);
ii = ii + 1000;
}
setTimeout("PDA2();", 3000);
}
function jfp(m){
$("#planeMeep_"+m).animate({
top: -3
}, 150, "linear");
$("#planeMeep_"+m).animate({
top: 200,
left: -50,
height:'110px',
width:'86px'
}, 400, "linear");
$("#planeMeep_"+m).animate({
left: -1000,
top:300
}, 200);
setTimeout("$('#planeMeep_"+m+"').remove();", 1000);
}
mi = 0;
function spawnMeepPlane(m){
planeX = mi * 30;
mi = mi + 1;
div = "";
$("#planeMeeps").prepend(div);
theMeeps.push(m);
}
function placeMeepsInsidePlane(){
for (var m in meeps){
spawnMeepPlane(meeps[m]);
}
}
mi2=0;
spawnX = 0;
function spawnMeepNormal(m){
if (mi2==0){
spawnX = 80;
}else{
spawnX = spawnX + 250;
}
mi2 = mi2 + 1;
pleft = spawnX - 60;
ptop = -100 - 130;
if (m==me){
opacity_meep = 1;
}else{
opacity_meep = 0.5;
}
parachute = "";
div = "";
$("#theWorld").prepend(div);
$("#theWorld").prepend(parachute);
}
function spawnMainMeeps(){
for (var m in meeps){
console.log("Spawned "+meeps[m]);
spawnMeepNormal(meeps[m]);
}
setTimeout("animate_meepsDown();", 500);
}
function animate_meepsDown(){
for (var m in meeps){
meep = meeps[m];
$("#meep_"+meep).animate({
top: 230
}, 3000)
ptop = 230 - 130;
$("#parachute_"+meep).animate({
top: ptop
}, 3000)
}
}
console.log("LOADED");
lastMouse = 0;
myCurrentMouse = 0;
function sendMouse(){
console.log("send mouse function ran.");
if (lastMouse == myCurrentMouse){
setTimeout("sendMouse()", 250);
}else{
lastMouse = myCurrentMouse;
document.getElementById("mg").contentWindow.sendPos(myCurrentMouse);
setTimeout("sendMouse()", 250);
}
}
sendMouse();
//MUSIC\\
soundManager.onload = function() {
//setTimeout("GLOBAL_BeginMinigame()", 30);
stage2a = soundManager.createSound({
id:'stage2a',
url:'http://s3.amazonaws.com/socialmeep/game/audio/stage2.mp3'
});
}