From c56eea3b4974287b3adf72bf744a4f4784c0d6b6 Mon Sep 17 00:00:00 2001 From: spaciecat <5057054+spaciecat@users.noreply.github.com> Date: Thu, 12 Sep 2019 15:58:12 +1000 Subject: [PATCH] dialogue animation + debugger refactored all the dialogue text animations to use css animation and transforms rather than frame by frame positioning this causes some issues and the code isnt the cleanest, but its already feels smoother so thats a good start! using the devtools for debugging was getting annoying so I added a `Game.debug()` method that toggles a custom debugger that includes a drawer containing links to all points in the script --- index.html | 6 +++- scripts/game/Game.js | 76 +++++++++++++++++++++++++++++++++++--------- styles/game.css | 51 +++++++++++++++++++++++------ 3 files changed, 108 insertions(+), 25 deletions(-) diff --git a/index.html b/index.html index c6bf657..e41af11 100644 --- a/index.html +++ b/index.html @@ -206,8 +206,12 @@ + +
+
+ - +
diff --git a/scripts/game/Game.js b/scripts/game/Game.js index 62c0b4f..3b3c522 100644 --- a/scripts/game/Game.js +++ b/scripts/game/Game.js @@ -29,12 +29,22 @@ window.attackBB = function(damage, type){ // Init Game.init = function(){ + // Create the section debug menu + Object.keys(Game.sections).forEach(function(key){ + const link = document.createElement('div'); + link.className = "section_link"; + link.innerText = key; + link.addEventListener('click', function() { + Game.goto(key); + }); + document.getElementById("section_debug_list").appendChild(link); + }) + // HP! window.HP = new HitPoints(); // Animation! console.log("init"); - Game.wordsDOM.style.top = "80px"; var animloop = function(){ Game.update(); requestAnimationFrame(animloop); @@ -43,6 +53,11 @@ Game.init = function(){ }; +// Call to toggle debug rendering +Game.debug = function(){ + document.body.classList.toggle('show_debug'); +} + // Parse scene markdown! Game.parseSceneMarkdown = function(md){ @@ -293,20 +308,51 @@ Game.immediatePromise = function(){ // Move the text DOM to latest Game.FORCE_TEXT_Y = -1; -Game.WORDS_HEIGHT_BOTTOM = 250; -Game.updateText = function(instant){ - if(Game.WORDS_HEIGHT_BOTTOM<0) Game.WORDS_HEIGHT_BOTTOM=250; // back to default - if(Game.FORCE_TEXT_Y<0){ - var wordsHeight = 80 + Game.wordsDOM.getBoundingClientRect().height; - var currentY = Game.wordsDOM.style.top=="" ? 80 : parseFloat(Game.wordsDOM.style.top); - var gotoY = (wordsHeight