2019-06-06 16:32:57 +00:00
|
|
|
Loader.addImages([
|
|
|
|
{ id:"party_bg", src:"sprites/act2/party_bg.png" },
|
|
|
|
{ id:"party_action", src:"sprites/act2/party_action.png" },
|
2019-06-11 18:31:28 +00:00
|
|
|
{ id:"hong_bb_outro", src:"sprites/act2/hong_bb_outro.png" },
|
2019-06-12 19:08:32 +00:00
|
|
|
{ id:"SPECIAL_ATTACK", src:"sprites/act2/special.png" },
|
2019-06-06 16:32:57 +00:00
|
|
|
]);
|
|
|
|
|
2019-06-13 15:43:18 +00:00
|
|
|
Loader.addSounds([
|
|
|
|
{ id:"squeak", src:"sounds/sfx/squeak.mp3" },
|
|
|
|
{ id:"record_scratch", src:"sounds/sfx/record_scratch.mp3" },
|
2019-06-26 15:03:27 +00:00
|
|
|
{ id:"hadouken", src:"sounds/sfx/hadouken.mp3" }
|
2019-06-13 15:43:18 +00:00
|
|
|
]);
|
|
|
|
|
2019-06-06 16:32:57 +00:00
|
|
|
function BG_Party(){
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
// Sprites!
|
|
|
|
self.bgSprite = new Sprite({
|
|
|
|
image: Library.images.party_bg,
|
|
|
|
grid:{ width:1, height:1 },
|
|
|
|
frame:{ width:720, height:1200 },
|
|
|
|
});
|
2019-06-11 18:31:28 +00:00
|
|
|
self.partyActionSprite = new Sprite({
|
2019-06-06 16:32:57 +00:00
|
|
|
image: Library.images.party_action,
|
|
|
|
grid:{ width:4, height:3 },
|
|
|
|
frame:{ width:720, height:600 },
|
2019-06-12 16:23:26 +00:00
|
|
|
y: 189,
|
|
|
|
frameNames:[
|
|
|
|
"pre",
|
|
|
|
"twist1",
|
|
|
|
"twist2",
|
|
|
|
"twist3",
|
|
|
|
"twist4",
|
|
|
|
"end",
|
|
|
|
"end_run",
|
|
|
|
"end_slap1",
|
|
|
|
"end_slap2",
|
|
|
|
"end_slap3"
|
|
|
|
]
|
2019-06-06 16:32:57 +00:00
|
|
|
});
|
2019-06-11 18:31:28 +00:00
|
|
|
self.outroSprite = new Sprite({
|
|
|
|
image: Library.images.hong_bb_outro,
|
|
|
|
grid:{ width:4, height:2 },
|
|
|
|
frame:{ width:720, height:400 },
|
2019-06-12 16:23:26 +00:00
|
|
|
y: 260,
|
|
|
|
frameNames:[
|
|
|
|
"end1",
|
|
|
|
"end2",
|
|
|
|
"end3",
|
|
|
|
"end4",
|
|
|
|
"end5",
|
|
|
|
"end6"
|
|
|
|
]
|
2019-06-11 18:31:28 +00:00
|
|
|
});
|
2019-06-06 16:32:57 +00:00
|
|
|
|
2019-06-11 14:45:09 +00:00
|
|
|
// Anxiety BG
|
|
|
|
self.anxiety = new BG_Anxiety();
|
2019-06-06 16:32:57 +00:00
|
|
|
|
2019-06-11 18:31:28 +00:00
|
|
|
// Characters
|
|
|
|
self.hong = new Act2_Hong();
|
|
|
|
self.beebee = new Act2_Beebee();
|
|
|
|
|
2019-06-11 14:45:09 +00:00
|
|
|
// LAYERS
|
|
|
|
self.layers = [
|
|
|
|
self.bgSprite,
|
|
|
|
self.anxiety,
|
2019-06-11 18:31:28 +00:00
|
|
|
self.partyActionSprite,
|
|
|
|
self.outroSprite,
|
|
|
|
self.hong,
|
|
|
|
self.beebee,
|
2019-06-11 14:45:09 +00:00
|
|
|
];
|
|
|
|
var PARALLAXES = [
|
|
|
|
0.5, // party bg
|
|
|
|
0.0, // anxiety bg
|
2019-06-11 18:31:28 +00:00
|
|
|
1.0, // PARTY ACTION SPRITE
|
|
|
|
0.0, // OUTRO hong & bb
|
|
|
|
0.0, // battle hong
|
|
|
|
0.0, // battle beebee
|
2019-06-11 14:45:09 +00:00
|
|
|
];
|
|
|
|
var ALPHAS = [
|
|
|
|
1.0, // party bg
|
|
|
|
0.0, // anxiety bg
|
2019-06-11 18:31:28 +00:00
|
|
|
1.0, // PARTY ACTION SPRITE
|
|
|
|
0.0, // OUTRO hong & bb
|
|
|
|
0.0, // battle hong
|
|
|
|
0.0, // battle beebee
|
2019-06-11 14:45:09 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
var parallax = 0;
|
|
|
|
var parallaxTicker = 0;
|
|
|
|
var PARALLAXING = null;
|
2019-06-06 16:32:57 +00:00
|
|
|
self.update = function(){
|
|
|
|
|
2019-06-11 14:45:09 +00:00
|
|
|
// START PARALLAXING IN / OUT
|
|
|
|
if(PARALLAXING!=null){
|
|
|
|
|
|
|
|
if(PARALLAXING=="out"){
|
|
|
|
parallaxTicker += 1/60; // 0 to 1 in one second
|
|
|
|
}
|
|
|
|
if(PARALLAXING=="in"){
|
|
|
|
parallaxTicker -= 1/60; // 1 to 0 in one second
|
|
|
|
}
|
|
|
|
if(parallaxTicker>1) parallaxTicker = 1;
|
|
|
|
if(parallaxTicker<0) parallaxTicker = 0;
|
|
|
|
|
|
|
|
// 0 to -180 in one second, smoothed
|
|
|
|
var t = Math.cos(parallaxTicker*Math.TAU/2); // 1 to -1
|
|
|
|
t = (1-t)/2; // 0 to 1
|
2019-06-12 16:23:26 +00:00
|
|
|
parallax = -t*210;
|
2019-06-11 14:45:09 +00:00
|
|
|
|
|
|
|
// Anxiety Alpha
|
|
|
|
ALPHAS[1] = t;
|
|
|
|
|
|
|
|
// DONE
|
|
|
|
if(t==1 || t==0){
|
|
|
|
PARALLAXING = null;
|
2019-06-11 18:31:28 +00:00
|
|
|
|
2019-06-12 16:23:26 +00:00
|
|
|
// Stage 1 or 3 transition end
|
|
|
|
if(STAGE==1 || STAGE==3){
|
2019-06-11 18:31:28 +00:00
|
|
|
ALPHAS[2] = 0; // Party Action
|
|
|
|
ALPHAS[4] = 1; // Hong
|
|
|
|
ALPHAS[5] = 1; // Beebee
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stage 5 transition end
|
|
|
|
if(STAGE==5){
|
|
|
|
ALPHAS[2] = 0; // Party Action
|
|
|
|
ALPHAS[3] = 1; // OUTRO Action
|
|
|
|
}
|
|
|
|
|
2019-06-11 14:45:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Anxiety BG
|
|
|
|
if(ALPHAS[1]>0){
|
|
|
|
self.anxiety.update(ALPHAS[1]);
|
|
|
|
if(ALPHAS[1]==1){ // if fully visible...
|
|
|
|
ALPHAS[0] = 0; // hide everything under
|
|
|
|
}else{
|
|
|
|
ALPHAS[0] = 1; // show everything under
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-06 16:32:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
self.draw = function(ctx){
|
2019-06-11 14:45:09 +00:00
|
|
|
|
|
|
|
ctx.save();
|
|
|
|
|
|
|
|
for(var i=0; i<self.layers.length; i++){
|
|
|
|
var layer = self.layers[i];
|
|
|
|
layer.x = PARALLAXES[i] * parallax;// - OFFSETS[i];
|
|
|
|
if(ALPHAS[i]>0){
|
|
|
|
ctx.globalAlpha = ALPHAS[i];
|
|
|
|
layer.draw(ctx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.restore();
|
|
|
|
|
2019-06-06 16:32:57 +00:00
|
|
|
};
|
|
|
|
|
2019-06-11 18:31:28 +00:00
|
|
|
var STAGE = 0;
|
2019-06-06 16:32:57 +00:00
|
|
|
var _subscriptions = [];
|
|
|
|
_subscriptions.push(
|
|
|
|
subscribe("act2-out-1", function(){
|
2019-06-11 18:31:28 +00:00
|
|
|
STAGE = 1;
|
2019-06-11 14:45:09 +00:00
|
|
|
PARALLAXING = "out";
|
|
|
|
sfx("whoosh"); // WHOOSH
|
|
|
|
}),
|
2019-06-06 16:32:57 +00:00
|
|
|
subscribe("act2-in-2", function(){
|
2019-06-12 16:23:26 +00:00
|
|
|
|
|
|
|
// SHOW ACTION, HIDE CHARS
|
|
|
|
ALPHAS[2] = 1; // Party Action
|
|
|
|
ALPHAS[4] = 0; // Hong
|
|
|
|
ALPHAS[5] = 0; // Beebee
|
|
|
|
|
|
|
|
// WHOOSH
|
2019-06-11 18:31:28 +00:00
|
|
|
STAGE = 2;
|
2019-06-11 14:45:09 +00:00
|
|
|
PARALLAXING = "in";
|
2019-06-12 16:23:26 +00:00
|
|
|
sfx("whoosh");
|
|
|
|
|
2019-06-11 14:45:09 +00:00
|
|
|
}),
|
2019-06-06 16:32:57 +00:00
|
|
|
subscribe("act2-out-3", function(){
|
2019-06-11 18:31:28 +00:00
|
|
|
STAGE = 3;
|
2019-06-12 16:23:26 +00:00
|
|
|
PARALLAXING = "out";
|
2019-06-11 18:31:28 +00:00
|
|
|
sfx("whoosh"); // WHOOSH
|
2019-06-11 14:45:09 +00:00
|
|
|
}),
|
2019-06-06 16:32:57 +00:00
|
|
|
subscribe("act2-in-4", function(){
|
2019-06-12 16:23:26 +00:00
|
|
|
|
|
|
|
// SHOW ACTION, HIDE CHARS
|
|
|
|
ALPHAS[2] = 1; // Party Action
|
|
|
|
ALPHAS[4] = 0; // Hong
|
|
|
|
ALPHAS[5] = 0; // Beebee
|
|
|
|
|
|
|
|
// WHOOSH
|
2019-06-11 18:31:28 +00:00
|
|
|
STAGE = 4;
|
2019-06-12 16:23:26 +00:00
|
|
|
PARALLAXING = "in";
|
|
|
|
sfx("whoosh");
|
|
|
|
|
2019-06-11 14:45:09 +00:00
|
|
|
}),
|
2019-06-06 16:32:57 +00:00
|
|
|
subscribe("act2-out-5", function(){
|
2019-06-11 18:31:28 +00:00
|
|
|
STAGE = 5;
|
|
|
|
PARALLAXING = "out";
|
2019-06-12 16:23:26 +00:00
|
|
|
}),
|
|
|
|
subscribe("act2-party-action", function(frameName){
|
|
|
|
self.partyActionSprite.gotoFrameByName(frameName);
|
|
|
|
}),
|
|
|
|
subscribe("act2-outro", function(frameName){
|
|
|
|
self.outroSprite.gotoFrameByName(frameName);
|
2019-06-12 19:08:32 +00:00
|
|
|
}),
|
|
|
|
subscribe("show_special_attack", function(){
|
|
|
|
var dom = $("#special_attack");
|
|
|
|
dom.setAttribute("attack", _.SPECIAL_ATTACK);
|
|
|
|
dom.style.display = "block";
|
|
|
|
}),
|
|
|
|
subscribe("remove_special_attack", function(){
|
|
|
|
var dom = $("#special_attack");
|
|
|
|
dom.style.display = "none";
|
2019-06-11 14:45:09 +00:00
|
|
|
})
|
2019-06-06 16:32:57 +00:00
|
|
|
);
|
|
|
|
|
2019-06-18 20:21:14 +00:00
|
|
|
self.kill = function(){
|
|
|
|
_subscriptions.forEach(unsubscribe);
|
|
|
|
};
|
|
|
|
|
2019-06-06 16:32:57 +00:00
|
|
|
}
|