2019-06-06 16:32:57 +00:00
|
|
|
Loader.addImages([
|
2019-07-17 16:16:02 +00:00
|
|
|
|
2019-06-06 16:32:57 +00:00
|
|
|
{ id:"party_bg", src:"sprites/act2/party_bg.png" },
|
2019-07-17 16:16:02 +00:00
|
|
|
|
|
|
|
{ id:"dee", src:"sprites/act2/dee.png" },
|
|
|
|
{ id:"dum", src:"sprites/act2/dum.png" },
|
|
|
|
{ id:"party_hunter", src:"sprites/act2/party_hunter.png" },
|
|
|
|
{ id:"party_hong", src:"sprites/act2/party_hong.png" },
|
|
|
|
|
|
|
|
{ id:"act2_end", src:"sprites/act2/act2_end.png" },
|
|
|
|
|
2019-06-12 19:08:32 +00:00
|
|
|
{ id:"SPECIAL_ATTACK", src:"sprites/act2/special.png" },
|
2019-07-17 16:16:02 +00:00
|
|
|
|
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;
|
|
|
|
|
2019-07-17 16:16:02 +00:00
|
|
|
// BACKGROUND SPRITES
|
|
|
|
var BGSpriteConfig = {
|
2019-06-06 16:32:57 +00:00
|
|
|
image: Library.images.party_bg,
|
2019-07-17 16:16:02 +00:00
|
|
|
grid:{ width:5, height:1 },
|
|
|
|
frame:{ width:1000, height:1200 },
|
|
|
|
};
|
|
|
|
self.bg = new Sprite(BGSpriteConfig);
|
|
|
|
self.bg_peeps = new Sprite(BGSpriteConfig);
|
|
|
|
self.bg_peeps.gotoFrame(1);
|
|
|
|
self.couch = new Sprite(BGSpriteConfig);
|
|
|
|
self.couch.gotoFrame(3);
|
|
|
|
self.alshire = new Sprite(BGSpriteConfig);
|
|
|
|
self.alshire.gotoFrame(4);
|
|
|
|
|
|
|
|
// DEE & DUM
|
|
|
|
self.dee = new Sprite({
|
|
|
|
image: Library.images.dee,
|
|
|
|
grid:{ width:4, height:2 },
|
|
|
|
frame:{ width:400, height:400 },
|
2019-06-06 16:32:57 +00:00
|
|
|
});
|
2019-07-17 16:16:02 +00:00
|
|
|
self.dum = new Sprite({
|
|
|
|
image: Library.images.dum,
|
2019-06-11 18:31:28 +00:00
|
|
|
grid:{ width:4, height:2 },
|
2019-07-17 16:16:02 +00:00
|
|
|
frame:{ width:400, height:400 },
|
|
|
|
});
|
|
|
|
self.dee.y = self.dum.y = 275;
|
|
|
|
|
|
|
|
// HUNTER & HONG SPRITES
|
|
|
|
self.party_hunter = new Sprite({
|
|
|
|
image: Library.images.party_hunter,
|
|
|
|
grid:{ width:4, height:6 },
|
|
|
|
frame:{ width:720, height:500 },
|
|
|
|
});
|
|
|
|
self.party_hunter.y = 217;
|
|
|
|
self.party_hong = new Sprite({
|
|
|
|
image: Library.images.party_hong,
|
|
|
|
grid:{ width:6, height:7 },
|
|
|
|
frame:{ width:720, height:500 },
|
|
|
|
});
|
|
|
|
self.party_hong.y = 258.5;
|
|
|
|
self.party_hong.gotoFrame(0);
|
|
|
|
|
|
|
|
// HONG & BB FINALE
|
|
|
|
self.act2_end = new Sprite({
|
|
|
|
image: Library.images.act2_end,
|
|
|
|
grid:{ width:6, height:3 },
|
2019-06-11 18:31:28 +00:00
|
|
|
frame:{ width:720, height:400 },
|
2019-07-17 16:16:02 +00:00
|
|
|
y: 260
|
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 = [
|
2019-07-17 16:16:02 +00:00
|
|
|
|
|
|
|
self.bg,
|
|
|
|
self.bg_peeps,
|
|
|
|
self.dee,
|
|
|
|
self.dum,
|
|
|
|
self.party_hunter,
|
|
|
|
|
2019-06-11 14:45:09 +00:00
|
|
|
self.anxiety,
|
2019-07-17 16:16:02 +00:00
|
|
|
self.party_hong,
|
|
|
|
|
2019-06-11 18:31:28 +00:00
|
|
|
self.hong,
|
|
|
|
self.beebee,
|
2019-07-17 16:16:02 +00:00
|
|
|
self.act2_end,
|
|
|
|
|
|
|
|
self.couch,
|
|
|
|
self.alshire
|
|
|
|
|
2019-06-11 14:45:09 +00:00
|
|
|
];
|
|
|
|
var PARALLAXES = [
|
2019-07-17 16:16:02 +00:00
|
|
|
|
|
|
|
0.1, // party bg
|
|
|
|
0.5, // party bg peeps
|
|
|
|
0.9, // dee
|
|
|
|
0.9, // dum
|
|
|
|
1.0, // hunter (at first...)
|
|
|
|
|
2019-06-11 14:45:09 +00:00
|
|
|
0.0, // anxiety bg
|
2019-07-17 16:16:02 +00:00
|
|
|
|
|
|
|
1.0, // party hong
|
|
|
|
|
2019-06-11 18:31:28 +00:00
|
|
|
0.0, // battle hong
|
2019-07-17 16:16:02 +00:00
|
|
|
1.0, // battle beebee
|
|
|
|
0.0, // act2 end
|
|
|
|
|
|
|
|
2.1, // couch
|
|
|
|
2.2, // al shire
|
|
|
|
|
|
|
|
];
|
|
|
|
var OFFSETS = [
|
|
|
|
|
|
|
|
0, // party bg
|
|
|
|
0, // party bg peeps
|
|
|
|
0, // dee
|
|
|
|
0, // dum
|
|
|
|
0, // hunter (at first...)
|
|
|
|
|
|
|
|
0, // anxiety bg
|
|
|
|
|
|
|
|
20, // party hong
|
|
|
|
|
|
|
|
0, // battle hong
|
|
|
|
240, // battle beebee
|
|
|
|
0, // act2 end
|
|
|
|
|
|
|
|
0, // couch
|
|
|
|
0, // al shire
|
|
|
|
|
2019-06-11 14:45:09 +00:00
|
|
|
];
|
|
|
|
var ALPHAS = [
|
2019-07-17 16:16:02 +00:00
|
|
|
|
2019-06-11 14:45:09 +00:00
|
|
|
1.0, // party bg
|
2019-07-17 16:16:02 +00:00
|
|
|
1.0, // party bg peeps
|
|
|
|
1.0, // dee
|
|
|
|
1.0, // dum
|
|
|
|
1.0, // hunter (at first...)
|
|
|
|
|
2019-06-11 14:45:09 +00:00
|
|
|
0.0, // anxiety bg
|
2019-07-17 16:16:02 +00:00
|
|
|
|
|
|
|
1.0, // party hong
|
|
|
|
|
2019-06-11 18:31:28 +00:00
|
|
|
0.0, // battle hong
|
|
|
|
0.0, // battle beebee
|
2019-07-17 16:16:02 +00:00
|
|
|
0.0, // act2 end
|
|
|
|
|
|
|
|
1.0, // couch
|
|
|
|
1.0, // al shire
|
|
|
|
|
2019-06-11 14:45:09 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
var parallax = 0;
|
|
|
|
var parallaxTicker = 0;
|
|
|
|
var PARALLAXING = null;
|
2019-07-17 16:16:02 +00:00
|
|
|
var MAGIC_NUMBER = 230;
|
|
|
|
var ticker = 0;
|
|
|
|
var ticker2 = 0;
|
|
|
|
var ticker3 = 0;
|
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-07-17 16:16:02 +00:00
|
|
|
parallax = -t*MAGIC_NUMBER; // MAGIC NUMBER
|
2019-06-11 14:45:09 +00:00
|
|
|
|
|
|
|
// Anxiety Alpha
|
2019-07-17 16:16:02 +00:00
|
|
|
ALPHAS[5] = t;
|
2019-06-11 14:45:09 +00:00
|
|
|
|
|
|
|
// 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-07-17 16:16:02 +00:00
|
|
|
ALPHAS[6] = 0; // HIDE Party Hong
|
|
|
|
ALPHAS[7] = 1; // SHOW Battle Hong
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stage 2 end
|
|
|
|
if(STAGE==2){
|
|
|
|
ALPHAS[8] = 0; // HIDE Battle Beebee
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stage 4 end
|
|
|
|
if(STAGE==4){
|
|
|
|
ticker = 0;
|
2019-07-22 19:47:57 +00:00
|
|
|
ALPHAS[8] = 0; // HIDE Battle Beebee
|
2019-06-11 18:31:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Stage 5 transition end
|
|
|
|
if(STAGE==5){
|
2019-07-17 16:16:02 +00:00
|
|
|
ALPHAS[6] = 0; // HIDE Party Hong
|
|
|
|
ALPHAS[9] = 1; // SHOW End
|
|
|
|
self.act2_end.gotoFrame(1);
|
2019-06-11 18:31:28 +00:00
|
|
|
}
|
|
|
|
|
2019-07-22 19:47:57 +00:00
|
|
|
}else{
|
|
|
|
if(STAGE==4){
|
|
|
|
OFFSETS[8] += 2; // BYE BB
|
|
|
|
}
|
2019-06-11 14:45:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Anxiety BG
|
2019-07-17 16:16:02 +00:00
|
|
|
if(ALPHAS[5]>0){
|
|
|
|
self.anxiety.update(ALPHAS[5]);
|
|
|
|
if(ALPHAS[5]==1){ // if fully visible...
|
|
|
|
// hide everything under
|
|
|
|
ALPHAS[0] = 0;
|
|
|
|
ALPHAS[1] = 0;
|
|
|
|
ALPHAS[2] = 0;
|
|
|
|
ALPHAS[3] = 0;
|
|
|
|
ALPHAS[4] = 0;
|
2019-06-11 14:45:09 +00:00
|
|
|
}else{
|
2019-07-17 16:16:02 +00:00
|
|
|
// show everything under
|
|
|
|
ALPHAS[0] = 1;
|
|
|
|
ALPHAS[1] = 1;
|
|
|
|
ALPHAS[2] = 1;
|
|
|
|
ALPHAS[3] = 1;
|
|
|
|
ALPHAS[4] = 1;
|
2019-06-11 14:45:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-17 16:16:02 +00:00
|
|
|
// SUPER HACKY - ANIMATE PARTY-HONG
|
|
|
|
if(self.party_hong.currentFrame>=5 && self.party_hong.currentFrame<11){
|
|
|
|
if(ticker<1/20){
|
|
|
|
ticker += 1/60;
|
|
|
|
}else{
|
|
|
|
ticker = 0;
|
|
|
|
self.party_hong.nextFrame();
|
|
|
|
}
|
|
|
|
}else if(self.party_hong.currentFrame>=26 && self.party_hong.currentFrame<32){
|
|
|
|
if(ticker<1/15){
|
|
|
|
ticker += 1/60;
|
|
|
|
}else{
|
|
|
|
ticker = 0;
|
|
|
|
self.party_hong.nextFrame();
|
|
|
|
}
|
|
|
|
}else if(self.party_hong.currentFrame>=36 && self.party_hong.currentFrame<=39){
|
|
|
|
if(ticker<1/15){
|
|
|
|
ticker += 1/60;
|
|
|
|
}else{
|
|
|
|
ticker = 0;
|
|
|
|
if(self.party_hong.currentFrame==39){
|
|
|
|
self.party_hong.gotoFrame(36);
|
|
|
|
}else{
|
|
|
|
self.party_hong.nextFrame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
ticker = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SUPER HACKY - ANIMATE PARTY-HUNTER
|
|
|
|
if(self.party_hunter.currentFrame>=19 && self.party_hunter.currentFrame<=20){
|
|
|
|
if(ticker2<1/3){
|
|
|
|
ticker2 += 1/60;
|
|
|
|
}else{
|
|
|
|
ticker2 = 0;
|
|
|
|
if(self.party_hunter.currentFrame==20){
|
|
|
|
self.party_hunter.gotoFrame(19);
|
|
|
|
}else{
|
|
|
|
self.party_hunter.nextFrame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
ticker2 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SUPER HACKER - ANIMATE THE END
|
|
|
|
if(self.act2_end.currentFrame>=2 && self.act2_end.currentFrame<10){
|
|
|
|
if(ticker3<1/15){
|
|
|
|
ticker3 += 1/60;
|
|
|
|
}else{
|
|
|
|
ticker3 = 0;
|
|
|
|
self.act2_end.nextFrame();
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
ticker3 = 0;
|
|
|
|
}
|
|
|
|
|
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];
|
2019-07-17 16:16:02 +00:00
|
|
|
layer.x = PARALLAXES[i] * parallax + OFFSETS[i];
|
2019-06-11 14:45:09 +00:00
|
|
|
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(
|
2019-07-17 16:16:02 +00:00
|
|
|
subscribe("act2", function(thing, frame){
|
2019-07-22 19:47:57 +00:00
|
|
|
if(typeof frame=="string"){
|
|
|
|
if(frame=="next"){
|
|
|
|
self[thing].nextFrame();
|
|
|
|
}else{
|
|
|
|
self[thing].gotoFrameByName(frame);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
self[thing].gotoFrame(frame);
|
|
|
|
}
|
2019-07-17 16:16:02 +00:00
|
|
|
}),
|
2019-06-06 16:32:57 +00:00
|
|
|
subscribe("act2-out-1", function(){
|
2019-07-17 16:16:02 +00:00
|
|
|
|
|
|
|
// ANIMATE PARTY HONG
|
|
|
|
ticker = 0;
|
|
|
|
self.party_hong.gotoFrame(5);
|
|
|
|
|
2019-06-11 18:31:28 +00:00
|
|
|
STAGE = 1;
|
2019-06-11 14:45:09 +00:00
|
|
|
PARALLAXING = "out";
|
|
|
|
sfx("whoosh"); // WHOOSH
|
2019-07-17 16:16:02 +00:00
|
|
|
ALPHAS[8] = 1; // SHOW Battle Beebee
|
2019-06-11 14:45:09 +00:00
|
|
|
}),
|
2019-06-06 16:32:57 +00:00
|
|
|
subscribe("act2-in-2", function(){
|
2019-06-12 16:23:26 +00:00
|
|
|
|
2019-07-17 16:16:02 +00:00
|
|
|
MAGIC_NUMBER = 210;
|
|
|
|
OFFSETS[8] = 220; // BB
|
|
|
|
|
|
|
|
// Dee & Dum! And Al-Shire is gone. And BG peeps change
|
|
|
|
self.dee.gotoFrame(4);
|
|
|
|
self.dum.gotoFrame(4);
|
|
|
|
self.bg_peeps.gotoFrame(2);
|
|
|
|
self.alshire.visible = false;
|
|
|
|
|
|
|
|
// Party Hong
|
2019-07-22 19:47:57 +00:00
|
|
|
self.party_hunter.gotoFrame(3); // look right
|
2019-07-17 16:16:02 +00:00
|
|
|
self.party_hong.gotoFrame(12); // look left
|
|
|
|
|
|
|
|
ALPHAS[6] = 1; // SHOW Party Hong
|
|
|
|
ALPHAS[7] = 0; // HIDE Battle Hong
|
2019-06-12 16:23:26 +00:00
|
|
|
|
|
|
|
// 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-07-17 16:16:02 +00:00
|
|
|
|
|
|
|
MAGIC_NUMBER = 150;
|
|
|
|
PARALLAXES[10] = 3.2; // COUCH
|
|
|
|
OFFSETS[8] = 170; // BB
|
|
|
|
|
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-07-17 16:16:02 +00:00
|
|
|
ALPHAS[8] = 1; // SHOW Battle Beebee
|
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
|
|
|
|
2019-07-17 16:16:02 +00:00
|
|
|
// Dee & Dum
|
|
|
|
self.dee.gotoFrame(5);
|
|
|
|
self.dum.gotoFrame(5);
|
|
|
|
|
|
|
|
// Party Hunter & Hong
|
|
|
|
self.party_hunter.gotoFrame(13); // disappointed
|
|
|
|
self.party_hong.gotoFrame(25); // shocked
|
|
|
|
|
|
|
|
ALPHAS[6] = 1; // SHOW Party Hong
|
|
|
|
ALPHAS[7] = 0; // HIDE Battle Hong
|
2019-07-22 19:47:57 +00:00
|
|
|
//ALPHAS[8] = 0; // HIDE Battle Beebee
|
2019-06-12 16:23:26 +00:00
|
|
|
|
|
|
|
// 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-07-17 16:16:02 +00:00
|
|
|
|
|
|
|
// RUN FAST, PARALLAX
|
|
|
|
PARALLAXES[0] *= 3;
|
|
|
|
PARALLAXES[1] *= 3;
|
|
|
|
PARALLAXES[2] *= 3;
|
|
|
|
PARALLAXES[3] *= 3;
|
|
|
|
PARALLAXES[4] *= 3;
|
|
|
|
PARALLAXES[10] *= 3;
|
|
|
|
|
2019-06-11 18:31:28 +00:00
|
|
|
STAGE = 5;
|
|
|
|
PARALLAXING = "out";
|
2019-06-12 16:23:26 +00:00
|
|
|
}),
|
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
|
|
|
}
|