sottolio 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/example/game/include/howler.min.js +3 -3
- data/lib/sottolio/version.rb +1 -1
- data/opal/sottolio.rb +1 -0
- data/opal/sottolio/application.rb +4 -113
- data/opal/sottolio/bootstrapper.rb +139 -0
- data/opal/sottolio/database.rb +0 -11
- data/opal/sottolio/image_manager.rb +15 -3
- data/opal/sottolio/lock.rb +12 -0
- data/opal/sottolio/script.rb +7 -51
- data/opal/sottolio/wrapper/canvas.rb +0 -12
- data/opal/sottolio/wrapper/canvas/canvas_button.rb +1 -1
- data/opal/sottolio/wrapper/canvas/canvas_input.rb +6 -1
- data/opal/sottolio/wrapper/image.rb +16 -10
- data/opal/sottolio/wrapper/sound.rb +2 -1
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0e8e9b431ebb6197a73e4d052427a842d3f5733
|
4
|
+
data.tar.gz: 71f481befa4e8fc43f3506989e4c350b924c1b3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba652252e5450b749dbd6da8f544dc9acdb6e66d312b78e8e4de89375d45b3335fda0fbb0a9207148ec592bc6adccba038a5cb4a4053f6bb6ab04d0269542f8a
|
7
|
+
data.tar.gz: 0ae9b9a2d3a857504eec775a06c7c7380dd0f668f80dcc9723265952cf2478d4c93978cb7b8cb28b24d74b8c397684c76cfada9d3e18de5675c4c44420dbe0ff
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -28,5 +28,7 @@ The [demo](http://www.giovannicapuano.net/sottolio/) is also available in the we
|
|
28
28
|
FAQ
|
29
29
|
===
|
30
30
|
**Q**: I can't see one or more assets (girls, images, sounds or whatever)
|
31
|
-
|
32
31
|
*R*: This is a well known bug. Please refresh the page.
|
32
|
+
|
33
|
+
**Q**: I have problems with $browser (with $browser != Firefox)
|
34
|
+
*R*: Currently Fiefox is the only stable browser where sottolio runs correctly. This definitely is considered a well known bug.
|
@@ -1,10 +1,10 @@
|
|
1
1
|
/*!
|
2
|
-
* howler.js v1.1.
|
2
|
+
* howler.js v1.1.26
|
3
3
|
* howlerjs.com
|
4
4
|
*
|
5
|
-
* (c) 2013, James Simpson of GoldFire Studios
|
5
|
+
* (c) 2013-2015, James Simpson of GoldFire Studios
|
6
6
|
* goldfirestudios.com
|
7
7
|
*
|
8
8
|
* MIT License
|
9
9
|
*/
|
10
|
-
!function(){var e={},t=null,n=!0,r=!1;if("undefined"!=typeof AudioContext)t=new AudioContext;else if("undefined"!=typeof webkitAudioContext)t=new webkitAudioContext;else if("undefined"!=typeof Audio){n=!1;try{new Audio}catch(i){r=!0}}else n=!1,r=!0;if(n){var s=void 0===t.createGain?t.createGainNode():t.createGain();s.gain.value=1,s.connect(t.destination)}var o=function(){this._volume=1,this._muted=!1,this.usingWebAudio=n,this._howls=[]};o.prototype={volume:function(e){var t=this;if(e=parseFloat(e),e&&e>=0&&1>=e){t._volume=e,n&&(s.gain.value=e);for(var r in t._howls)if(t._howls.hasOwnProperty(r)&&t._howls[r]._webAudio===!1)for(var i=0;i<t._howls[r]._audioNode.length;i++)t._howls[r]._audioNode[i].volume=t._howls[r]._volume*t._volume;return t}return n?s.gain.value:t._volume},mute:function(){return this._setMuted(!0),this},unmute:function(){return this._setMuted(!1),this},_setMuted:function(e){var t=this;t._muted=e,n&&(s.gain.value=e?0:t._volume);for(var r in t._howls)if(t._howls.hasOwnProperty(r)&&t._howls[r]._webAudio===!1)for(var i=0;i<t._howls[r]._audioNode.length;i++)t._howls[r]._audioNode[i].muted=e}};var u=new o,a=null;if(!r){a=new Audio;var f={mp3:!!a.canPlayType("audio/mpeg;").replace(/^no$/,""),opus:!!a.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),m4a:!!(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")}}var l=function(e){var t=this;t._autoplay=e.autoplay||!1,t._buffer=e.buffer||!1,t._duration=e.duration||0,t._format=e.format||null,t._loop=e.loop||!1,t._loaded=!1,t._sprite=e.sprite||{},t._src=e.src||"",t._pos3d=e.pos3d||[0,0,-.5],t._volume=e.volume||1,t._urls=e.urls||[],t._rate=e.rate||1,t._onload=[e.onload||function(){}],t._onloaderror=[e.onloaderror||function(){}],t._onend=[e.onend||function(){}],t._onpause=[e.onpause||function(){}],t._onplay=[e.onplay||function(){}],t._onendTimer=[],t._webAudio=n&&!t._buffer,t._audioNode=[],t._webAudio&&t._setupAudioNode(),u._howls.push(t),t.load()};if(l.prototype={load:function(){var t=this,n=null;if(r)return t.on("loaderror"),void 0;for(var i=0;i<t._urls.length;i++){var s,o;if(t._format)s=t._format;else{if(o=t._urls[i].toLowerCase().split("?")[0],s=o.match(/.+\.([^?]+)(\?|$)/),s=s&&s.length>=2?s:o.match(/data\:audio\/([^?]+);/),!s)return t.on("loaderror"),void 0;s=s[1]}if(f[s]){n=t._urls[i];break}}if(!n)return t.on("loaderror"),void 0;if(t._src=n,t._webAudio)c(t,n);else{var a=new Audio;t._audioNode.push(a),a.src=n,a._pos=0,a.preload="auto",a.volume=u._muted?0:t._volume*u.volume(),e[n]=t;var l=function(){t._duration=a.duration,0===Object.getOwnPropertyNames(t._sprite).length&&(t._sprite={_default:[0,1e3*t._duration]}),t._loaded||(t._loaded=!0,t.on("load")),t._autoplay&&t.play(),a.removeEventListener("canplaythrough",l,!1)};a.addEventListener("canplaythrough",l,!1),a.load()}return t},urls:function(e){var t=this;return e?(t.stop(),t._urls="string"==typeof e?[e]:e,t._loaded=!1,t.load(),t):t._urls},play:function(e,n){var r=this;return"function"==typeof e&&(n=e),e&&"function"!=typeof e||(e="_default"),r._loaded?r._sprite[e]?(r._inactiveNode(function(i){i._sprite=e;var s,o=i._pos>0?i._pos:r._sprite[e][0]/1e3,a=r._sprite[e][1]/1e3-i._pos,f=!(!r._loop&&!r._sprite[e][2]),l="string"==typeof n?n:Math.round(Date.now()*Math.random())+"";if(function(){var t={id:l,sprite:e,loop:f};s=setTimeout(function(){!r._webAudio&&f&&r.stop(t.id,t.timer).play(e,t.id),r._webAudio&&!f&&(r._nodeById(t.id).paused=!0),r._webAudio||f||r.stop(t.id,t.timer),r.on("end",l)},1e3*a),r._onendTimer.push(s),t.timer=r._onendTimer[r._onendTimer.length-1]}(),r._webAudio){var c=r._sprite[e][0]/1e3,h=r._sprite[e][1]/1e3;i.id=l,i.paused=!1,p(r,[f,c,h],l),r._playStart=t.currentTime,i.gain.value=r._volume,void 0===i.bufferSource.start?i.bufferSource.noteGrainOn(0,o,a):i.bufferSource.start(0,o,a)}else{if(4!==i.readyState)return r._clearEndTimer(s),function(){var t=r,s=e,o=n,u=i,a=function(){t.play(s,o),u.removeEventListener("canplaythrough",a,!1)};u.addEventListener("canplaythrough",a,!1)}(),r;i.id=l,i.currentTime=o,i.muted=u._muted,i.volume=r._volume*u.volume(),setTimeout(function(){i.play()},0)}return r.on("play"),"function"==typeof n&&n(l),r}),r):("function"==typeof n&&n(),r):(r.on("load",function(){r.play(e,n)}),r)},pause:function(e,t){var n=this;if(!n._loaded)return n.on("play",function(){n.pause(e)}),n;n._clearEndTimer(t||0);var r=e?n._nodeById(e):n._activeNode();if(r)if(r._pos=n.pos(null,e),n._webAudio){if(!r.bufferSource)return n;r.paused=!0,void 0===r.bufferSource.stop?r.bufferSource.noteOff(0):r.bufferSource.stop(0)}else r.pause();return n.on("pause"),n},stop:function(e,t){var n=this;if(!n._loaded)return n.on("play",function(){n.stop(e)}),n;n._clearEndTimer(t||0);var r=e?n._nodeById(e):n._activeNode();if(r)if(r._pos=0,n._webAudio){if(!r.bufferSource)return n;r.paused=!0,void 0===r.bufferSource.stop?r.bufferSource.noteOff(0):r.bufferSource.stop(0)}else r.pause(),r.currentTime=0;return n},mute:function(e){var t=this;if(!t._loaded)return t.on("play",function(){t.mute(e)}),t;var n=e?t._nodeById(e):t._activeNode();return n&&(t._webAudio?n.gain.value=0:n.volume=0),t},unmute:function(e){var t=this;if(!t._loaded)return t.on("play",function(){t.unmute(e)}),t;var n=e?t._nodeById(e):t._activeNode();return n&&(t._webAudio?n.gain.value=t._volume:n.volume=t._volume),t},volume:function(e,t){var n=this;if(e=parseFloat(e),e>=0&&1>=e){if(n._volume=e,!n._loaded)return n.on("play",function(){n.volume(e,t)}),n;var r=t?n._nodeById(t):n._activeNode();return r&&(n._webAudio?r.gain.value=e:r.volume=e*u.volume()),n}return n._volume},loop:function(e){var t=this;return"boolean"==typeof e?(t._loop=e,t):t._loop},sprite:function(e){var t=this;return"object"==typeof e?(t._sprite=e,t):t._sprite},pos:function(e,n){var r=this;if(!r._loaded)return r.on("load",function(){r.pos(e)}),"number"==typeof e?r:r._pos||0;e=parseFloat(e);var i=n?r._nodeById(n):r._activeNode();if(i)return r._webAudio?e>=0?(i._pos=e,r.pause(n).play(i._sprite,n),r):i._pos+(t.currentTime-r._playStart):e>=0?(i.currentTime=e,r):i.currentTime;if(e>=0)return r;for(var s=0;s<r._audioNode.length;s++)if(r._audioNode[s].paused&&4===r._audioNode[s].readyState)return r._webAudio?r._audioNode[s]._pos:r._audioNode[s].currentTime},pos3d:function(e,t,n,r){var i=this;if(t=void 0!==t&&t?t:0,n=void 0!==n&&n?n:-.5,!i._loaded)return i.on("play",function(){i.pos3d(e,t,n,r)}),i;if(!(e>=0||0>e))return i._pos3d;if(i._webAudio){var s=r?i._nodeById(r):i._activeNode();s&&(i._pos3d=[e,t,n],s.panner.setPosition(e,t,n))}return i},fade:function(e,t,n,r,i){var s=this,o=Math.abs(e-t),u=e>t?"down":"up",a=o/.01,f=n/a;if(!s._loaded)return s.on("load",function(){s.fade(e,t,n,r,i)}),s;s.volume(e,i);for(var l=1;a>=l;l++)!function(){var e=s._volume+("up"===u?.01:-.01)*l,n=Math.round(1e3*e)/1e3,o=t;setTimeout(function(){s.volume(n,i),n===o&&r&&r()},f*l)}()},fadeIn:function(e,t,n){return this.volume(0).play().fade(0,e,t,n)},fadeOut:function(e,t,n,r){var i=this;return i.fade(i._volume,e,t,function(){n&&n(),i.pause(r),i.on("end")},r)},_nodeById:function(e){for(var t=this,n=t._audioNode[0],r=0;r<t._audioNode.length;r++)if(t._audioNode[r].id===e){n=t._audioNode[r];break}return n},_activeNode:function(){for(var e=this,t=null,n=0;n<e._audioNode.length;n++)if(!e._audioNode[n].paused){t=e._audioNode[n];break}return e._drainPool(),t},_inactiveNode:function(e){for(var t=this,n=null,r=0;r<t._audioNode.length;r++)if(t._audioNode[r].paused&&4===t._audioNode[r].readyState){e(t._audioNode[r]),n=!0;break}if(t._drainPool(),!n){var i;t._webAudio?(i=t._setupAudioNode(),e(i)):(t.load(),i=t._audioNode[t._audioNode.length-1],i.addEventListener("loadedmetadata",function(){e(i)}))}},_drainPool:function(){var e,t=this,n=0;for(e=0;e<t._audioNode.length;e++)t._audioNode[e].paused&&n++;for(e=t._audioNode.length-1;e>=0&&!(5>=n);e--)t._audioNode[e].paused&&(t._webAudio&&t._audioNode[e].disconnect(0),n--,t._audioNode.splice(e,1))},_clearEndTimer:function(e){var t=this,n=t._onendTimer.indexOf(e);n=n>=0?n:0,t._onendTimer[n]&&(clearTimeout(t._onendTimer[n]),t._onendTimer.splice(n,1))},_setupAudioNode:function(){var e=this,n=e._audioNode,r=e._audioNode.length;return n[r]=void 0===t.createGain?t.createGainNode():t.createGain(),n[r].gain.value=e._volume,n[r].paused=!0,n[r]._pos=0,n[r].readyState=4,n[r].connect(s),n[r].panner=t.createPanner(),n[r].panner.setPosition(e._pos3d[0],e._pos3d[1],e._pos3d[2]),n[r].panner.connect(n[r]),n[r]},on:function(e,t){var n=this,r=n["_on"+e];if("function"==typeof t)r.push(t);else for(var i=0;i<r.length;i++)t?r[i].call(n,t):r[i].call(n);return n},off:function(e,t){for(var n=this,r=n["_on"+e],i=""+t,s=0;s<r.length;s++)if(i===""+r[s]){r.splice(s,1);break}return n},unload:function(){for(var t=this,n=t._audioNode,r=0;r<t._audioNode.length;r++)t.stop(n[r].id),t._webAudio?n[r].disconnect(0):n[r].src="";var i=u._howls.indexOf(t);i&&u._howls.splice(i,1),delete e[t._src],t=null}},n)var c=function(n,r){if(r in e)n._duration=e[r].duration,h(n);else{var i=new XMLHttpRequest;i.open("GET",r,!0),i.responseType="arraybuffer",i.onload=function(){t.decodeAudioData(i.response,function(t){t&&(e[r]=t,h(n,t))})},i.onerror=function(){n._webAudio&&(n._buffer=!0,n._webAudio=!1,n._audioNode=[],delete n._gainNode,n.load())};try{i.send()}catch(s){i.onerror()}}},h=function(e,t){e._duration=t?t.duration:e._duration,0===Object.getOwnPropertyNames(e._sprite).length&&(e._sprite={_default:[0,1e3*e._duration]}),e._loaded||(e._loaded=!0,e.on("load")),e._autoplay&&e.play()},p=function(n,r,i){var s=n._nodeById(i);s.bufferSource=t.createBufferSource(),s.bufferSource.buffer=e[n._src],s.bufferSource.connect(s.panner),s.bufferSource.loop=r[0],r[0]&&(s.bufferSource.loopStart=r[1],s.bufferSource.loopEnd=r[1]+r[2]),s.bufferSource.playbackRate.value=n._rate};"function"==typeof define&&define.amd&&define(function(){return{Howler:u,Howl:l}}),window.Howler=u,window.Howl=l}()
|
10
|
+
!function(){var e={},o=null,n=!0,t=!1;try{"undefined"!=typeof AudioContext?o=new AudioContext:"undefined"!=typeof webkitAudioContext?o=new webkitAudioContext:n=!1}catch(r){n=!1}if(!n)if("undefined"!=typeof Audio)try{new Audio}catch(r){t=!0}else t=!0;if(n){var a="undefined"==typeof o.createGain?o.createGainNode():o.createGain();a.gain.value=1,a.connect(o.destination)}var i=function(e){this._volume=1,this._muted=!1,this.usingWebAudio=n,this.ctx=o,this.noAudio=t,this._howls=[],this._codecs=e,this.iOSAutoEnable=!0};i.prototype={volume:function(e){var o=this;if(e=parseFloat(e),e>=0&&1>=e){o._volume=e,n&&(a.gain.value=e);for(var t in o._howls)if(o._howls.hasOwnProperty(t)&&o._howls[t]._webAudio===!1)for(var r=0;r<o._howls[t]._audioNode.length;r++)o._howls[t]._audioNode[r].volume=o._howls[t]._volume*o._volume;return o}return n?a.gain.value:o._volume},mute:function(){return this._setMuted(!0),this},unmute:function(){return this._setMuted(!1),this},_setMuted:function(e){var o=this;o._muted=e,n&&(a.gain.value=e?0:o._volume);for(var t in o._howls)if(o._howls.hasOwnProperty(t)&&o._howls[t]._webAudio===!1)for(var r=0;r<o._howls[t]._audioNode.length;r++)o._howls[t]._audioNode[r].muted=e},codecs:function(e){return this._codecs[e]},_enableiOSAudio:function(){var e=this;if(!o||!e._iOSEnabled&&/iPhone|iPad|iPod/i.test(navigator.userAgent)){e._iOSEnabled=!1;var n=function(){var t=o.createBuffer(1,1,22050),r=o.createBufferSource();r.buffer=t,r.connect(o.destination),"undefined"==typeof r.start?r.noteOn(0):r.start(0),setTimeout(function(){(r.playbackState===r.PLAYING_STATE||r.playbackState===r.FINISHED_STATE)&&(e._iOSEnabled=!0,e.iOSAutoEnable=!1,window.removeEventListener("touchstart",n,!1))},0)};return window.addEventListener("touchstart",n,!1),e}}};var u=null,d={};t||(u=new Audio,d={mp3:!!u.canPlayType("audio/mpeg;").replace(/^no$/,""),opus:!!u.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!u.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!u.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),aac:!!u.canPlayType("audio/aac;").replace(/^no$/,""),m4a:!!(u.canPlayType("audio/x-m4a;")||u.canPlayType("audio/m4a;")||u.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(u.canPlayType("audio/x-mp4;")||u.canPlayType("audio/mp4;")||u.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!u.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")});var l=new i(d),f=function(e){var t=this;t._autoplay=e.autoplay||!1,t._buffer=e.buffer||!1,t._duration=e.duration||0,t._format=e.format||null,t._loop=e.loop||!1,t._loaded=!1,t._sprite=e.sprite||{},t._src=e.src||"",t._pos3d=e.pos3d||[0,0,-.5],t._volume=void 0!==e.volume?e.volume:1,t._urls=e.urls||[],t._rate=e.rate||1,t._model=e.model||null,t._onload=[e.onload||function(){}],t._onloaderror=[e.onloaderror||function(){}],t._onend=[e.onend||function(){}],t._onpause=[e.onpause||function(){}],t._onplay=[e.onplay||function(){}],t._onendTimer=[],t._webAudio=n&&!t._buffer,t._audioNode=[],t._webAudio&&t._setupAudioNode(),"undefined"!=typeof o&&o&&l.iOSAutoEnable&&l._enableiOSAudio(),l._howls.push(t),t.load()};if(f.prototype={load:function(){var e=this,o=null;if(t)return void e.on("loaderror");for(var n=0;n<e._urls.length;n++){var r,a;if(e._format)r=e._format;else{if(a=e._urls[n],r=/^data:audio\/([^;,]+);/i.exec(a),r||(r=/\.([^.]+)$/.exec(a.split("?",1)[0])),!r)return void e.on("loaderror");r=r[1].toLowerCase()}if(d[r]){o=e._urls[n];break}}if(!o)return void e.on("loaderror");if(e._src=o,e._webAudio)_(e,o);else{var u=new Audio;u.addEventListener("error",function(){u.error&&4===u.error.code&&(i.noAudio=!0),e.on("loaderror",{type:u.error?u.error.code:0})},!1),e._audioNode.push(u),u.src=o,u._pos=0,u.preload="auto",u.volume=l._muted?0:e._volume*l.volume();var f=function(){e._duration=Math.ceil(10*u.duration)/10,0===Object.getOwnPropertyNames(e._sprite).length&&(e._sprite={_default:[0,1e3*e._duration]}),e._loaded||(e._loaded=!0,e.on("load")),e._autoplay&&e.play(),u.removeEventListener("canplaythrough",f,!1)};u.addEventListener("canplaythrough",f,!1),u.load()}return e},urls:function(e){var o=this;return e?(o.stop(),o._urls="string"==typeof e?[e]:e,o._loaded=!1,o.load(),o):o._urls},play:function(e,n){var t=this;return"function"==typeof e&&(n=e),e&&"function"!=typeof e||(e="_default"),t._loaded?t._sprite[e]?(t._inactiveNode(function(r){r._sprite=e;var a=r._pos>0?r._pos:t._sprite[e][0]/1e3,i=0;t._webAudio?(i=t._sprite[e][1]/1e3-r._pos,r._pos>0&&(a=t._sprite[e][0]/1e3+a)):i=t._sprite[e][1]/1e3-(a-t._sprite[e][0]/1e3);var u,d=!(!t._loop&&!t._sprite[e][2]),f="string"==typeof n?n:Math.round(Date.now()*Math.random())+"";if(function(){var o={id:f,sprite:e,loop:d};u=setTimeout(function(){!t._webAudio&&d&&t.stop(o.id).play(e,o.id),t._webAudio&&!d&&(t._nodeById(o.id).paused=!0,t._nodeById(o.id)._pos=0,t._clearEndTimer(o.id)),t._webAudio||d||t.stop(o.id),t.on("end",f)},1e3*i),t._onendTimer.push({timer:u,id:o.id})}(),t._webAudio){var _=t._sprite[e][0]/1e3,s=t._sprite[e][1]/1e3;r.id=f,r.paused=!1,p(t,[d,_,s],f),t._playStart=o.currentTime,r.gain.value=t._volume,"undefined"==typeof r.bufferSource.start?d?r.bufferSource.noteGrainOn(0,a,86400):r.bufferSource.noteGrainOn(0,a,i):d?r.bufferSource.start(0,a,86400):r.bufferSource.start(0,a,i)}else{if(4!==r.readyState&&(r.readyState||!navigator.isCocoonJS))return t._clearEndTimer(f),function(){var o=t,a=e,i=n,u=r,d=function(){o.play(a,i),u.removeEventListener("canplaythrough",d,!1)};u.addEventListener("canplaythrough",d,!1)}(),t;r.readyState=4,r.id=f,r.currentTime=a,r.muted=l._muted||r.muted,r.volume=t._volume*l.volume(),setTimeout(function(){r.play()},0)}return t.on("play"),"function"==typeof n&&n(f),t}),t):("function"==typeof n&&n(),t):(t.on("load",function(){t.play(e,n)}),t)},pause:function(e){var o=this;if(!o._loaded)return o.on("play",function(){o.pause(e)}),o;o._clearEndTimer(e);var n=e?o._nodeById(e):o._activeNode();if(n)if(n._pos=o.pos(null,e),o._webAudio){if(!n.bufferSource||n.paused)return o;n.paused=!0,"undefined"==typeof n.bufferSource.stop?n.bufferSource.noteOff(0):n.bufferSource.stop(0)}else n.pause();return o.on("pause"),o},stop:function(e){var o=this;if(!o._loaded)return o.on("play",function(){o.stop(e)}),o;o._clearEndTimer(e);var n=e?o._nodeById(e):o._activeNode();if(n)if(n._pos=0,o._webAudio){if(!n.bufferSource||n.paused)return o;n.paused=!0,"undefined"==typeof n.bufferSource.stop?n.bufferSource.noteOff(0):n.bufferSource.stop(0)}else isNaN(n.duration)||(n.pause(),n.currentTime=0);return o},mute:function(e){var o=this;if(!o._loaded)return o.on("play",function(){o.mute(e)}),o;var n=e?o._nodeById(e):o._activeNode();return n&&(o._webAudio?n.gain.value=0:n.muted=!0),o},unmute:function(e){var o=this;if(!o._loaded)return o.on("play",function(){o.unmute(e)}),o;var n=e?o._nodeById(e):o._activeNode();return n&&(o._webAudio?n.gain.value=o._volume:n.muted=!1),o},volume:function(e,o){var n=this;if(e=parseFloat(e),e>=0&&1>=e){if(n._volume=e,!n._loaded)return n.on("play",function(){n.volume(e,o)}),n;var t=o?n._nodeById(o):n._activeNode();return t&&(n._webAudio?t.gain.value=e:t.volume=e*l.volume()),n}return n._volume},loop:function(e){var o=this;return"boolean"==typeof e?(o._loop=e,o):o._loop},sprite:function(e){var o=this;return"object"==typeof e?(o._sprite=e,o):o._sprite},pos:function(e,n){var t=this;if(!t._loaded)return t.on("load",function(){t.pos(e)}),"number"==typeof e?t:t._pos||0;e=parseFloat(e);var r=n?t._nodeById(n):t._activeNode();if(r)return e>=0?(t.pause(n),r._pos=e,t.play(r._sprite,n),t):t._webAudio?r._pos+(o.currentTime-t._playStart):r.currentTime;if(e>=0)return t;for(var a=0;a<t._audioNode.length;a++)if(t._audioNode[a].paused&&4===t._audioNode[a].readyState)return t._webAudio?t._audioNode[a]._pos:t._audioNode[a].currentTime},pos3d:function(e,o,n,t){var r=this;if(o="undefined"!=typeof o&&o?o:0,n="undefined"!=typeof n&&n?n:-.5,!r._loaded)return r.on("play",function(){r.pos3d(e,o,n,t)}),r;if(!(e>=0||0>e))return r._pos3d;if(r._webAudio){var a=t?r._nodeById(t):r._activeNode();a&&(r._pos3d=[e,o,n],a.panner.setPosition(e,o,n),a.panner.panningModel=r._model||"HRTF")}return r},fade:function(e,o,n,t,r){var a=this,i=Math.abs(e-o),u=e>o?"down":"up",d=i/.01,l=n/d;if(!a._loaded)return a.on("load",function(){a.fade(e,o,n,t,r)}),a;a.volume(e,r);for(var f=1;d>=f;f++)!function(){var e=a._volume+("up"===u?.01:-.01)*f,n=Math.round(1e3*e)/1e3,i=o;setTimeout(function(){a.volume(n,r),n===i&&t&&t()},l*f)}()},fadeIn:function(e,o,n){return this.volume(0).play().fade(0,e,o,n)},fadeOut:function(e,o,n,t){var r=this;return r.fade(r._volume,e,o,function(){n&&n(),r.pause(t),r.on("end")},t)},_nodeById:function(e){for(var o=this,n=o._audioNode[0],t=0;t<o._audioNode.length;t++)if(o._audioNode[t].id===e){n=o._audioNode[t];break}return n},_activeNode:function(){for(var e=this,o=null,n=0;n<e._audioNode.length;n++)if(!e._audioNode[n].paused){o=e._audioNode[n];break}return e._drainPool(),o},_inactiveNode:function(e){for(var o=this,n=null,t=0;t<o._audioNode.length;t++)if(o._audioNode[t].paused&&4===o._audioNode[t].readyState){e(o._audioNode[t]),n=!0;break}if(o._drainPool(),!n){var r;if(o._webAudio)r=o._setupAudioNode(),e(r);else{o.load(),r=o._audioNode[o._audioNode.length-1];var a=navigator.isCocoonJS?"canplaythrough":"loadedmetadata",i=function(){r.removeEventListener(a,i,!1),e(r)};r.addEventListener(a,i,!1)}}},_drainPool:function(){var e,o=this,n=0;for(e=0;e<o._audioNode.length;e++)o._audioNode[e].paused&&n++;for(e=o._audioNode.length-1;e>=0&&!(5>=n);e--)o._audioNode[e].paused&&(o._webAudio&&o._audioNode[e].disconnect(0),n--,o._audioNode.splice(e,1))},_clearEndTimer:function(e){for(var o=this,n=0,t=0;t<o._onendTimer.length;t++)if(o._onendTimer[t].id===e){n=t;break}var r=o._onendTimer[n];r&&(clearTimeout(r.timer),o._onendTimer.splice(n,1))},_setupAudioNode:function(){var e=this,n=e._audioNode,t=e._audioNode.length;return n[t]="undefined"==typeof o.createGain?o.createGainNode():o.createGain(),n[t].gain.value=e._volume,n[t].paused=!0,n[t]._pos=0,n[t].readyState=4,n[t].connect(a),n[t].panner=o.createPanner(),n[t].panner.panningModel=e._model||"equalpower",n[t].panner.setPosition(e._pos3d[0],e._pos3d[1],e._pos3d[2]),n[t].panner.connect(n[t]),n[t]},on:function(e,o){var n=this,t=n["_on"+e];if("function"==typeof o)t.push(o);else for(var r=0;r<t.length;r++)o?t[r].call(n,o):t[r].call(n);return n},off:function(e,o){var n=this,t=n["_on"+e],r=o?o.toString():null;if(r){for(var a=0;a<t.length;a++)if(r===t[a].toString()){t.splice(a,1);break}}else n["_on"+e]=[];return n},unload:function(){for(var o=this,n=o._audioNode,t=0;t<o._audioNode.length;t++)n[t].paused||(o.stop(n[t].id),o.on("end",n[t].id)),o._webAudio?n[t].disconnect(0):n[t].src="";for(t=0;t<o._onendTimer.length;t++)clearTimeout(o._onendTimer[t].timer);var r=l._howls.indexOf(o);null!==r&&r>=0&&l._howls.splice(r,1),delete e[o._src],o=null}},n)var _=function(o,n){if(n in e)return o._duration=e[n].duration,void c(o);if(/^data:[^;]+;base64,/.test(n)){for(var t=atob(n.split(",")[1]),r=new Uint8Array(t.length),a=0;a<t.length;++a)r[a]=t.charCodeAt(a);s(r.buffer,o,n)}else{var i=new XMLHttpRequest;i.open("GET",n,!0),i.responseType="arraybuffer",i.onload=function(){s(i.response,o,n)},i.onerror=function(){o._webAudio&&(o._buffer=!0,o._webAudio=!1,o._audioNode=[],delete o._gainNode,delete e[n],o.load())};try{i.send()}catch(u){i.onerror()}}},s=function(n,t,r){o.decodeAudioData(n,function(o){o&&(e[r]=o,c(t,o))},function(e){t.on("loaderror")})},c=function(e,o){e._duration=o?o.duration:e._duration,0===Object.getOwnPropertyNames(e._sprite).length&&(e._sprite={_default:[0,1e3*e._duration]}),e._loaded||(e._loaded=!0,e.on("load")),e._autoplay&&e.play()},p=function(n,t,r){var a=n._nodeById(r);a.bufferSource=o.createBufferSource(),a.bufferSource.buffer=e[n._src],a.bufferSource.connect(a.panner),a.bufferSource.loop=t[0],t[0]&&(a.bufferSource.loopStart=t[1],a.bufferSource.loopEnd=t[1]+t[2]),a.bufferSource.playbackRate.value=n._rate};"function"==typeof define&&define.amd&&define(function(){return{Howler:l,Howl:f}}),"undefined"!=typeof exports&&(exports.Howler=l,exports.Howl=f),"undefined"!=typeof window&&(window.Howler=l,window.Howl=f)}();
|
data/lib/sottolio/version.rb
CHANGED
data/opal/sottolio.rb
CHANGED
@@ -16,119 +16,10 @@
|
|
16
16
|
# You should have received a copy of the GNU General Public License
|
17
17
|
# along with sottolio. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
#++
|
19
|
-
include Sottolio
|
20
|
-
|
21
19
|
@scripts = []
|
22
|
-
require 'script'
|
23
|
-
|
24
|
-
if @scripts.empty?
|
25
|
-
puts 'No scripts found.'
|
26
|
-
return
|
27
|
-
end
|
28
|
-
|
29
|
-
canvas_id = Sottolio.get 'game'
|
30
|
-
go_next = Sottolio.get 'next'
|
31
|
-
canvas = Canvas.new canvas_id
|
32
|
-
|
33
|
-
database = Database.new
|
34
|
-
scripts = Script.new @scripts
|
35
|
-
scripts.reverse!
|
36
|
-
|
37
|
-
config = {
|
38
|
-
canvas_id: 'game',
|
39
|
-
font_family: 'Arial',
|
40
|
-
font_size: '30px',
|
41
|
-
font_color: '#000'
|
42
|
-
}
|
43
|
-
lock = Lock.new
|
44
|
-
canvas_text = CanvasText.new canvas_id, config
|
45
|
-
canvas_button = CanvasButton.new canvas_id, config, lock
|
46
|
-
|
47
|
-
sound_manager = SoundManager.new
|
48
|
-
image_manager = ImageManager.new
|
49
|
-
input = nil
|
50
|
-
|
51
|
-
next_dialogue = -> {
|
52
|
-
if lock.free? && (!input || input.destroyed? || (input.present? && !input.empty?)) && scripts.any?
|
53
|
-
input.save_and_destroy if input.is_a?(CanvasInput) && input.present?
|
54
|
-
|
55
|
-
canvas.fill_style = '#fff'
|
56
|
-
|
57
|
-
script = scripts.pop
|
58
|
-
current_command = script.keys.first
|
59
|
-
case current_command
|
60
|
-
when :play_sound
|
61
|
-
return next_dialogue.call unless script[:play_sound].true? database
|
62
|
-
|
63
|
-
sound = Sound.new(script[:play_sound][:resource], script[:play_sound][:loop], script[:play_sound][:volume])
|
64
|
-
sound_manager.add script[:play_sound][:id], sound
|
65
|
-
sound_manager.play script[:play_sound][:id]
|
66
|
-
|
67
|
-
next_dialogue.call
|
68
|
-
when :stop_sound
|
69
|
-
return next_dialogue.call unless script[:stop_sound].true? database
|
70
|
-
|
71
|
-
sound_manager.stop script[:stop_sound][:id]
|
72
|
-
|
73
|
-
next_dialogue.call
|
74
|
-
when :background
|
75
|
-
return next_dialogue.call unless script[:background].true? database
|
76
20
|
|
77
|
-
|
78
|
-
|
79
|
-
image_manager.draw script[:background][:id]
|
80
|
-
|
81
|
-
next_dialogue.call
|
82
|
-
when :character
|
83
|
-
return next_dialogue.call unless script[:character].true? database
|
84
|
-
|
85
|
-
character = Character.new(canvas_id, script[:character][:resource], script[:character][:id])
|
86
|
-
image_manager.add character
|
87
|
-
image_manager.draw script[:character][:id], script[:character][:x], script[:character][:y]
|
88
|
-
|
89
|
-
next_dialogue.call
|
90
|
-
when :remove
|
91
|
-
image_manager.remove script[:remove][:id], script[:remove][:animation], script[:remove][:to], script[:remove][:speed]
|
92
|
-
|
93
|
-
next_dialogue.call
|
94
|
-
when :dialogue
|
95
|
-
return next_dialogue.call unless script[:dialogue].true? database
|
96
|
-
|
97
|
-
canvas.clear
|
98
|
-
|
99
|
-
if script[:dialogue].include? :name
|
100
|
-
canvas_text.write "#{script[:dialogue][:name].apply(database)}: #{script[:dialogue][:text].apply(database)}"
|
101
|
-
else
|
102
|
-
canvas_text.write script[:dialogue][:text].apply(database)
|
103
|
-
end
|
104
|
-
when :input
|
105
|
-
return next_dialogue.call unless script[:input].true? database
|
106
|
-
|
107
|
-
canvas.clear
|
108
|
-
|
109
|
-
if script[:input].include? :name
|
110
|
-
canvas_text.write "#{script[:input][:name].apply(database)}: #{script[:input][:text].apply(database)}"
|
111
|
-
else
|
112
|
-
canvas_text.write script[:input][:text].apply(database)
|
113
|
-
end
|
114
|
-
|
115
|
-
input = CanvasInput.new canvas_id, database, script[:input][:id], script[:input][:request].apply(database)
|
116
|
-
when :choice
|
117
|
-
return next_dialogue.call unless script[:choice].true? database
|
118
|
-
|
119
|
-
canvas.clear
|
120
|
-
|
121
|
-
if script[:choice].include? :name
|
122
|
-
canvas_text.write "#{script[:choice][:name].apply(database)}: #{script[:choice][:text].apply(database)}"
|
123
|
-
else
|
124
|
-
canvas_text.write script[:choice][:text].apply(database)
|
125
|
-
end
|
126
|
-
|
127
|
-
canvas_button.get_choice database, script[:choice][:options], script[:choice][:id], next_dialogue
|
128
|
-
end
|
129
|
-
end
|
130
|
-
}
|
131
|
-
|
132
|
-
next_dialogue.call # bootstrapping
|
21
|
+
require 'script'
|
22
|
+
abort 'No scripts found.' if @scripts.empty?
|
133
23
|
|
134
|
-
Sottolio::
|
24
|
+
sottolio = Sottolio::Bootstrapper.new(@scripts)
|
25
|
+
sottolio.run!
|
@@ -0,0 +1,139 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright(C) 2013-2015 Giovanni Capuano <webmaster@giovannicapuano.net>
|
3
|
+
#
|
4
|
+
# This file is part of sottolio.
|
5
|
+
#
|
6
|
+
# sottolio is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# sottolio is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with sottolio. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#++
|
19
|
+
module Sottolio
|
20
|
+
class Bootstrapper
|
21
|
+
def initialize(scripts)
|
22
|
+
@scripts = scripts
|
23
|
+
end
|
24
|
+
|
25
|
+
def run!
|
26
|
+
canvas_id = Sottolio.get 'game'
|
27
|
+
go_next = Sottolio.get 'next'
|
28
|
+
canvas = Canvas.new canvas_id
|
29
|
+
|
30
|
+
database = Database.new
|
31
|
+
scripts = Script.new @scripts
|
32
|
+
|
33
|
+
config = {
|
34
|
+
canvas_id: 'game',
|
35
|
+
font_family: 'Arial',
|
36
|
+
font_size: '30px',
|
37
|
+
font_color: '#000'
|
38
|
+
}
|
39
|
+
lock = Lock.new
|
40
|
+
canvas_text = CanvasText.new canvas_id, config
|
41
|
+
canvas_button = CanvasButton.new canvas_id, config, lock
|
42
|
+
|
43
|
+
sound_manager = SoundManager.new
|
44
|
+
image_manager = ImageManager.new
|
45
|
+
input = nil
|
46
|
+
|
47
|
+
next_dialogue = -> {
|
48
|
+
if lock.free? && (!input || input.destroyed? || (input.present? && !input.empty?)) && scripts.any?
|
49
|
+
input.save_and_destroy if input.is_a?(CanvasInput) && input.present?
|
50
|
+
|
51
|
+
canvas.fill_style = '#fff'
|
52
|
+
|
53
|
+
script = scripts.pop
|
54
|
+
current_command = script.keys.first
|
55
|
+
case current_command
|
56
|
+
when :play_sound
|
57
|
+
if script[:play_sound].true? database
|
58
|
+
sound = Sound.new script[:play_sound][:resource], script[:play_sound][:loop], script[:play_sound][:volume]
|
59
|
+
sound_manager.add script[:play_sound][:id], sound
|
60
|
+
sound_manager.play script[:play_sound][:id]
|
61
|
+
end
|
62
|
+
|
63
|
+
next_dialogue.call
|
64
|
+
when :stop_sound
|
65
|
+
if script[:stop_sound].true? database
|
66
|
+
sound_manager.stop script[:stop_sound][:id]
|
67
|
+
end
|
68
|
+
|
69
|
+
next_dialogue.call
|
70
|
+
when :background
|
71
|
+
if script[:background].true? database
|
72
|
+
background = Background.new canvas_id, script[:background][:resource], script[:background][:id]
|
73
|
+
image_manager.add background
|
74
|
+
image_manager.draw script[:background][:id]
|
75
|
+
end
|
76
|
+
|
77
|
+
next_dialogue.call
|
78
|
+
when :character
|
79
|
+
if script[:character].true? database
|
80
|
+
character = Character.new canvas_id, script[:character][:resource], script[:character][:id]
|
81
|
+
image_manager.add character
|
82
|
+
image_manager.draw script[:character][:id], script[:character][:x], script[:character][:y]
|
83
|
+
end
|
84
|
+
|
85
|
+
next_dialogue.call
|
86
|
+
when :remove
|
87
|
+
image_manager.remove script[:remove][:id], script[:remove][:animation], script[:remove][:to], script[:remove][:speed]
|
88
|
+
|
89
|
+
next_dialogue.call
|
90
|
+
when :dialogue
|
91
|
+
if script[:dialogue].true? database
|
92
|
+
canvas.clear
|
93
|
+
|
94
|
+
if script[:dialogue].include? :name
|
95
|
+
canvas_text.write "#{script[:dialogue][:name].apply(database)}: #{script[:dialogue][:text].apply(database)}"
|
96
|
+
else
|
97
|
+
canvas_text.write script[:dialogue][:text].apply(database)
|
98
|
+
end
|
99
|
+
else
|
100
|
+
next_dialogue.call
|
101
|
+
end
|
102
|
+
when :input
|
103
|
+
if script[:input].true? database
|
104
|
+
canvas.clear
|
105
|
+
|
106
|
+
if script[:input].include? :name
|
107
|
+
canvas_text.write "#{script[:input][:name].apply(database)}: #{script[:input][:text].apply(database)}"
|
108
|
+
else
|
109
|
+
canvas_text.write script[:input][:text].apply(database)
|
110
|
+
end
|
111
|
+
|
112
|
+
input = CanvasInput.new canvas_id, database, script[:input][:id], script[:input][:request].apply(database)
|
113
|
+
else
|
114
|
+
next_dialogue.call
|
115
|
+
end
|
116
|
+
when :choice
|
117
|
+
if script[:choice].true? database
|
118
|
+
canvas.clear
|
119
|
+
|
120
|
+
if script[:choice].include? :name
|
121
|
+
canvas_text.write "#{script[:choice][:name].apply(database)}: #{script[:choice][:text].apply(database)}"
|
122
|
+
else
|
123
|
+
canvas_text.write script[:choice][:text].apply(database)
|
124
|
+
end
|
125
|
+
|
126
|
+
canvas_button.get_choice database, script[:choice][:options], script[:choice][:id], next_dialogue
|
127
|
+
else
|
128
|
+
next_dialogue.call
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
}
|
133
|
+
|
134
|
+
next_dialogue.call
|
135
|
+
|
136
|
+
Sottolio.add_listener :click, go_next, next_dialogue
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
data/opal/sottolio/database.rb
CHANGED
@@ -26,14 +26,6 @@ module Sottolio
|
|
26
26
|
@db[key] = value
|
27
27
|
end
|
28
28
|
|
29
|
-
def delete(key)
|
30
|
-
@db.delete key
|
31
|
-
end
|
32
|
-
|
33
|
-
def delete_if(key, &block)
|
34
|
-
@db.delete_if key, &block
|
35
|
-
end
|
36
|
-
|
37
29
|
def get(key)
|
38
30
|
@db[key]
|
39
31
|
end
|
@@ -41,8 +33,5 @@ module Sottolio
|
|
41
33
|
def has?(key)
|
42
34
|
@db.include? key
|
43
35
|
end
|
44
|
-
alias_method :exist?, :has?
|
45
|
-
alias_method :exists?, :has?
|
46
|
-
alias_method :include?, :has?
|
47
36
|
end
|
48
37
|
end
|
@@ -18,10 +18,9 @@
|
|
18
18
|
#++
|
19
19
|
module Sottolio
|
20
20
|
class ImageManager
|
21
|
-
attr_accessor :images
|
22
|
-
|
23
21
|
def initialize
|
24
22
|
@images = {}
|
23
|
+
@lock = Lock.new
|
25
24
|
end
|
26
25
|
|
27
26
|
def add(image)
|
@@ -40,7 +39,20 @@ module Sottolio
|
|
40
39
|
end
|
41
40
|
|
42
41
|
def draw(id, x = nil, y = nil)
|
43
|
-
@images[id.to_sym]
|
42
|
+
image = @images[id.to_sym]
|
43
|
+
|
44
|
+
# We need to load images by keeping given priority
|
45
|
+
# (i.e. bg must loaded as first so characters appear on top).
|
46
|
+
@lock.on_free do
|
47
|
+
p "#{id} queued"
|
48
|
+
@lock.lock!
|
49
|
+
|
50
|
+
image.on_load -> {
|
51
|
+
p "#{id} loaded"
|
52
|
+
@lock.free!
|
53
|
+
image.draw x, y, x && y
|
54
|
+
}
|
55
|
+
end
|
44
56
|
end
|
45
57
|
end
|
46
58
|
end
|
data/opal/sottolio/lock.rb
CHANGED
@@ -19,6 +19,8 @@
|
|
19
19
|
module Sottolio
|
20
20
|
class Lock
|
21
21
|
def initialize
|
22
|
+
@callbacks = []
|
23
|
+
@bootstrapped = false
|
22
24
|
free!
|
23
25
|
end
|
24
26
|
|
@@ -36,6 +38,16 @@ module Sottolio
|
|
36
38
|
|
37
39
|
def free!
|
38
40
|
@lock = false
|
41
|
+
@callbacks.shift.call unless @callbacks.empty?
|
42
|
+
end
|
43
|
+
|
44
|
+
def on_free(&block)
|
45
|
+
unless locked? && @bootstrapped
|
46
|
+
@bootstrapped = true
|
47
|
+
block.call
|
48
|
+
else
|
49
|
+
@callbacks << block
|
50
|
+
end
|
39
51
|
end
|
40
52
|
end
|
41
53
|
end
|
data/opal/sottolio/script.rb
CHANGED
@@ -16,70 +16,26 @@
|
|
16
16
|
# You should have received a copy of the GNU General Public License
|
17
17
|
# along with sottolio. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
#++
|
19
|
+
require 'forwardable'
|
20
|
+
|
19
21
|
module Sottolio
|
20
22
|
class Script
|
21
|
-
|
23
|
+
extend Forwardable
|
22
24
|
|
23
25
|
# TODO: Rid of unused methods
|
24
26
|
def initialize(scripts = [])
|
25
27
|
@var = []
|
26
28
|
scripts.each { |p| self << p }
|
29
|
+
@var.reverse!
|
27
30
|
end
|
28
31
|
|
29
|
-
def
|
30
|
-
@var.each(&block)
|
31
|
-
end
|
32
|
-
|
33
|
-
def append(block)
|
32
|
+
def <<(block)
|
34
33
|
instance_eval &block
|
35
34
|
end
|
36
|
-
alias_method :<<, :append
|
37
|
-
|
38
|
-
def has?(type)
|
39
|
-
@var.any? { |h| h.keys.first.to_sym == type.to_sym }
|
40
|
-
end
|
41
|
-
alias_method :include?, :has?
|
42
|
-
|
43
|
-
def length(type = nil)
|
44
|
-
if block_given?
|
45
|
-
@var.count &block
|
46
|
-
elsif type == nil
|
47
|
-
@var.count
|
48
|
-
else
|
49
|
-
@var.count { |h| h.keys.first.to_sym == type.to_sym }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
alias_method :count, :length
|
53
|
-
alias_method :count, :size
|
54
|
-
|
55
|
-
def get(type)
|
56
|
-
@var.select { |h| h.keys.first.to_sym == type.to_sym }
|
57
|
-
end
|
58
35
|
|
59
|
-
|
60
|
-
@var.first
|
61
|
-
end
|
62
|
-
|
63
|
-
def last
|
64
|
-
@var.last
|
65
|
-
end
|
66
|
-
|
67
|
-
def pop
|
68
|
-
@var.pop
|
69
|
-
end
|
70
|
-
|
71
|
-
def reverse
|
72
|
-
@var.reverse
|
73
|
-
end
|
74
|
-
|
75
|
-
def reverse!
|
76
|
-
@var.reverse!
|
77
|
-
end
|
78
|
-
|
79
|
-
def to_s
|
80
|
-
@var.inspect
|
81
|
-
end
|
36
|
+
def_delegators :@var, :pop, :any?
|
82
37
|
|
38
|
+
# Script's commands
|
83
39
|
def method_missing(m, *args, &block)
|
84
40
|
if args.any?
|
85
41
|
args = args.first if args.length == 1
|
@@ -70,18 +70,6 @@ module Sottolio
|
|
70
70
|
x > rect[:x] && x < rect[:x] + rect[:w] && y > rect[:y] && y < rect[:y] + rect[:h]
|
71
71
|
end
|
72
72
|
|
73
|
-
def draw(ary)
|
74
|
-
ary.each { |image|
|
75
|
-
draw_image image[:src], image[:x], image[:y]
|
76
|
-
}
|
77
|
-
end
|
78
|
-
|
79
|
-
def draw_image(*args)
|
80
|
-
image = args.shift
|
81
|
-
x, y, width, height = args
|
82
|
-
`#@canvas.drawImage(image, x, y)`
|
83
|
-
end
|
84
|
-
|
85
73
|
def clear
|
86
74
|
fill_style = '#000'
|
87
75
|
round_rect 2, 725, 1276, 120
|
@@ -23,25 +23,31 @@ module Sottolio
|
|
23
23
|
def initialize(element, image, id, x = 0, y = 0)
|
24
24
|
super element
|
25
25
|
|
26
|
-
|
26
|
+
@image = `new Image()`
|
27
27
|
`#@image.src = image`
|
28
28
|
|
29
29
|
@id = id
|
30
30
|
@x = x
|
31
31
|
@y = y
|
32
|
-
|
33
|
-
|
32
|
+
end
|
33
|
+
|
34
|
+
def on_load(callbac)
|
35
|
+
`#@image.onload = callbac`
|
36
|
+
end
|
37
|
+
|
38
|
+
def draw_image(*args)
|
39
|
+
image = args.shift
|
40
|
+
x, y, width, height = args
|
41
|
+
`#@canvas.drawImage(image, x, y)`
|
34
42
|
end
|
35
43
|
|
36
44
|
def draw(x = nil, y = nil, save = false)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
}]
|
45
|
+
draw_image @image, x || @x, y || @y
|
46
|
+
|
47
|
+
@width = `#@image.width`
|
48
|
+
@height = `#@image.height`
|
42
49
|
|
43
|
-
@x = x if save
|
44
|
-
@y = y if save
|
50
|
+
@x, @y = x, y if save
|
45
51
|
end
|
46
52
|
|
47
53
|
def out?
|
metadata
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sottolio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giovanni Capuano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
version_requirements: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0.8'
|
14
19
|
name: opal
|
15
20
|
prerelease: false
|
16
21
|
requirement: !ruby/object:Gem::Requirement
|
@@ -19,12 +24,12 @@ dependencies:
|
|
19
24
|
- !ruby/object:Gem::Version
|
20
25
|
version: '0.8'
|
21
26
|
type: :runtime
|
27
|
+
- !ruby/object:Gem::Dependency
|
22
28
|
version_requirements: !ruby/object:Gem::Requirement
|
23
29
|
requirements:
|
24
30
|
- - "~>"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
- !ruby/object:Gem::Dependency
|
32
|
+
version: '10.4'
|
28
33
|
name: rake
|
29
34
|
prerelease: false
|
30
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -33,11 +38,6 @@ dependencies:
|
|
33
38
|
- !ruby/object:Gem::Version
|
34
39
|
version: '10.4'
|
35
40
|
type: :development
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '10.4'
|
41
41
|
description: Engine to make visual novel games to be run inside your web browser.
|
42
42
|
email: webmaster@giovannicapuano.net
|
43
43
|
executables:
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/sottolio/version.rb
|
71
71
|
- opal/sottolio.rb
|
72
72
|
- opal/sottolio/application.rb
|
73
|
+
- opal/sottolio/bootstrapper.rb
|
73
74
|
- opal/sottolio/database.rb
|
74
75
|
- opal/sottolio/image_manager.rb
|
75
76
|
- opal/sottolio/lock.rb
|