From cc2ac3dbef3cec0d46253c1c9222cec1c652a6f0 Mon Sep 17 00:00:00 2001 From: Aaron Fischer Date: Tue, 22 Aug 2017 15:03:49 +0200 Subject: [PATCH] Start with the first act --- src/act1.js | 8 ++- src/assets/images/room_stasis.gif | Bin 0 -> 991 bytes src/assets/images/room_stasis_dark.gif | Bin 0 -> 153 bytes src/bubble.js | 73 +++++++++++++++---------- src/index_dev.html | 1 + src/muri.js | 16 ++++-- 6 files changed, 62 insertions(+), 36 deletions(-) create mode 100644 src/assets/images/room_stasis.gif create mode 100644 src/assets/images/room_stasis_dark.gif diff --git a/src/act1.js b/src/act1.js index 60051d0..f0f4e22 100644 --- a/src/act1.js +++ b/src/act1.js @@ -1,7 +1,13 @@ (function() { var act1 = {}; - muri.get('bubble').talk(['Hi', 'I Think, this works ...', 'This looks kinda cool. I think , I can work with that to build a nice little adventure game with some clicky things.', 'Just need to find out a way to click on things.']); + muri.get('bubble') + .story([ + [['Beep ...', 'Click, Click, Click ...'], [20, 15]], + [['Urgh ... ....', 'What is wrong with me? ...'], [5, 40]] + ]).then(function() { + console.log("asdf"); + }) act1.update = function() { }; diff --git a/src/assets/images/room_stasis.gif b/src/assets/images/room_stasis.gif new file mode 100644 index 0000000000000000000000000000000000000000..e73a88e0df2268fbbb5ef7c03160d75195d78aa3 GIT binary patch literal 991 zcmV<510eiINk%v~VPpU@0CxZYA^8LZ3IG5AEC2ui0Av6%0E0w7K^q<^0000|QcQPv zTXSJho}{PC==Y*BPT-4qRB8YKGYB>(M`UDt00000000F45QIsmkm1&+I%^qX}zQA@8mutI&uD*-e?*9S^2!MozfrfvBh=GG(c5^>mE&`AN0E>cxg?W5> zntB))go7WV2?>fReUT(VBS9H^5}6#K7zqNkA}fr7rwF)REh$=Yb*v-=6{-U%0|f=L zDT1mNz`@SYBF-q$0(E-Os>A`x9AYs9GSwF5ErxNFfWGvXh4J=tj*;&W*1KmArn zJ#{v0kOpU0e=auE=$}%#t9A}45Ada{ai@&`GGEb`7z%!5mz)s$#b=#*(Y5!WgA>;0 z6I3<<&|e!Ic4&hbV<3m21QNgy5{4+INXQwesfdAwC#oo;ijK7CqJ|djf!U6P?1)*9 zJ~9BLkN>Q5UnFUqKGNl1oBBG8PNG55(5G+{|Bm*7^ z(`1lo=CY=bZJNnuV>8NVNdt50ac7=t;t8i&d;VGHpmGYT=9zK6xnrV;(m5!Kfi4Ot z0DelUC#8J4St(|1KANH&4Q$##oCAcq#Pmbn#--U zriyE?u)635h#)ot%CN+$lMjx`Dtl~=ccQ`x?P;>3%p-w>n^?Jn)|IY?Cwi%8Q-!5@Hh(Q>t!?h3XE{T>@G}j z!~Pa*a3NpX(C`fxTO2PA6PsIX#W1k@@eCrP1G2y)%h2)4EVu0P%P_|*^UO5YZ1c@H N=dAP2Ji{6R06T>Q#uNYm literal 0 HcmV?d00001 diff --git a/src/assets/images/room_stasis_dark.gif b/src/assets/images/room_stasis_dark.gif new file mode 100644 index 0000000000000000000000000000000000000000..420947166253f7d61ffd32d52091ac25142cd819 GIT binary patch literal 153 zcmZ?wbh9u|Okpr$C}&_${K>+?#lXOz1H=p%Xh{kCfVgAF^>G+5N0Zf*%MSaA07jvBx9x8MKRQ+K{xje)@$ E02dKHdH?_b literal 0 HcmV?d00001 diff --git a/src/bubble.js b/src/bubble.js index ad6e139..5636f57 100644 --- a/src/bubble.js +++ b/src/bubble.js @@ -2,39 +2,54 @@ var bubble = {}; var isactive = false; - var show = function(text, position, callback) { - isactive = true; + var show = function(text, position) { + return new Promise(function(resolve) { + isactive = true; - var dom = document.getElementById('bubble'); - dom.style.display = ''; - dom.style.left = position[0]*8; - dom.style.top = position[1]*8; - dom.innerHTML = ''; + var dom = document.getElementById('bubble'); + dom.style.display = ''; + dom.style.left = position[0]*8; + dom.style.top = position[1]*8; + dom.innerHTML = ''; - parts = text.split(' '); - var show = function() { - if (parts.length === 0) { - setTimeout(function() { - isactive = false; - dom.style.display = 'none'; - callback.call(); - }, 4000); - return; - } - dom.innerHTML += parts.shift() + ' '; - setTimeout(show, 150); - }; - show(); + parts = text.split(' '); + var show = function() { + if (parts.length === 0) { + setTimeout(function() { + isactive = false; + dom.style.display = 'none'; + return resolve(); + }, 4000); + return; + } + dom.innerHTML += parts.shift() + ' '; + setTimeout(show, 150); + }; + show(); + }); }; - bubble.talk = function(texts, position, callback) { - if (texts.length === 0) { - if (callback !== undefined) callback.call(); - return; - } - var text = texts.shift(); - show(text, position || [5, 40], function() { - bubble.talk(texts, position); + bubble.talk = function(texts, position) { + return new Promise(function(resolve) { + if (texts.length === 0) { + return resolve(); + } + var text = texts.shift(); + show(text, position || [5, 40]).then(function() { + bubble.talk(texts, position); + }); + }); + }; + + bubble.story = function(talkList) { + return new Promise(function(resolve, reject) { + if (talkList.length === 0) { + return resolve(); + } + var params = talkList.shift(); + bubble.talk(params[0], params[1]).then(function() { + bubble.story(talkList); + }); }); }; diff --git a/src/index_dev.html b/src/index_dev.html index 358aa74..47e9f6d 100644 --- a/src/index_dev.html +++ b/src/index_dev.html @@ -10,6 +10,7 @@

loading game ...

+ diff --git a/src/muri.js b/src/muri.js index 5572039..54300d9 100644 --- a/src/muri.js +++ b/src/muri.js @@ -58,16 +58,19 @@ var muri = (function() { return muri.modules[i]; }; - muri.start = function() { + muri.newGame = function() { + kontra.store.set('current-room', 'stasis_dark'); + }; + + muri.setup = function() { kontra.assets.load( 'player.png', - 'room_stasis_dark.png', - 'room_stasis.png' + 'room_stasis_dark.gif', + 'room_stasis.gif' ).then(function() { document.getElementById('loading').style.display = 'none'; if (kontra.store.get('current-room') === null) - kontra.store.set('current-room', 'stasis_dark'); - + kontra.store.set('current-room', 'stasis'); var rooms = { stasis_dark: bg('stasis_dark'), stasis: bg('stasis') @@ -95,4 +98,5 @@ var muri = (function() { return muri; }()); -window.onload = muri.start; +document.getElementById('newGame').addEventListener('click', muri.newGame); +window.onload = muri.setup;