the last few anims

This commit is contained in:
Nicky Case 2019-04-19 11:57:10 -04:00
parent d5d9414630
commit 9063a1f7dd
10 changed files with 756 additions and 394 deletions

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,7 @@ function Act1_Beebee(){
"body_fear",
"body_point_crotch",
"body_point_heart",
"body_point_sing",
"body_sing",
"mouth_normal",
"mouth_normal_talk",
@ -43,6 +43,7 @@ function Act1_Beebee(){
"eyes_fear",
"eyes_pretty",
"eyes_wat",
"eyes_wat_2",
"body_panic*",
"body_panic_2*",
@ -56,7 +57,17 @@ function Act1_Beebee(){
"body_flail3*",
"body_flail4*",
// TODO: SMILE! "That's me!"
"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",
"eyes_anger"
],
x: 270-7.5,
@ -65,6 +76,14 @@ function Act1_Beebee(){
// ANIM LOOPS
var animLoops = [
{ 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*" },
{ 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*" },
@ -77,8 +96,8 @@ function Act1_Beebee(){
// Go To Frames!
self.gotoFrames({
body: "normal",
mouth: "small",
eyes: "wat",
mouth: "normal",
eyes: "normal",
});
var _subscriptions = [];
_subscriptions.push( subscribe("bb", self.gotoFrames) );
@ -99,139 +118,6 @@ function Act1_Beebee(){
_oldDraw.apply(self, arguments);
};
/*
self.body = new Sprite(spriteConfig);
self.head = new Sprite(spriteConfig);
self.eyes = new Sprite(spriteConfig);
self.gotoFrames = function(bodyName, headName, eyesName){
// Body
bodyName = "body_"+bodyName;
self.body.gotoFrameByName(bodyName);
// Head
headName = headName ? "head_"+headName : "blank";
self.head.gotoFrameByName(headName); // TODO: DON'T RESET MOUTH
// Eyes
eyesName = eyesName ? "eyes_"+eyesName : "blank";
self.eyes.gotoFrameByName(eyesName);
};
self.gotoFrames("normal", "normal", "normal");
subscribe("bb", function(bodyName, headName, eyesName){
self.gotoFrames(bodyName, headName, eyesName);
});
// First frame
// self.sprite.gotoFrameByName("normal");
// Draw
var ticker = 0;
self.draw = function(ctx){
self.body.update();
self.head.update();
self.eyes.update();
self.body.draw(ctx);
self.head.draw(ctx);
self.eyes.draw(ctx);
// TALKING
if(self.body.currentFrameName=="body_normal" || self.body.currentFrameName=="body_fear"){
if(Game.WHO_IS_SPEAKING=="b"){
if(ticker<=0){
if(self.head.currentFrameName=="head_normal") self.head.gotoFrameByName("head_normal_2");
else if(self.head.currentFrameName=="head_normal_2") self.head.gotoFrameByName("head_normal");
ticker = 10;
}
ticker -= (Game.TEXT_SPEED/40) * Game.CURRENT_SPEAKING_SPEED;
}else{
if(self.head.currentFrameName=="head_normal_2") self.head.gotoFrameByName("head_normal");
ticker = 0;
}
if(self.head.currentFrameName=="head_normal_2"){
self.eyes.x = 270+1;
self.eyes.y = 390-2;
}else{
self.eyes.x = 270;
self.eyes.y = 390;
}
}
// PANICKING
if(self.body.currentFrameName=="body_panic" || self.body.currentFrameName=="body_panic_2"){
if(ticker<=0){
if(self.body.currentFrameName=="body_panic") self.body.gotoFrameByName("body_panic_2");
else if(self.body.currentFrameName=="body_panic_2") self.body.gotoFrameByName("body_panic");
ticker = 4;
}
ticker -= 1;
}
// SHIVERING
self.body.breatheSpeed = 0.8;
self.body.breatheAmp = 0.01;
self.head.breatheSpeed = 0.8;
self.head.breatheAmp = 0.01;
self.eyes.breatheSpeed = 0.8;
self.eyes.breatheAmp = 0.01;
/*
// Normal: Breathe fast!
if(fname.substr(0,6) == "normal"){
self.sprite.breatheSpeed = 0.8;
self.sprite.breatheAmp = 0.01;
}
// Scream: Loop between scream 1/2!
if(fname.substr(0,6) == "scream"){
self.sprite.breatheSpeed = 0;
self.sprite.breatheAmp = 0;
if(ticker<=0){
ticker=5;
if(fname=="scream") self.sprite.gotoFrameByName("scream_2");
if(fname=="scream_2") self.sprite.gotoFrameByName("scream");
}else{
ticker--;
}
}
// Draw me!
self.sprite.draw(ctx);
};
// When going to frames...
subscribe("beebee", function(fname){
/*self.sprite.gotoFrameByName(fname);
// Bounce transition
if(fname=="normal_speak"){
self.sprite.bounce = 1.1;
}
if(fname=="scream"){
self.sprite.bounce = 1.6;
}
});
// Kill
self.kill = function(){
};*/
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

View File

@ -26,7 +26,8 @@ function Act1_Hong(){
"body_0_sammich_no_outline",
"body_0_sammich",
"eyes_0_neutral",
"eyes_0_concerned",
"eyes_0_lookaway",
"eyes_0_annoyed",
"eyes_0_shock",
"mouth_0_neutral",
"mouth_0_chew1",
@ -44,6 +45,7 @@ function Act1_Hong(){
"eyes_lookaway",
"eyes_anger",
"eyes_surprise",
"mouth_shut",
"mouth_neutral",
"mouth_neutral_talk",
"mouth_smile",
@ -72,8 +74,10 @@ function Act1_Hong(){
// ANIM LOOPS
var animLoops = [
{ target:"body", ifOnFrame:"phone1", wait:0.5, thenGoToFrame:"phone2" },
{ target:"body", ifOnFrame:"phone2", wait:0.5, thenGoToFrame:"phone1" }
{ target:"body", ifOnFrame:"phone1", wait:1, thenGoToFrame:"phone2" },
{ target:"body", ifOnFrame:"phone2", wait:1, thenGoToFrame:"phone1" },
{ target:"mouth", ifOnFrame:"0_chew1", wait:0.7, thenGoToFrame:"0_chew2" },
{ target:"mouth", ifOnFrame:"0_chew2", wait:0.7, thenGoToFrame:"0_chew1" }
];
// Inherit from Character!
@ -81,107 +85,16 @@ function Act1_Hong(){
// Go To Frames!
self.gotoFrames({
body: "phone1",
mouth: "neutral",
eyes: "neutral",
body: "0_sammich",
mouth: "0_chew1",
eyes: "0_neutral",
});
var _subscriptions = [];
_subscriptions.push( subscribe("hong", self.gotoFrames) );
_subscriptions.push( subscribe("attack_hong", self.showAttackedIcon) );
// Draw
self.bounceHookes = 0.2; // stiff
self.bounceDamp = 0.8; // stiff
/*
// Draw
var ticker = 0;
self.draw = function(ctx){
self.sprite.update();
// Draw body FIRST
ticker++;
//var bod_frame = (Math.floor(ticker/30)%2 == 0) ? "body_phone1" : "body_phone2"; // phone flickering
self.sprite.gotoFrameByName("0_body_sammich");
self.sprite.draw(ctx);
// Draw mouth next
self.sprite.gotoFrameByName("0_mouth_neutral");
self.sprite.draw(ctx);
// Draw eyes finally
self.sprite.gotoFrameByName("0_eyes_neutral");
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;
};
// When going to frames...
subscribe("hong", function(fname, options){
// If attacked, vibrate
if(fname=="attacked"){
//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);
}else{
// Otherwise, go to that frame
self.sprite.gotoFrameByName(fname);
self.sprite.bounce = 1.05;
if(fname=="shock"){
self.sprite.bounce = 1/1.5;
}
}
});
// Kill
self.kill = function(){
};
*/
self.characterSpeakerID = "h";
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

View File

@ -51,6 +51,7 @@ function Character(spriteConfig, animLoops){
self.gotoFrames = function(args, bounce){
// Bounce?
if(bounce===undefined) bounce=0.03; // a LITTLE bit, by default
if(bounce!==undefined){
self.bounce += bounce;
}
@ -152,7 +153,7 @@ function Character(spriteConfig, animLoops){
icon.draw(ctx);
attackedTimer += 1/60;
if(attackedTimer>1.5){ // 1s
if(attackedTimer>1.75){
icon.y -= 1;
icon.alpha -= 1/15;
if(icon.alpha<0){
@ -210,7 +211,7 @@ function Character(spriteConfig, animLoops){
attackedIconShown = type;
var icon = self.fears[attackedIconShown];
icon.x = 82;
icon.y = 230;
icon.y = 250;
icon.alpha = 1;
attackedTimer = 0;
};

View File

@ -224,23 +224,24 @@ Game.immediatePromise = function(){
};
// Move the text DOM to latest
Game.updateText = function(){
Game.updateText = function(instant){
var wordsHeight = 80 + Game.wordsDOM.getBoundingClientRect().height;
var currentY = parseFloat(Game.wordsDOM.style.top) || 80;
var gotoY = (wordsHeight<250) ? 0 : wordsHeight-250;
gotoY = 80 - gotoY;
var nextY = currentY*0.9 + gotoY*0.1;
var nextY = instant ? gotoY : currentY*0.9 + gotoY*0.1;
Game.wordsDOM.style.top = nextY+"px";
};
// CLEAR TEXT
Game.clearText = function(){
Game.wordsDOM.innerHTML = ""; // TODO HACK make prettier
Game.wordsDOM.innerHTML = "";
Game.updateText(true);
};
window.clearText = Game.clearText;
// Execute text! Just add it to text DOM.
Game.TEXT_SPEED = 70;
Game.TEXT_SPEED = 60; // 70;
Game.OVERRIDE_TEXT_SPEED = 1;
Game.WHO_IS_SPEAKING = null; // "h", "b", "n" etc...
Game.CURRENT_SPEAKING_SPEED = 1;
@ -328,8 +329,18 @@ Game.executeText = function(line){
// Bigger interval
if(i!=dialogue.length-1){ // NOT last
if(chr=="." || chr=="?" || chr=="!"){
interval += SPEED*10;
if(chr=="."){
if(dialogue[i+1]=="\""){ // UNLESS next one's a punctuation!
interval += 0;
}else{
interval += SPEED*10;
}
}else if(chr=="?" || chr=="!"){ // gap unless next one's ALSO punctuation.
if(dialogue[i+1]==" "){ // next one's a space? gap!
interval += SPEED*10;
}else{ // if not, no!
interval += SPEED;
}
}else if(chr==","){
interval += SPEED*5;
}else{
@ -414,7 +425,7 @@ Game.executeText = function(line){
Game.OVERRIDE_TEXT_SPEED = 1;
// Return promise
var nextLineDelay = SPEED*7;
var nextLineDelay = Game.TEXT_SPEED*7; // don't override this
if(dialogue.slice(-1)=="-") nextLineDelay=0; // sudden interrupt!
Game.setTimeout(function(){
Game.WHO_IS_SPEAKING = null; // DONE WITH IT.
@ -437,6 +448,17 @@ Game.executeChoice = function(line){
preChoiceCodeIfAny = line.match(/\`(.*)\`/)[0]; // 0, with backticks
}
// Choice text, add italics where *word word words*
var originalChoiceText = choiceText;
var italicsRegex = /\*([^\*]*)\*/g;
var results;
while(results=italicsRegex.exec(choiceText)){
// Modify choiceText in place, it's fine.
var startOfMatch = results.index;
var endOfMatch = results.index + results[0].length;
choiceText = choiceText.slice(0,startOfMatch) + "<i>" + results[1] + "</i>" + choiceText.slice(endOfMatch);
}
var div = document.createElement("div");
div.innerHTML = choiceText;
div.onclick = function(){
@ -446,7 +468,7 @@ Game.executeChoice = function(line){
// Override line... ONCE
if(!Game.OVERRIDE_CHOICE_LINE){
Game.addToQueue("b: "+choiceText);
Game.addToQueue("b: "+originalChoiceText);
}
Game.OVERRIDE_CHOICE_LINE = false;
@ -462,6 +484,22 @@ Game.executeChoice = function(line){
div.style.top = "0px";
},0);
// If it's too big, shrink font size
setTimeout(function(){
var choiceHeight = div.getBoundingClientRect().height;
if(choiceHeight>40) div.style.fontSize = "18px";
// And if still too much???
setTimeout(function(){
var choiceHeight = div.getBoundingClientRect().height;
if(choiceHeight>40) div.style.fontSize = "16px";
// And if still too much???
setTimeout(function(){
var choiceHeight = div.getBoundingClientRect().height;
if(choiceHeight>40) div.style.fontSize = "14px";
},0);
},0);
},0);
// Wait a bit before adding new line
return new RSVP.Promise(function(resolve){
Game.setTimeout(resolve, 100);

View File

@ -59,6 +59,9 @@ function HitPoints(){
// Who's been attacked?
subscribe("attack", function(target, damage, type){
Game.clearText(); // BYE
if(target=="hong"){
self.doDamage(damage, "hong");
self.leftShake = 30;
@ -67,6 +70,7 @@ function HitPoints(){
self.doDamage(damage, "beebee");
self.rightShake = 30;
}
});
// Draw

View File

@ -1,15 +1,25 @@
// Load assets
Loader.addScenes([
"scenes/intro.md",
"scenes/test.md",
"scenes/test-outro.md"
"scenes/act1.md",
//"scenes/test.md",
//"scenes/test-outro.md"
]);
Loader.load().then(function(){
Game.init();
Game.start();
// Outro
// Set up...
SceneSetup.act1();
Game.goto("act1i");
publish("hp_show");
hong({body:"phone1", mouth:"neutral", eyes:"neutral"});
//_.whitebread = true;
_.partyinvite="ignore";
_.fifteencigs = true;
//_.subtweet=true;
_.seppuku = true;
// GO!
Game.goto("act1g");
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 KiB

After

Width:  |  Height:  |  Size: 279 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 KiB

After

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB