anxiety/scripts/act1/Act1_Beebee.js

133 lines
3.0 KiB
JavaScript
Raw Normal View History

2019-04-09 18:59:19 +00:00
Loader.addImages([
{ id:"act1_beebee", src:"sprites/act1/act1_beebee.png" }
]);
2019-02-22 23:48:24 +00:00
function Act1_Beebee(){
2019-02-17 21:54:29 +00:00
var self = this;
2019-04-18 11:40:22 +00:00
// SPRITE CONFIG!
2019-03-17 18:41:19 +00:00
var spriteConfig = {
2019-02-22 23:48:24 +00:00
image: Library.images.act1_beebee,
2019-02-17 21:54:29 +00:00
grid:{
2019-03-17 18:41:19 +00:00
width: 4,
height: 8
2019-02-17 21:54:29 +00:00
},
frame:{
2019-03-17 18:41:19 +00:00
width: 720,
height: 500
2019-02-17 21:54:29 +00:00
},
anchor:{
2019-03-17 18:41:19 +00:00
x: 546/2,
y: 400/2
2019-02-17 21:54:29 +00:00
},
frameNames:[
2019-03-17 18:41:19 +00:00
"body_normal",
"body_fear",
"body_point_crotch",
"body_point_heart",
2019-04-19 15:57:10 +00:00
"body_sing",
2019-03-17 18:41:19 +00:00
2019-04-18 11:40:22 +00:00
"mouth_normal",
"mouth_normal_talk",
"mouth_small",
"mouth_small_talk",
2019-04-19 17:44:45 +00:00
"mouth_small_lock",
2019-03-17 18:41:19 +00:00
"eyes_normal",
"eyes_normal_right",
"eyes_uncertain",
"eyes_uncertain_right",
"eyes_narrow",
"eyes_narrow_eyebrow",
"eyes_fear",
"eyes_pretty",
"eyes_wat",
2019-04-19 15:57:10 +00:00
"eyes_wat_2",
2019-03-17 18:41:19 +00:00
2019-04-18 11:40:22 +00:00
"body_panic*",
"body_panic_2*",
"body_scream_anger*",
"body_scream_anger_2*",
"body_scream*",
"body_scream_2*",
2019-03-17 18:41:19 +00:00
2019-04-18 11:40:22 +00:00
"body_flail*",
"body_flail2*",
"body_flail3*",
"body_flail4*",
2019-03-17 18:41:19 +00:00
2019-04-19 15:57:10 +00:00
"mouth_smile",
"mouth_smile_talk",
"mouth_smile_lock",
"eyes_smile",
"eyes_look",
"eyes_look_sad",
"eyes_look_sad_smile",
"eyes_pained1",
"eyes_pained2",
"mouth_shut",
2019-05-05 19:56:00 +00:00
"eyes_anger",
"body_meta*"
2019-03-17 18:41:19 +00:00
2019-02-17 21:54:29 +00:00
],
2019-04-18 11:40:22 +00:00
x: 270-7.5,
y: 390+4.5
2019-03-17 18:41:19 +00:00
};
2019-04-18 11:40:22 +00:00
// ANIM LOOPS
var animLoops = [
2019-04-19 15:57:10 +00:00
{ target:"body", ifOnFrame:"panic*", wait:0.07, thenGoToFrame:"panic_2*" },
{ target:"body", ifOnFrame:"panic_2*", wait:0.07, thenGoToFrame:"panic*" },
{ target:"body", ifOnFrame:"scream_anger*", wait:0.1, thenGoToFrame:"scream_anger_2*" },
{ target:"body", ifOnFrame:"scream_anger_2*", wait:0.1, thenGoToFrame:"scream_anger*" },
{ target:"body", ifOnFrame:"scream*", wait:0.1, thenGoToFrame:"scream_2*" },
{ target:"body", ifOnFrame:"scream_2*", wait:0.1, thenGoToFrame:"scream*" },
2019-04-18 11:40:22 +00:00
{ target:"body", ifOnFrame:"flail*", wait:0.05, thenGoToFrame:"flail2*" },
{ target:"body", ifOnFrame:"flail2*", wait:0.05, thenGoToFrame:"flail3*" },
{ target:"body", ifOnFrame:"flail3*", wait:0.05, thenGoToFrame:"flail4*" },
{ target:"body", ifOnFrame:"flail4*", wait:0.05, thenGoToFrame:"flail*" }
];
// Inherit from Character!
Character.apply(self, [spriteConfig, animLoops]);
// Go To Frames!
self.gotoFrames({
body: "normal",
2019-04-19 15:57:10 +00:00
mouth: "normal",
eyes: "normal",
2019-04-18 11:40:22 +00:00
});
var _subscriptions = [];
_subscriptions.push( subscribe("bb", self.gotoFrames) );
// Draw! Same as earlier except a lot of vibration
var ticker = 0;
var _oldDraw = self.draw;
self.characterSpeakerID = "b";
self.bounceHookes = 0.25; // loose
self.bounceDamp = 0.9; // loose
self.draw = function(ctx){
// Vibration!
ticker += 1/60;
self.characterSquash = 1 + Math.sin(ticker*Math.TAU*7)*0.01; // seven vibes per second
// Old Draw
_oldDraw.apply(self, arguments);
};
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Kill!
self.kill = function(){
_subscriptions.forEach(unsubscribe);
2019-02-18 17:24:52 +00:00
};
2019-02-17 21:54:29 +00:00
}