This commit is contained in:
Aaron Fischer 2017-08-21 17:08:32 +02:00
parent 4ef0441c7d
commit 3a4e594c57
8 changed files with 38 additions and 15 deletions

BIN
bla/muri.zip Normal file

Binary file not shown.

9
build.sh Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env bash
rm -f muri-src.zip muri.zip
uglifyjs --no-dead-code --output src/muri.min.js src/*.js
(cd src && zip -q -9 ../muri.zip index.html muri.min.js assets/**/* vendor/*.min.js)
(cd src && zip -q -9 ../muri-src.zip *)
filesize=`stat --printf="%s" muri.zip`
echo $filesize "byte ->" $((100*$filesize/13000)) "%"

BIN
muri-src.zip Normal file

Binary file not shown.

BIN
muri.zip Normal file

Binary file not shown.

View file

@ -1,15 +1 @@
<link rel="stylesheet" href="assets/styles.css"></link> <link rel="stylesheet" href="assets/styles.css"></link><h1>murí</h1><p>a js13kgame by <a href="https://aaron-fischer.net/">Aaron Fischer</a> (2017)</p> <div id="content"><div><canvas width="100" height="50" id="js13k-2017"></canvas><div id="bubble" style="display: none;">Uh ...</div></div></div><p id="loading">loading game ...</p><script src="vendor/kontra.min.js"></script><script src="muri.min.js"></script>
<h1>murí</h1>
<p>a js13kgame by <a href="https://aaron-fischer.net/">Aaron Fischer</a> (2017)</p>
<div id="content">
<div>
<canvas width="100" height="50" id="js13k-2017"></canvas>
<div id="bubble" style="display: none;">Uh ...</div>
</div>
</div>
<p id="loading">loading game ...</p>
<script src="vendor/kontra.js"></script>
<script src="muri.js"></script>

15
src/index_dev.html Normal file
View file

@ -0,0 +1,15 @@
<link rel="stylesheet" href="assets/styles.css"></link>
<h1>murí</h1>
<p>a js13kgame by <a href="https://aaron-fischer.net/">Aaron Fischer</a> (2017)</p>
<div id="content">
<div>
<canvas width="100" height="50" id="js13k-2017"></canvas>
<div id="bubble" style="display: none;">Uh ...</div>
</div>
</div>
<p id="loading">loading game ...</p>
<script src="vendor/kontra.js"></script>
<script src="muri.js"></script>

1
src/muri.min.js vendored Normal file

File diff suppressed because one or more lines are too long

12
src/vendor/kontra.min.js vendored Normal file
View file

@ -0,0 +1,12 @@
/*
* Kontra.js v3.0.0 (Custom Build on 2017-08-21) | MIT
* Build: https://straker.github.io/kontra/download?files=gameLoop+keyboard+sprite+assets+pool+spriteSheet+store
*/
this.kontra={init:function(n){var t=this.canvas=document.getElementById(n)||n||document.querySelector("canvas");if(!this._isCanvas(t))throw Error("You must provide a canvas element for the game");this.context=t.getContext("2d")},_noop:new Function,_isString:function(n){return""+n===n},_isNumber:function(n){return+n===n},_isFunc:function(n){return"function"==typeof n},_isImage:function(n){return!!n&&"IMG"===n.nodeName||this._isCanvas(n)},_isCanvas:function(n){return!!n&&"CANVAS"===n.nodeName}};
!function(e,n,t){e.gameLoop=function(o){function r(){if(i=n(r),c=t.now(),u=c-a,a=c,!(u>1e3)){for(s+=u;s>=d;)h.update(f),s-=d;m(),h.render()}}if(o=o||{},!e._isFunc(o.update)||!e._isFunc(o.render))throw Error("You must provide update() and render() functions");var a,i,c,u,p=o.fps||60,s=0,d=1e3/p,f=1/p,m=o.clearCanvas===!1?e._noop:function(){e.context.clearRect(0,0,e.canvas.width,e.canvas.height)},h={update:o.update,render:o.render,isStopped:!0,start:function(){a=t.now(),this.isStopped=!1,n(r)},stop:function(){this.isStopped=!0,cancelAnimationFrame(i)},_frame:r,set _last(e){a=e}};return h}}(kontra,requestAnimationFrame,performance);
!function(){function n(n){var r=i[n.which];t[r]=!0,o[r]&&o[r](n)}function r(n){var r=i[n.which];t[r]=!1}function e(n){t={}}for(var o={},t={},i={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",91:"leftwindow",92:"rightwindow",93:"select",144:"numlock",145:"scrolllock",106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},a=0;a<26;a++)i[65+a]=(10+a).toString(36);for(a=0;a<10;a++)i[48+a]=""+a,i[96+a]="numpad"+a;for(a=1;a<20;a++)i[111+a]="f"+a;var c=window.addEventListener;c("keydown",n),c("keyup",r),c("blur",e),kontra.keys={bind:function(n,r){n=Array.isArray(n)?n:[n];for(var e,t=0;e=n[t];t++)o[e]=r},unbind:function(n){n=Array.isArray(n)?n:[n];for(var r,e=0;r=n[e];e++)o[r]=null},pressed:function(n){return!!t[n]}}}();
!function(t,i,n){t.vector=function(i,n){var e=Object.create(t.vector.prototype);return e._init(i,n),e},t.vector.prototype={_init:function(t,i){this._x=t||0,this._y=i||0},add:function(t,i){this._x+=(t.x||0)*(i||1),this._y+=(t.y||0)*(i||1)},clamp:function(t,i,e,c){this._clamp=!0,this._xMin=void 0!==t?t:-n,this._yMin=void 0!==i?i:-n,this._xMax=void 0!==e?e:n,this._yMax=void 0!==c?c:n},get x(){return this._x},get y(){return this._y},set x(t){this._x=this._clamp?i.min(i.max(this._xMin,t),this._xMax):t},set y(t){this._y=this._clamp?i.min(i.max(this._yMin,t),this._yMax):t}},t.sprite=function(i){var n=Object.create(t.sprite.prototype);return n.init(i),n},t.sprite.prototype={init:function(i){var n,e,c,o=this;i=i||{},o.position=o.position||t.vector(),o.velocity=o.velocity||t.vector(),o.acceleration=o.acceleration||t.vector(),o.position._init(i.x,i.y),o.velocity._init(i.dx,i.dy),o.acceleration._init(i.ddx,i.ddy),o.width=o.height=0;for(var s in i)o[s]=i[s];if(o.ttl=i.ttl||0,o.context=i.context||t.context,o.advance=o._advance,o.draw=o._draw,t._isImage(n=i.image))o.image=n,o.width=n.width,o.height=n.height,o.draw=o._drawImg;else if(n=i.animations){o.animations={};for(var h in n)e=n[h],o.animations[h]=e.clone?e.clone():e,c||(c=o.animations[h]);o.currentAnimation=c,o.width=c.width,o.height=c.height,o.advance=o._advanceAnim,o.draw=o._drawAnim}},get x(){return this.position.x},get y(){return this.position.y},get dx(){return this.velocity.x},get dy(){return this.velocity.y},get ddx(){return this.acceleration.x},get ddy(){return this.acceleration.y},set x(t){this.position.x=t},set y(t){this.position.y=t},set dx(t){this.velocity.x=t},set dy(t){this.velocity.y=t},set ddx(t){this.acceleration.x=t},set ddy(t){this.acceleration.y=t},isAlive:function(){return this.ttl>0},collidesWith:function(t){return this.x<t.x+t.width&&this.x+this.width>t.x&&this.y<t.y+t.height&&this.y+this.height>t.y},update:function(t){this.advance(t)},render:function(){this.draw()},playAnimation:function(t){this.currentAnimation=this.animations[t]},_advance:function(t){this.velocity.add(this.acceleration,t),this.position.add(this.velocity,t),this.ttl--},_advanceAnim:function(t){this._advance(t),this.currentAnimation.update(t)},_draw:function(){this.context.fillStyle=this.color,this.context.fillRect(this.x,this.y,this.width,this.height)},_drawImg:function(){this.context.drawImage(this.image,this.x,this.y)},_drawAnim:function(){this.currentAnimation.render({context:this.context,x:this.x,y:this.y})}}}(kontra,Math,1/0);
!function(a){function n(){for(var a=[],n=0;n<arguments.length;n++)arguments[n]&&a.push(arguments[n].trim().replace(new RegExp("(^[/]{"+(a[0]?1:2)+",}|[/]*$)","g"),""));return a.join("/")}function t(a){return a.split(".").pop()}function e(a){var n=a.replace("."+t(a),"");return 0==n.indexOf("/")&&0==n.lastIndexOf("/")?n.substr(1):n}function r(t){var r=e(t),o=new Image,i=kontra.assets,s=i.images;return t=n(i.imagePath,t),new a(function(a,n){o.onload=function(){s[r]=s[t]=this,a(this)},o.onerror=function(){n("Unable to load image "+t)},o.src=t})}function o(r){var o,i,s,u,c,d=kontra.assets,f=d.audio,l=d.audioPath;return Array.isArray(r)||(r=[r]),new a(function(a,d){for(c=0;o=r[c];c++)if(p[t(o)]){s=o;break}s?(i=e(s),u=new Audio,o=n(l,s),u.addEventListener("canplay",function(){f[i]=f[o]=this,a(this)}),u.onerror=function(){d("Unable to load audio "+o)},u.src=o,u.load()):d("cannot play any of the audio formats provided")})}function i(t){var r=e(t),o=new XMLHttpRequest,i=kontra.assets,s=i.data;return t=n(i.dataPath,t),new a(function(a,n){o.addEventListener("load",function(){var e=o.responseText;if(200!==o.status)return n(e);try{e=JSON.parse(e)}catch(i){}s[r]=s[t]=e,a(e)}),o.open("GET",t,!0),o.send()})}var s=/(jpeg|jpg|gif|png)$/,u=/(wav|mp3|ogg|aac)$/,c=/^no$/,d=new Audio,p={wav:"",mp3:d.canPlayType("audio/mpeg;").replace(c,""),ogg:d.canPlayType('audio/ogg; codecs="vorbis"').replace(c,""),aac:d.canPlayType("audio/aac;").replace(c,"")};kontra.assets={images:{},audio:{},data:{},imagePath:"",audioPath:"",dataPath:"",load:function(){var n,e,c,d,p,f=[];for(d=0;c=arguments[d];d++)n=Array.isArray(c)?c[0]:c,e=t(n),p=e.match(s)?r(c):e.match(u)?o(c):i(c),f.push(p);return a.all(f)},_canUse:p}}(Promise);
!function(t){t.pool=function(e){e=e||{};var i,s=0,c=0;if(!t._isFunc(e.create)||!(i=e.create())||!(t._isFunc(i.update)&&t._isFunc(i.init)&&t._isFunc(i.isAlive)))throw Error("Must provide create() function which returns an object with init(), update(), and isAlive() functions");return{create:e.create,objects:[i],size:1,maxSize:e.maxSize||1/0,get:function(t){if(t=t||{},this.objects[0].isAlive()){if(this.size===this.maxSize)return;for(var e=0;e<this.size&&this.objects.length<this.maxSize;e++)this.objects.unshift(this.create());this.size=this.objects.length,s=this.size-1}var i=this.objects[0];i.init(t);for(var h=1;h<this.size;h++)this.objects[h-1]=this.objects[h];this.objects[s]=i,c++},getAliveObjects:function(){return this.objects.slice(this.objects.length-c)},clear:function(){c=s=this.objects.length=0,this.size=1,this.objects.push(this.create())},update:function(t){for(var e,i=s,h=Math.max(this.objects.length-c,0);i>=h;)if(e=this.objects[i],e.update(t),e.isAlive())i--;else{for(var n=i;n>0;n--)this.objects[n]=this.objects[n-1];this.objects[0]=e,c--,h++}},render:function(){for(var t=Math.max(this.objects.length-c,0),e=s;e>=t;e--)this.objects[e].render&&this.objects[e].render()}}}}(kontra);
!function(t){t.animation=function(i){var e=Object.create(t.animation.prototype);return e._init(i),e},t.animation.prototype={_init:function(t){t=t||{},this.spriteSheet=t.spriteSheet,this.frames=t.frames,this.frameRate=t.frameRate;var i=t.spriteSheet.frame;this.width=i.width,this.height=i.height,this.margin=i.margin||0,this._frame=0,this._accum=0},clone:function(){return t.animation(this)},update:function(t){for(t=t||1/60,this._accum+=t;this._accum*this.frameRate>=1;)this._frame=++this._frame%this.frames.length,this._accum-=1/this.frameRate},render:function(i){i=i||{};var e=i.context||t.context,r=this.frames[this._frame]/this.spriteSheet.framesPerRow|0,a=this.frames[this._frame]%this.spriteSheet.framesPerRow|0;e.drawImage(this.spriteSheet.image,a*this.width+(2*a+1)*this.margin,r*this.height+(2*r+1)*this.margin,this.width,this.height,i.x,i.y,this.width,this.height)}},t.spriteSheet=function(i){var e=Object.create(t.spriteSheet.prototype);return e._init(i),e},t.spriteSheet.prototype={_init:function(i){if(i=i||{},!t._isImage(i.image))throw Erorr("You must provide an Image for the SpriteSheet");this.animations={},this.image=i.image,this.frame={width:i.frameWidth,height:i.frameHeight,margin:i.frameMargin},this.framesPerRow=i.image.width/i.frameWidth|0,this.createAnimations(i.animations)},createAnimations:function(i){var e,r,a,h;for(var s in i){if(e=i[s],r=e.frames,a=e.frameRate,h=[],void 0===r)throw Error("Animation "+s+" must provide a frames property");Array.isArray(r)||(r=[r]);for(var n,m=0;n=r[m];m++)h.push.apply(h,this._parse(n));this.animations[s]=t.animation({spriteSheet:this,frames:h,frameRate:a})}},_parse:function(e){if(t._isNumber(e))return[e];var r=[],a=e.split(".."),h=i=+a[0],s=+a[1];if(h<s)for(;i<=s;i++)r.push(i);else for(;i>=s;i--)r.push(i);return r}}}(kontra);
kontra.store={set:function(t,e){void 0===e?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(e))},get:function(t){var e=localStorage.getItem(t);try{e=JSON.parse(e)}catch(o){}return e}};