2019-06-14 15:03:30 +00:00
|
|
|
Loader.addImages([
|
|
|
|
{ id:"rooftop_bg", src:"sprites/act3/rooftop_bg.png" },
|
|
|
|
{ id:"rooftop_hunter", src:"sprites/act3/hunter.png" },
|
2019-06-26 15:03:27 +00:00
|
|
|
{ id:"rooftop_hong", src:"sprites/act3/hong.png" },
|
2019-07-29 19:43:38 +00:00
|
|
|
{ id:"rooftop_dd", src:"sprites/act3/dd.png" },
|
|
|
|
{ id:"dizzy", src:"sprites/act3/dizzy.png" },
|
2019-06-26 15:03:27 +00:00
|
|
|
{ id:"hospital", src:"sprites/act3/hospital.png" },
|
|
|
|
]);
|
|
|
|
|
|
|
|
Loader.addSounds([
|
|
|
|
{ id:"lock_door", src:"sounds/sfx/lock_door.mp3" }
|
2019-06-14 15:03:30 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
function BG_Rooftop(){
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
2019-07-29 19:43:38 +00:00
|
|
|
// BACKGROUND SPRITES
|
|
|
|
var BGSpriteConfig = {
|
2019-06-14 15:03:30 +00:00
|
|
|
image: Library.images.rooftop_bg,
|
2019-07-29 19:43:38 +00:00
|
|
|
grid:{ width:2, height:2 },
|
|
|
|
frame:{ width:1400, height:1200 },
|
|
|
|
};
|
|
|
|
self.bg = new Sprite(BGSpriteConfig);
|
|
|
|
self.skyline = new Sprite(BGSpriteConfig);
|
|
|
|
self.skyline.gotoFrame(1);
|
|
|
|
self.clouds = new Sprite(BGSpriteConfig);
|
|
|
|
self.clouds.gotoFrame(2);
|
|
|
|
self.roof = new Sprite(BGSpriteConfig);
|
|
|
|
self.roof.gotoFrame(3);
|
|
|
|
|
|
|
|
// ROOF HUNTER, HONG, DEEDUM, DIZZIES
|
|
|
|
self.roofhunter = new Sprite({
|
2019-06-14 15:03:30 +00:00
|
|
|
image: Library.images.rooftop_hunter,
|
2019-07-29 19:43:38 +00:00
|
|
|
grid:{ width:8, height:5 },
|
|
|
|
frame:{ width:400, height:360 },
|
|
|
|
y: 219
|
2019-06-14 15:03:30 +00:00
|
|
|
});
|
2019-07-29 19:43:38 +00:00
|
|
|
self.roofhong = new Sprite({
|
2019-06-14 15:03:30 +00:00
|
|
|
image: Library.images.rooftop_hong,
|
2019-07-29 19:43:38 +00:00
|
|
|
grid:{ width:8, height:8 },
|
2019-06-14 15:03:30 +00:00
|
|
|
frame:{ width:720, height:800 },
|
|
|
|
y: 225
|
|
|
|
});
|
2019-07-29 19:43:38 +00:00
|
|
|
self.dd = new Sprite({
|
|
|
|
image: Library.images.rooftop_dd,
|
|
|
|
grid:{ width:4, height:2 },
|
|
|
|
frame:{ width:240, height:120 },
|
|
|
|
y: 300
|
|
|
|
});
|
|
|
|
var DizzySpriteConfig = {
|
|
|
|
image: Library.images.dizzy,
|
|
|
|
grid:{ width:4, height:2 },
|
|
|
|
frame:{ width:50, height:50 }
|
|
|
|
}
|
|
|
|
self.dizzyhunter = new Sprite(DizzySpriteConfig);
|
|
|
|
self.dizzyhunter.y = 205;
|
|
|
|
self.dizzyhong = new Sprite(DizzySpriteConfig);
|
|
|
|
self.dizzyhong.y = 221;
|
|
|
|
|
|
|
|
// Anxiety BG - TODO: ALL BOXES FALL DOWN
|
2019-06-14 15:03:30 +00:00
|
|
|
self.anxiety = new BG_Anxiety();
|
|
|
|
|
|
|
|
// Characters
|
|
|
|
self.hong = new Act3_Hong();
|
|
|
|
self.beebee = new Act3_Beebee();
|
|
|
|
|
2019-06-26 15:03:27 +00:00
|
|
|
// Hospital scene
|
|
|
|
self.hospitalSprite = new Sprite({
|
|
|
|
image: Library.images.hospital,
|
|
|
|
grid:{ width:4, height:1 },
|
|
|
|
frame:{ width:720, height:1200 },
|
|
|
|
});
|
|
|
|
self.hospitalSprite.visible = false;
|
|
|
|
|
2019-07-29 19:43:38 +00:00
|
|
|
////////////////////////////////////////
|
|
|
|
// LAYERS //////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
|
2019-06-14 15:03:30 +00:00
|
|
|
self.layers = [
|
2019-07-29 19:43:38 +00:00
|
|
|
|
|
|
|
self.bg,
|
|
|
|
self.skyline,
|
|
|
|
self.clouds,
|
|
|
|
self.roof,
|
|
|
|
|
|
|
|
self.roofhunter,
|
|
|
|
self.dd,
|
|
|
|
self.dizzyhunter,
|
|
|
|
self.dizzyhong,
|
|
|
|
self.roofhong,
|
|
|
|
|
2019-06-14 15:03:30 +00:00
|
|
|
self.anxiety,
|
|
|
|
self.hong,
|
2019-07-29 19:43:38 +00:00
|
|
|
self.beebee,
|
|
|
|
|
2019-06-14 15:03:30 +00:00
|
|
|
];
|
|
|
|
var PARALLAXES = [
|
2019-07-29 19:43:38 +00:00
|
|
|
|
|
|
|
0.05, // bg
|
|
|
|
0.1, // skyline
|
|
|
|
0.0, // clouds
|
|
|
|
0.3, // roof
|
|
|
|
|
|
|
|
0.5, // roofhunter
|
|
|
|
0.5, // dd
|
|
|
|
0.5, // dizzyhunter
|
|
|
|
0.5, // dizzyhong
|
|
|
|
1.0, // roofhong
|
|
|
|
|
|
|
|
0.0, // anxiety
|
|
|
|
0.0, // hong
|
|
|
|
0.0, // beebee
|
|
|
|
|
|
|
|
];
|
|
|
|
var OFFSETS = [
|
|
|
|
|
|
|
|
0, // bg
|
|
|
|
0, // skyline
|
|
|
|
0, // clouds
|
|
|
|
0, // roof
|
|
|
|
|
|
|
|
0, // roofhunter
|
|
|
|
0, // dd
|
|
|
|
79, // dizzyhunter
|
|
|
|
211, // dizzyhong
|
|
|
|
0, // roofhong
|
|
|
|
|
|
|
|
0, // anxiety
|
|
|
|
0, // hong
|
|
|
|
0, // beebee
|
|
|
|
|
2019-06-14 15:03:30 +00:00
|
|
|
];
|
|
|
|
var ALPHAS = [
|
2019-07-29 19:43:38 +00:00
|
|
|
|
|
|
|
1, // bg
|
|
|
|
1, // skyline
|
|
|
|
1, // clouds
|
|
|
|
1, // roof
|
|
|
|
|
|
|
|
1, // roofhunter
|
|
|
|
1, // dd
|
|
|
|
1, // dizzyhunter
|
|
|
|
1, // dizzyhong
|
|
|
|
1, // roofhong
|
|
|
|
|
|
|
|
0, // anxiety
|
|
|
|
0, // hong
|
|
|
|
0, // beebee
|
|
|
|
|
2019-06-14 15:03:30 +00:00
|
|
|
];
|
|
|
|
|
2019-07-29 19:43:38 +00:00
|
|
|
|
2019-06-14 15:03:30 +00:00
|
|
|
var parallax = 0;
|
|
|
|
var parallaxTicker = 0;
|
|
|
|
var PARALLAXING = null;
|
2019-07-29 19:43:38 +00:00
|
|
|
var ticker = 0;
|
2019-06-14 15:03:30 +00:00
|
|
|
self.update = function(){
|
|
|
|
|
|
|
|
// 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
|
|
|
|
parallax = -t*190;
|
|
|
|
|
|
|
|
// Anxiety Alpha
|
2019-07-29 19:43:38 +00:00
|
|
|
//ALPHAS[2] = t;
|
2019-06-14 15:03:30 +00:00
|
|
|
|
|
|
|
// DONE
|
|
|
|
if(t==1 || t==0){
|
|
|
|
PARALLAXING = null;
|
|
|
|
|
|
|
|
// Stage 1 transition end
|
2019-07-29 19:43:38 +00:00
|
|
|
/*if(STAGE==1){
|
2019-06-14 15:03:30 +00:00
|
|
|
ALPHAS[1] = 0; // HIDE Hunter
|
|
|
|
ALPHAS[3] = 0; // HIDE Old Hong
|
|
|
|
ALPHAS[4] = 1; // SHOW new hong
|
|
|
|
ALPHAS[5] = 1; // SHOW Beebee
|
2019-07-29 19:43:38 +00:00
|
|
|
}*/
|
2019-06-14 15:03:30 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-07-29 19:43:38 +00:00
|
|
|
// SUPER HACKY - ANIMATE THE DIZZIES
|
|
|
|
ticker += 1/60;
|
|
|
|
var fps = 4;
|
|
|
|
var frame = Math.round(ticker*fps) % 4; // fps times a second
|
|
|
|
self.dizzyhunter.gotoFrame(frame);
|
|
|
|
var frame = Math.round(ticker*fps) % 4 + 4; // fps times a second
|
|
|
|
self.dizzyhong.gotoFrame(frame);
|
|
|
|
|
2019-06-14 15:03:30 +00:00
|
|
|
// Anxiety BG
|
2019-07-29 19:43:38 +00:00
|
|
|
/*if(ALPHAS[2]>0){
|
2019-06-14 15:03:30 +00:00
|
|
|
self.anxiety.update(ALPHAS[2]);
|
|
|
|
if(ALPHAS[2]==1){ // if fully visible...
|
|
|
|
ALPHAS[0] = 0; // hide everything under
|
|
|
|
}else{
|
|
|
|
ALPHAS[0] = 1; // show everything under
|
|
|
|
}
|
2019-07-29 19:43:38 +00:00
|
|
|
}*/
|
2019-06-14 15:03:30 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
self.draw = function(ctx){
|
|
|
|
|
|
|
|
ctx.save();
|
|
|
|
|
2019-06-26 15:03:27 +00:00
|
|
|
if(!self.hospitalSprite.visible){
|
|
|
|
|
|
|
|
for(var i=0; i<self.layers.length; i++){
|
|
|
|
var layer = self.layers[i];
|
2019-07-29 19:43:38 +00:00
|
|
|
layer.x = PARALLAXES[i] * parallax + OFFSETS[i];
|
2019-06-26 15:03:27 +00:00
|
|
|
if(ALPHAS[i]>0){
|
|
|
|
ctx.globalAlpha = ALPHAS[i];
|
|
|
|
layer.draw(ctx);
|
|
|
|
}
|
2019-06-14 15:03:30 +00:00
|
|
|
}
|
2019-06-26 15:03:27 +00:00
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
self.hospitalSprite.draw(ctx);
|
|
|
|
|
2019-06-14 15:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ctx.restore();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var STAGE = 0;
|
|
|
|
var _subscriptions = [];
|
|
|
|
_subscriptions.push(
|
|
|
|
subscribe("act3-out", function(){
|
|
|
|
STAGE = 1;
|
|
|
|
PARALLAXING = "out";
|
|
|
|
sfx("whoosh"); // WHOOSH
|
|
|
|
}),
|
|
|
|
subscribe("act3-in", function(){
|
|
|
|
|
|
|
|
// SHOW ACTION, HIDE CHARS
|
2019-07-29 19:43:38 +00:00
|
|
|
/*
|
2019-06-14 15:03:30 +00:00
|
|
|
ALPHAS[1] = 1; // SHOW Hunter
|
|
|
|
ALPHAS[3] = 1; // SHOW Roof Hong
|
|
|
|
ALPHAS[4] = 0; // HIDE battle Hong
|
|
|
|
ALPHAS[5] = 0; // HIDE battle Beebee
|
2019-07-29 19:43:38 +00:00
|
|
|
*/
|
2019-06-14 15:03:30 +00:00
|
|
|
|
|
|
|
// WHOOSH
|
|
|
|
STAGE = 2;
|
|
|
|
PARALLAXING = "in";
|
|
|
|
sfx("whoosh");
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
2019-06-14 16:02:25 +00:00
|
|
|
// HUNTER FRAME
|
|
|
|
subscribe("hunter-roof", function(frameName){
|
|
|
|
self.hunterSprite.gotoFrameByName(frameName);
|
|
|
|
}),
|
|
|
|
|
2019-06-14 15:03:30 +00:00
|
|
|
// JUMP OFF
|
|
|
|
subscribe("start-jump-anim", function(){
|
|
|
|
self.hongSprite.gotoFrame(4);
|
2019-07-08 18:37:46 +00:00
|
|
|
self.hunterSprite.gotoFrameByName("front_badass");
|
2019-06-14 15:03:30 +00:00
|
|
|
}),
|
|
|
|
subscribe("hong-next", function(){
|
|
|
|
self.hongSprite.nextFrame();
|
|
|
|
}),
|
|
|
|
|
|
|
|
// WALK AWAY
|
|
|
|
subscribe("start-walkaway-anim", function(){
|
|
|
|
self.hongSprite.gotoFrame(23);
|
2019-07-04 14:16:45 +00:00
|
|
|
self.hunterSprite.gotoFrameByName("side_neutral");
|
2019-06-26 15:03:27 +00:00
|
|
|
}),
|
|
|
|
|
|
|
|
// INJURY
|
|
|
|
subscribe("act4-injury-show", function(frame){
|
|
|
|
self.hospitalSprite.visible = true;
|
|
|
|
}),
|
|
|
|
subscribe("act4-injury", function(frame){
|
|
|
|
self.hospitalSprite.gotoFrame(frame);
|
2019-06-14 15:03:30 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2019-06-18 20:21:14 +00:00
|
|
|
self.kill = function(){
|
|
|
|
_subscriptions.forEach(unsubscribe);
|
|
|
|
};
|
|
|
|
|
2019-06-14 15:03:30 +00:00
|
|
|
}
|