more stuff

This commit is contained in:
Nicky Case 2019-02-20 15:22:23 -05:00
parent dcd178a376
commit a9180a2607
4 changed files with 47 additions and 15 deletions

View File

@ -9,9 +9,9 @@
<div id="game_container"> <div id="game_container">
<canvas id="game_canvas"></canvas> <canvas id="game_canvas"></canvas>
<div id="game_words" class="no_select"></div> <div id="game_words"></div>
<div id="game_hp"></div> <div id="game_hp"></div>
<div id="game_choices" class="no_select"></div> <div id="game_choices"></div>
<div id="paused"> <div id="paused">
<div> <div>
paused paused

View File

@ -6,11 +6,11 @@ n: THIS IS A HUMAN
`publish("scene", ["add_beebee"])` `publish("scene", ["add_beebee"])`
(#act1b)
n: THIS IS YOU, THAT HUMAN'S ANXIETY n: THIS IS YOU, THAT HUMAN'S ANXIETY
h: oh, hello again. i'm sorry but i'd like to eat in peace today if that's not too m-- h: oh, hello again.
h: i don't mean to be rude, but i'd like to eat in peace today if that's not too m--
n: YOUR JOB IS TO PROTECT YOUR HUMAN FROM *DANGER* n: YOUR JOB IS TO PROTECT YOUR HUMAN FROM *DANGER*
@ -26,9 +26,19 @@ n: QUICK, WARN THEM
# act1a_alone # act1a_alone
h: oh no b: Don't you know loneliness is as associated with premature death as smoking 15 cigarettes a day?-
b: oh yes `Game.OVERRIDE_TEXT_SPEED = 2;`
b: (Holt-Lunstad et al, 2010, PLoS Medicine)
h: uh, thank you for citing your sources but--
`Game.OVERRIDE_TEXT_SPEED = 2;`
b: Which means if you don't hang out with someone *right now* you're gonna-
b: DIEEEEEEEEEEEEEEEEEEEE
n: YOU USED *FEAR OF BEING UNLOVED* n: YOU USED *FEAR OF BEING UNLOVED*
@ -46,9 +56,13 @@ n: YOU USED *FEAR OF BEING A BAD PERSON*
# act1a_bread # act1a_bread
h: oh no h: um, thank you for your concern but i--
b: oh yes `Game.OVERRIDE_TEXT_SPEED = 2;`
b: It'll spike your blood sugar and your health will be ruined and then they'll have to amputate all your limbs and then you'll-
b: DIEEEEEEEEEEEEEEEEEEEE
n: YOU USED *FEAR OF BEING HURT* n: YOU USED *FEAR OF BEING HURT*

View File

@ -7,6 +7,7 @@ Game.startSectionID = null;
Game.dom = document.querySelector("#game_container"); Game.dom = document.querySelector("#game_container");
Game.wordsDOM = document.querySelector("#game_words"); Game.wordsDOM = document.querySelector("#game_words");
Game.choicesDOM = document.querySelector("#game_choices"); Game.choicesDOM = document.querySelector("#game_choices");
Game.canvas = document.querySelector("#game_canvas");
Game.startSectionID = null; Game.startSectionID = null;
Game.queue = []; Game.queue = [];
@ -92,21 +93,24 @@ Game.update = function(){
}; };
// PAUSING THE GAME
Game.paused = false; Game.paused = false;
Game.pausedDOM = document.querySelector("#paused");
Game.pause = function(){ Game.pause = function(){
Game.paused = true; Game.paused = true;
document.querySelector("#paused").style.display = "block"; Game.pausedDOM.style.display = "block";
}; };
window.addEventListener("blur", Game.pause); window.addEventListener("blur", Game.pause);
Game.onUnpause = function(){ Game.onUnpause = function(){
if(Game.paused){ if(Game.paused){
Game.paused = false; Game.paused = false;
document.querySelector("#paused").style.display = "none"; Game.pausedDOM.style.display = "none";
} }
}; };
window.addEventListener("click", Game.onUnpause); window.addEventListener("click", Game.onUnpause);
window.addEventListener("touchstart", Game.onUnpause); window.addEventListener("touchstart", Game.onUnpause);
// "SET TIMEOUT" for text and stuff
Game.timeoutCallbacks = []; Game.timeoutCallbacks = [];
Game.setTimeout = function(callback, interval){ Game.setTimeout = function(callback, interval){
Game.timeoutCallbacks.push({ Game.timeoutCallbacks.push({
@ -114,6 +118,15 @@ Game.setTimeout = function(callback, interval){
timeLeft: interval timeLeft: interval
}); });
}; };
// TODO: SKIP TEXT WHEN CLICK ANYWHERE (but NOT capture in choice)
Game.clearAllTimeouts = function(){
Game.timeoutCallbacks.forEach(function(tc){
tc.callback();
});
Game.timeoutCallbacks = [];
};
Game.canvas.addEventListener("click", Game.clearAllTimeouts);
Game.canvas.addEventListener("touchstart", Game.clearAllTimeouts);
Game.goto = function(sectionID){ Game.goto = function(sectionID){
@ -209,6 +222,7 @@ Game.updateText = function(){
}; };
// Execute text! Just add it to text DOM. // Execute text! Just add it to text DOM.
Game.TEXT_SPEED = 40;
Game.OVERRIDE_TEXT_SPEED = 1; Game.OVERRIDE_TEXT_SPEED = 1;
Game.executeText = function(line){ Game.executeText = function(line){
@ -245,7 +259,7 @@ Game.executeText = function(line){
// Add the text // Add the text
var interval = 0; var interval = 0;
var SPEED = Math.round(40 / Game.OVERRIDE_TEXT_SPEED); var SPEED = Math.round(Game.TEXT_SPEED / Game.OVERRIDE_TEXT_SPEED);
if(speaker!="n"){ if(speaker!="n"){
// If not narrator, add letter by letter... // If not narrator, add letter by letter...
@ -327,10 +341,12 @@ Game.executeText = function(line){
})(word, interval); })(word, interval);
// Interval // Interval
interval += SPEED*5; interval += SPEED*6.5;
// Larger interval if punctuation... // Larger interval if punctuation...
if(bareWord.slice(-1)==",") interval += SPEED*5; if(bareWord.slice(-1)==",") interval += SPEED*5;
if(bareWord.slice(-1)==":") interval += SPEED*5;
if(bareWord.slice(-1)==".") interval += SPEED*10;
if(bareWord.slice(-3)=="...") interval += SPEED*15; if(bareWord.slice(-3)=="...") interval += SPEED*15;
} }
@ -338,6 +354,9 @@ Game.executeText = function(line){
} }
// Return overrides to default
Game.OVERRIDE_TEXT_SPEED = 1;
// Return promise // Return promise
var nextLineDelay = SPEED*7; var nextLineDelay = SPEED*7;
if(dialogue.slice(-1)=="-") nextLineDelay=0; // sudden interrupt! if(dialogue.slice(-1)=="-") nextLineDelay=0; // sudden interrupt!
@ -495,7 +514,6 @@ Game.parseLine = function(line){
// WHERE STUFF WILL BE DRAWN /////////////////////////////////////////////////////////////////// // WHERE STUFF WILL BE DRAWN ///////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
Game.canvas = document.querySelector("#game_canvas");
Game.canvas.width = 360 * 2; Game.canvas.width = 360 * 2;
Game.canvas.height = 450 * 2; Game.canvas.height = 450 * 2;
Game.canvas.style.width = Game.canvas.width/2 + "px"; Game.canvas.style.width = Game.canvas.width/2 + "px";

View File

@ -7,7 +7,7 @@ body{
background: #000; background: #000;
} }
.no_select{ #game_words, #game_choices, #paused{
-webkit-user-select: none; /* Safari 3.1+ */ -webkit-user-select: none; /* Safari 3.1+ */
-moz-user-select: none; /* Firefox 2+ */ -moz-user-select: none; /* Firefox 2+ */
-ms-user-select: none; /* IE 10+ */ -ms-user-select: none; /* IE 10+ */