2019-04-09 18:59:19 +00:00
|
|
|
Loader.addImages([
|
2019-04-18 11:40:22 +00:00
|
|
|
{ id:"act1_hong", src:"sprites/act1/act1_hong.png" }
|
2019-04-09 18:59:19 +00:00
|
|
|
]);
|
|
|
|
|
2019-02-22 23:48:24 +00:00
|
|
|
function Act1_Hong(){
|
2019-02-18 17:24:52 +00:00
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
2019-04-18 11:40:22 +00:00
|
|
|
// SPRITE CONFIG!
|
|
|
|
var spriteConfig = {
|
2019-02-22 23:48:24 +00:00
|
|
|
image: Library.images.act1_hong,
|
2019-02-18 17:24:52 +00:00
|
|
|
grid:{
|
2019-02-18 20:59:10 +00:00
|
|
|
width: 4,
|
2019-04-11 18:44:15 +00:00
|
|
|
height: 10
|
2019-02-18 17:24:52 +00:00
|
|
|
},
|
|
|
|
frame:{
|
2019-04-11 18:44:15 +00:00
|
|
|
width: 720,
|
|
|
|
height: 500
|
2019-02-18 17:24:52 +00:00
|
|
|
},
|
|
|
|
anchor:{
|
2019-04-11 18:44:15 +00:00
|
|
|
x: 122/2,
|
|
|
|
y: 404/2
|
2019-02-18 17:24:52 +00:00
|
|
|
},
|
|
|
|
frameNames:[
|
2019-04-11 18:44:15 +00:00
|
|
|
|
2019-04-18 11:40:22 +00:00
|
|
|
"body_0_sammich_no_outline",
|
|
|
|
"body_0_sammich",
|
|
|
|
"eyes_0_neutral",
|
|
|
|
"eyes_0_concerned",
|
|
|
|
"eyes_0_shock",
|
|
|
|
"mouth_0_neutral",
|
|
|
|
"mouth_0_chew1",
|
|
|
|
"mouth_0_chew2",
|
|
|
|
"mouth_0_neutral_talk",
|
|
|
|
"mouth_0_shock",
|
|
|
|
|
|
|
|
"body_putaway*",
|
2019-04-11 18:44:15 +00:00
|
|
|
"body_phone1",
|
|
|
|
"body_phone2",
|
|
|
|
"eyes_neutral",
|
|
|
|
"eyes_annoyed",
|
|
|
|
"eyes_sad",
|
|
|
|
"eyes_shock",
|
|
|
|
"eyes_lookaway",
|
|
|
|
"eyes_anger",
|
|
|
|
"eyes_surprise",
|
|
|
|
"mouth_neutral",
|
|
|
|
"mouth_neutral_talk",
|
|
|
|
"mouth_smile",
|
|
|
|
"mouth_smile_talk",
|
|
|
|
"mouth_sad",
|
|
|
|
"mouth_sad_talk",
|
|
|
|
"mouth_shock",
|
|
|
|
"mouth_anger",
|
|
|
|
"mouth_anger_talk",
|
|
|
|
|
2019-04-18 11:40:22 +00:00
|
|
|
"body_2_tired*",
|
|
|
|
"body_2_fuck*",
|
|
|
|
"body_2_you*",
|
|
|
|
"body_2_sammich_eat*",
|
|
|
|
"body_2_sammich_eaten",
|
2019-04-11 18:44:15 +00:00
|
|
|
|
2019-04-18 11:40:22 +00:00
|
|
|
"body_3_defeated1*",
|
|
|
|
"body_3_defeated2*",
|
|
|
|
"body_3_defeated3*",
|
|
|
|
"body_3_defeated3_no_outline*"
|
2019-04-11 18:44:15 +00:00
|
|
|
|
2019-02-18 17:24:52 +00:00
|
|
|
],
|
2019-04-11 18:44:15 +00:00
|
|
|
x: 65,
|
2019-04-18 11:40:22 +00:00
|
|
|
y: 385+14
|
|
|
|
};
|
|
|
|
|
|
|
|
// ANIM LOOPS
|
|
|
|
var animLoops = [
|
|
|
|
{ target:"body", ifOnFrame:"phone1", wait:0.5, thenGoToFrame:"phone2" },
|
|
|
|
{ target:"body", ifOnFrame:"phone2", wait:0.5, thenGoToFrame:"phone1" }
|
|
|
|
];
|
|
|
|
|
|
|
|
// Inherit from Character!
|
|
|
|
Character.apply(self, [spriteConfig, animLoops]);
|
|
|
|
|
|
|
|
// Go To Frames!
|
|
|
|
self.gotoFrames({
|
|
|
|
body: "phone1",
|
|
|
|
mouth: "neutral",
|
|
|
|
eyes: "neutral",
|
2019-02-18 17:24:52 +00:00
|
|
|
});
|
2019-04-18 11:40:22 +00:00
|
|
|
var _subscriptions = [];
|
|
|
|
_subscriptions.push( subscribe("hong", self.gotoFrames) );
|
|
|
|
_subscriptions.push( subscribe("attack_hong", self.showAttackedIcon) );
|
2019-02-18 17:24:52 +00:00
|
|
|
|
2019-04-18 11:40:22 +00:00
|
|
|
// Draw
|
|
|
|
self.bounceHookes = 0.2; // stiff
|
|
|
|
self.bounceDamp = 0.8; // stiff
|
|
|
|
|
|
|
|
/*
|
2019-04-11 18:44:15 +00:00
|
|
|
|
2019-02-18 17:24:52 +00:00
|
|
|
// Draw
|
|
|
|
var ticker = 0;
|
|
|
|
self.draw = function(ctx){
|
|
|
|
|
2019-04-11 18:44:15 +00:00
|
|
|
self.sprite.update();
|
2019-02-18 20:59:10 +00:00
|
|
|
|
2019-02-18 17:24:52 +00:00
|
|
|
// Draw body FIRST
|
|
|
|
ticker++;
|
2019-04-18 11:40:22 +00:00
|
|
|
//var bod_frame = (Math.floor(ticker/30)%2 == 0) ? "body_phone1" : "body_phone2"; // phone flickering
|
|
|
|
self.sprite.gotoFrameByName("0_body_sammich");
|
2019-02-18 17:24:52 +00:00
|
|
|
self.sprite.draw(ctx);
|
|
|
|
|
2019-04-11 18:44:15 +00:00
|
|
|
// Draw mouth next
|
2019-04-18 11:40:22 +00:00
|
|
|
self.sprite.gotoFrameByName("0_mouth_neutral");
|
2019-02-18 17:24:52 +00:00
|
|
|
self.sprite.draw(ctx);
|
|
|
|
|
2019-04-11 18:44:15 +00:00
|
|
|
// Draw eyes finally
|
2019-04-18 11:40:22 +00:00
|
|
|
self.sprite.gotoFrameByName("0_eyes_neutral");
|
2019-04-11 18:44:15 +00:00
|
|
|
self.sprite.draw(ctx);
|
|
|
|
|
|
|
|
// Draw attacked icon
|
|
|
|
if(attackedIconShown){
|
|
|
|
|
|
|
|
var icon = self.fears[attackedIconShown];
|
|
|
|
icon.draw(ctx);
|
|
|
|
|
|
|
|
attackedTimer += 1/60;
|
|
|
|
if(attackedTimer>1.5){ // 1s
|
|
|
|
icon.y -= 1;
|
|
|
|
icon.alpha -= 1/15;
|
|
|
|
if(icon.alpha<0){
|
|
|
|
attackedIconShown = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// Show attacked icon!
|
|
|
|
var attackedIconShown = null;
|
|
|
|
var attackedTimer = 0;
|
|
|
|
self.showAttackedIcon = function(type){
|
|
|
|
attackedIconShown = type;
|
|
|
|
var icon = self.fears[attackedIconShown];
|
|
|
|
icon.x = 82;
|
|
|
|
icon.y = 230;
|
|
|
|
icon.alpha = 1;
|
|
|
|
attackedTimer = 0;
|
2019-02-18 17:24:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// When going to frames...
|
2019-04-11 18:44:15 +00:00
|
|
|
subscribe("hong", function(fname, options){
|
2019-02-25 14:33:32 +00:00
|
|
|
|
2019-04-11 18:44:15 +00:00
|
|
|
// If attacked, vibrate
|
2019-02-25 14:33:32 +00:00
|
|
|
if(fname=="attacked"){
|
|
|
|
|
2019-04-11 18:44:15 +00:00
|
|
|
//self.sprite.gotoFrameByName("shock");
|
|
|
|
//self.sprite.bounce = 1/1.5;
|
|
|
|
self.sprite.shakeAmp = 5;
|
|
|
|
self.sprite.shakeSpeed = 10;
|
|
|
|
self.sprite.shakeTimer = 0.5;
|
|
|
|
|
|
|
|
_mouth_frame = "mouth_shock";
|
|
|
|
_eyes_frame = "eyes_shock";
|
|
|
|
|
|
|
|
// Show an attack icon of type=options!
|
|
|
|
self.showAttackedIcon(options);
|
2019-02-25 14:33:32 +00:00
|
|
|
|
|
|
|
}else{
|
|
|
|
|
2019-04-11 18:44:15 +00:00
|
|
|
// Otherwise, go to that frame
|
2019-02-25 14:33:32 +00:00
|
|
|
self.sprite.gotoFrameByName(fname);
|
|
|
|
self.sprite.bounce = 1.05;
|
|
|
|
if(fname=="shock"){
|
|
|
|
self.sprite.bounce = 1/1.5;
|
|
|
|
}
|
|
|
|
|
2019-02-18 17:24:52 +00:00
|
|
|
}
|
2019-02-25 14:33:32 +00:00
|
|
|
|
2019-02-18 17:24:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Kill
|
|
|
|
self.kill = function(){
|
|
|
|
};
|
|
|
|
|
2019-04-18 11:40:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Kill!
|
|
|
|
self.kill = function(){
|
|
|
|
_subscriptions.forEach(unsubscribe);
|
|
|
|
};
|
|
|
|
|
2019-02-18 17:24:52 +00:00
|
|
|
}
|