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">
<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_choices" class="no_select"></div>
<div id="game_choices"></div>
<div id="paused">
<div>
paused

View File

@ -6,11 +6,11 @@ n: THIS IS A HUMAN
`publish("scene", ["add_beebee"])`
(#act1b)
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*
@ -26,9 +26,19 @@ n: QUICK, WARN THEM
# 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*
@ -46,9 +56,13 @@ n: YOU USED *FEAR OF BEING A BAD PERSON*
# 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*

View File

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

View File

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