diff --git a/#foo.bar# b/#foo.bar# deleted file mode 100644 index ce7c795a5af79d7df87fd48d436ea8ace99eda98..0000000000000000000000000000000000000000 --- a/#foo.bar# +++ /dev/null @@ -1 +0,0 @@ -ByeMC is awesome \ No newline at end of file diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ae44452a1c2fb6e80a261756a0b5b9345006e4fc Binary files /dev/null and b/.DS_Store differ diff --git a/.swp b/.swp deleted file mode 100644 index 3bffb92fcf05120f22984d74137996aeb902964e..0000000000000000000000000000000000000000 Binary files a/.swp and /dev/null differ diff --git a/assets/aimerthing.png b/aimerthing.png similarity index 100% rename from assets/aimerthing.png rename to aimerthing.png diff --git a/assets/arrow.png b/arrow.png similarity index 100% rename from assets/arrow.png rename to arrow.png diff --git a/assets/Sprite-0002.aseprite b/assets/Sprite-0002.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..93fd6ecdd02a30c2a3f0d3841aa8706cbc523340 Binary files /dev/null and b/assets/Sprite-0002.aseprite differ diff --git a/assets/Sprite-0003.aseprite b/assets/Sprite-0003.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..b65de37d3b9d813d56ef935f98a6336788bdd8bd Binary files /dev/null and b/assets/Sprite-0003.aseprite differ diff --git a/assets/Sprite-0004.aseprite b/assets/Sprite-0004.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..0e43844fc4a8e88e78d92f2405987ffeef5dba94 Binary files /dev/null and b/assets/Sprite-0004.aseprite differ diff --git a/assets/Sprite-0005.aseprite b/assets/Sprite-0005.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..5cb09cbc05f461edfa2ab95d399534edb62462c7 Binary files /dev/null and b/assets/Sprite-0005.aseprite differ diff --git a/assets/Sprite-0006.aseprite b/assets/Sprite-0006.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..2ef4231749dbc96b4de014745a931b1e2ed27292 Binary files /dev/null and b/assets/Sprite-0006.aseprite differ diff --git a/assets/hamsterx2.aseprite b/assets/hamsterx2.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..ac661480b21bbeedb42f3ef66ca228d5eee98e71 Binary files /dev/null and b/assets/hamsterx2.aseprite differ diff --git a/build.zip b/build.zip new file mode 100644 index 0000000000000000000000000000000000000000..2a7a7b5d89faed7f6d97cf90b13c4f8fba7d6f13 Binary files /dev/null and b/build.zip differ diff --git a/build/aimerthing.png b/build/aimerthing.png new file mode 100644 index 0000000000000000000000000000000000000000..008e6b6e80db33849d27736bfc8fd4b031af8045 Binary files /dev/null and b/build/aimerthing.png differ diff --git a/build/arw.png b/build/arw.png new file mode 100644 index 0000000000000000000000000000000000000000..f509667c3b90a211bad7a0c9ad450b281f67e4fe Binary files /dev/null and b/build/arw.png differ diff --git a/build/cursor.png b/build/cursor.png new file mode 100644 index 0000000000000000000000000000000000000000..ca76e84e80889ed8e2719e377c1aaeeb957afde9 Binary files /dev/null and b/build/cursor.png differ diff --git a/build/gun.png b/build/gun.png new file mode 100644 index 0000000000000000000000000000000000000000..0f28c2665e4de59a860284bd4a7312eb7e791d67 Binary files /dev/null and b/build/gun.png differ diff --git a/build/hamster.png b/build/hamster.png new file mode 100644 index 0000000000000000000000000000000000000000..1346ce776d46fed336d29c6b9af605e7030dc095 Binary files /dev/null and b/build/hamster.png differ diff --git a/build/index.html b/build/index.html new file mode 100644 index 0000000000000000000000000000000000000000..b22f25d05b2f6dde9c0901e55d80558ec207ad87 --- /dev/null +++ b/build/index.html @@ -0,0 +1,66 @@ +<canvas id="gameCanvas" width="600" height="400">no canvas support, try a newer browser</canvas> +<style>#gameCanvas { + display: block; + margin: auto; + width: 1200px; + height: 800px; + image-rendering: -moz-crisp-edges; + image-rendering: -webkit-crisp-edges; + image-rendering: pixelated; + cursor: none; + } + /* if the canvas can't fit the screen, shrink it, maintaining the aspect ratio */ + + aside { + float:left; + }</style> + +<script>var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.createTemplateTagFirstArg=function(a){return a.raw=a};$jscomp.createTemplateTagFirstArgWithRaw=function(a,b){a.raw=b;return a};$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.makeIterator=function(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):$jscomp.arrayIterator(a)}; + var fntA=[[,,1,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,1,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1]],fntB=[[,1,1,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,1,1,1]],fntC=[[,,1,1,1,1],[,1,1,,,1,1],[,1,1],[,1,1],[,1,1],[,1,1,,,1,1],[,,1,1,1,1]],fntD=[[,1,1,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,1,1,1]],fntE=[[,,1,1,1,1,1],[,1,1,1,1,1,1],[,1,1],[,1,1,1,1,1],[,1,1],[,1,1,1,1,1,1],[,,1,1,1,1,1]],fntF=[[,,1,1,1,1,1],[,1,1,1,1,1, + 1],[,1,1],[,1,1,1,1,1],[,1,1],[,1,1],[,1,1]],fntG=[[,,1,1,1,1,1],[,1,1,1,1,1,1],,[,1,1],[,1,1,,1,1,1],[,1,1,,,1,1],[,1,1,1,1,1,1],[,,1,1,1,1]],fntH=[[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,1,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,,1,1]],fntI=[[,1,1,1,1,1,1],[,,,1,1],[,,,1,1],[,,,1,1],[,,,1,1],[,,,1,1],[,1,1,1,1,1,1]],fntJ=[[,,1,1,1,1,1],[,,,,,1,1],[,,,,,1,1],[,,,,,1,1],[,,,,,1,1],[,1,1,,,1,1],[,,1,1,1,1]],fntK=[[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,1,1],[,1,1,1,1],[,1,1,,1,1],[,1,1,,,1,1],[,1,1, + ,,1,1]],fntL=[[,1,1],[,1,1],[,1,1],[,1,1],[,1,1],[,1,1,1,1,1,1],[,1,1,1,1,1,1]],fntM=[[,1,1,,,,1],[,1,1,1,,1,1],[,1,1,,1,,1],[,1,1,,,,1],[,1,1,,,,1],[,1,1,,,,1],[,1,1,,,,1]],fntN=[[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,1,,1,1],[,1,1,1,1,1,1],[,1,1,,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1]],fntO=[[,,1,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,,1,1,1,1]],fntP=[[,1,1,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,1,1,1],[,1,1],[,1,1],[,1,1]],fntQ=[[,,1,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1, + ,,1,1],[,1,1,,1,1,1],[,1,1,,,1,1],[,,1,1,1,1,,1]],fntR=[[,1,1,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,,1,1]],fntS=[[,,1,1,1,1],[,1,1,,,1,1],[,1,1],[,,1,1,1,1],[,,,,,1,1],[,1,1,,,1,1],[,,1,1,1,1]],fntT=[[,1,1,1,1,1,1],[,1,1,1,1,1,1],[,,,1,1],[,,,1,1],[,,,1,1],[,,,1,1],[,,,1,1]],fntU=[[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,1,1,1,1],[,,1,1,1,1]],fntV=[[,1,1,,,,1],[,1,1,,,,1],[,1,1,,,,1],[,1,1,,,,1],[,1,1,,,,1],[,,1,1,,1],[,,,1,1]], + fntW=[[,1,1,,,,1],[,1,1,,,,1],[,1,1,,,,1],[,1,1,,1,,1],[,1,1,,1,,1],[,1,1,,1,,1],[,,,1,,1]],fntX=[[,1,,,,,1],[,1,1,,,1,1],[,,1,1,1,1],[,,,1,1],[,,1,1,1,1],[,1,1,,,1,1],[,1,,,,,1]],fntY=[[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,,1,1,1,1,1],[,,,,,1,1],[,1,1,,,1,1],[,,1,1,1,1]],fntZ=[[,1,1,1,1,1,1],[,,,,,1,1],[,,,,1,1],[,,,1,1],[,,1,1],[,1,1],[,1,1,1,1,1,1],,],fnt1=[[,,,1,1],[,,1,1,1],[,,,1,1],[,,,1,1],[,,,1,1],[,,,1,1],[,1,1,1,1,1,1]],fnt2=[[,,1,1,1,1],[,1,1,,,1,1],[,,,,,1,1],[,,,,1,1],[,,,1,1],[,, + 1,1],[,1,1,1,1,1,1]],fnt3=[[,,1,1,1,1],[,1,1,,,1,1],[,,,,,1,1],[,,,,1,1],[,,,,,1,1],[,1,1,,,1,1],[,,1,1,1,1]],fnt4=[[,,,,1,1,1],[,,,1,1,1,1],[,,1,1,,1,1],[,1,1,,,1,1],[,1,1,1,1,1,1],[,,,,,1,1],[,,,,,1,1]],fnt5=[[,1,1,1,1,1,1],[,1,1],[,1,1],[,1,1,1,1,1],[,,,,,1,1],[,,,,,1,1],[,1,1,1,1,1]],fnt6=[[,,1,1,1,1],[,1,1,,,1,1],[,1,1],[,1,1,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,,1,1,1,1]],fnt7=[[,1,1,1,1,1,1],[,1,1,1,1,1,1],[,,,,1,1],[,,,,1,1],[,,,1,1],[,,,1,1],[,,,1,1]],fnt8=[[,,1,1,1,1],[,1,1,,,1,1],[,1,1,, + ,1,1],[,,1,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,,1,1,1,1]],fnt9=[[,,1,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,,1,1,1,1,1],[,,,,,1,1],[,,,,,1,1],[,,,,,1,1]],fnt0=[[,,1,1,1,1],[,1,1,,,1,1],[,1,1,,,1,1],[,1,1,,1,1,1],[,1,1,1,,1,1],[,1,1,,,1,1],[,,1,1,1,1]],fntSlash=[[],[,,,,,,1],[,,,,,1],[,,,,1],[,,,1],[,,1],[,1]],fntColon=[[,1,1],[,1,1],[],[],[],[,1,1],[,1,1]],fntDot=[[],[],[],[],[],[,1,1],[,1,1]],fntNeg=[[],[],[],[,1,1,1,1,1,1],[],[],[]],fntINDEX={A:fntA,B:fntB,C:fntC,D:fntD,E:fntE,F:fntF,G:fntG,H:fntH,I:fntI, + J:fntJ,K:fntK,L:fntL,M:fntM,N:fntN,O:fntO,P:fntP,Q:fntQ,R:fntR,S:fntS,T:fntT,U:fntU,V:fntV,W:fntW,X:fntX,Y:fntY,Z:fntZ,1:fnt1,2:fnt2,3:fnt3,4:fnt4,5:fnt5,6:fnt6,7:fnt7,8:fnt8,9:fnt9,0:fnt0,"/":fntSlash,":":fntColon,".":fntDot,"-":fntNeg};var log=function(a,b){console.log("["+a+"] "+b)},fontStack='"Comic Sans MS"',id=0,pi=Math.PI;gPar=function(a){return(new URLSearchParams(window.location.search)).get(a)};var customLv=gPar("lv"),Canvas=function(a){this.c=document.getElementById(a);this.ctx=this.c.getContext("2d");this.w=this.c.width;this.h=this.c.height;this.tW=this.c.offsetWidth;this.tH=this.c.offsetHeight;this.scale=this.tW/this.w;this.camera={x:0,y:0};this.mousePos={x:0,y:0};this.realMousePos={x:0,y:0}}; + Canvas.prototype.fill=function(a){this.ctx.fillStyle=a;this.ctx.fillRect(0,0,this.w,this.h)};Canvas.prototype.getMousePos=function(a){var b=this.c.getBoundingClientRect(),e=this.c.width/b.width,d=this.c.height/b.height;this.mousePos.x=(a.clientX-b.left)*e+this.camera.x;this.mousePos.y=(a.clientY-b.top)*d+this.camera.y;return{x:(a.clientX-b.left)*e,y:(a.clientY-b.top)*d}};Canvas.prototype.translate=function(a,b){this.ctx.translate(a,b)};Canvas.prototype.rotate=function(a){this.ctx.rotate(a)}; + Canvas.prototype.drawImg=function(a,b,e,d,f,h,g,k){h=void 0===h?0:h;g=void 0===g?b+d/2:g;k=void 0===k?e+f/2:k;this.ctx.save();this.ctx.translate(g-this.camera.x,k-this.camera.y);this.ctx.rotate(h*pi/180);this.ctx.drawImage(a,-d/2,-f/2,d,f);this.ctx.restore()};Canvas.prototype.sliceImage=function(a,b,e,d,f,h,g,k,n,m){m=void 0===m?0:m;this.ctx.save();this.ctx.translate(b+d/2-this.camera.x,e+f/2-this.camera.y);this.ctx.rotate(m*pi/180);this.ctx.drawImage(a,h,g,k,n,-d/2,-f/2,d,f);this.ctx.restore()}; + Canvas.prototype.drawImage=function(a,b,e,d,f,h){this.drawImg(a,b,e,d,f,void 0===h?0:h)};Canvas.prototype.drawRect=function(a,b,e,d,f){this.ctx.fillStyle=void 0===f?"white":f;this.ctx.fillRect(a-this.camera.x,b-this.camera.y,e,d)};Canvas.prototype.strokeRect=function(a,b,e,d,f){this.ctx.strokeStyle=f;this.ctx.strokeRect(a-this.camera.x,b-this.camera.y,e,d)}; + Canvas.prototype.drawFont=function(a,b,e,d,f){this.ctx.fillStyle=d;this.ctx.textAlign=void 0===f?"start":f;this.ctx.fillText(a,b-this.camera.x,e-this.camera.y)}; + Canvas.prototype.dT=function(a,b,e,d,f,h,g,k,n){g=void 0===g?"start":g;k=void 0===k?"top":k;n=void 0===n?{}:n;a=a.toUpperCase();var m=a.split("");a=(7*m.length-1)*f;var l=7*d;switch(g){case "center":case "middle":b-=a/2;break;case "end":case "right":b-=a}switch(k){case "middle":case "center":e-=l/2;break;case "bottom":e-=l}g=0;var p=7*f;k=!1;m=$jscomp.makeIterator(m);for(l=m.next();!l.done;l=m.next()){l=l.value;this.ctx.fillStyle=h;var r=0,t=p;k&&(t-=.5*f,k=!1);n.shortFullStop&&"."==l&&(k=!0);l=fI[l]; + if(void 0!=l)for(var v in l){p=0;for(var u=$jscomp.makeIterator(l[v]),q=u.next();!q.done;q=u.next())1==q.value&&this.ctx.fillRect(b+p*f+g*t-this.camera.x,e+r*d-this.camera.y,f,d),p++;r++}g++;p=7*f}return{w:a}};Canvas.prototype.setFont=function(a,b){this.ctx.font=(void 0===b?"10":b)+"px "+a};Canvas.prototype.drawLine=function(a,b,e,d,f){this.ctx.strokeStyle=f;this.ctx.beginPath();this.ctx.moveTo(a-this.camera.x,b-this.camera.y);this.ctx.lineTo(e,d);this.ctx.stroke()}; + Canvas.prototype.mvCamera=function(a,b){this.camera.x+=a;this.camera.y+=b};Canvas.prototype.setCamera=function(a,b,e){this.camera.x=a;this.camera.y=b};var Entity=function(a,b,e,d){this.name=a;this.x=b;this.y=e;this.sprite=d};Entity.prototype.step=function(){console.log(this.name+" is stepping");console.log(this.name+" is at "+this.x+", "+this.y)};Entity.prototype.draw=function(){};Entity.prototype.intersects=function(a){return this.x<a.x+a.w&&this.x+this.w>a.x&&this.y<a.y+a.h&&this.y+this.h>a.y}; + var Room=function(a){this.id=id;id+=1;this.name=a;this.objects=[];this.hitboxes=[];this.background=[];this.w=c.w;this.h=c.h};Room.prototype.spawn=function(a){this.objects.push(a)};Room.prototype.step=function(){for(var a=$jscomp.makeIterator(this.objects),b=a.next();!b.done;b=a.next())b.value.step()};Room.prototype.draw=function(){for(var a=$jscomp.makeIterator(this.objects),b=a.next();!b.done;b=a.next())b.value.draw()};Room.prototype.drawGUI=function(){};Room.prototype.keyDown=function(a){}; + Room.prototype.keyHeld=function(a){};Room.prototype.click=function(a,b){};Room.prototype.mHeld=function(a,b){};Room.prototype.start=function(){};var fI=fntINDEX,c=new Canvas("gameCanvas");c.ctx||alert("Your browser does not support the canvas element");gameCtx=c.ctx;c.fill("#1c1c1c");c.setFont(fontStack);var gameStart=gameCtx.imageSmoothingEnabled=!1;c.dT("Death By Hamster",c.w/2,c.h/2-40,2,2,"white","middle"); + var images={mouse:{ingame:"./aimerthing.png",cursor:"./cursor.png"},level:{tileset:"./t.png"},player:{car:"./hamster.png",gun:"./gun.png"},ui:{a:"./arw.png"}},loader=new Room("loader"),loadingText="Loading...",loadingError=0;loader.drawGUI=function(){c.dT(loadingText,c.w/2,c.h/2,2,2,"white","middle");loadingError&&c.dT(loadingErrorText,c.w/2,c.h/2+20,1,1,"red","middle")};var rooms=[],loadedImages=0,totalImages=0,key$11;for(key$11 in images)for(var subkey$12 in images[key$11])totalImages++; + loadingText="Loading...";loadingText="Loading images ("+loadedImages+" / "+totalImages+")"; + for(var key in images)for(var subkey in images[key]){var IMG=new Image;IMG.addEventListener("load",function(){loadedImages++;loadingText="Loading images ("+loadedImages+" / "+totalImages+")";loadedImages==totalImages&&(loader.step=function(){cRoom=rooms[1]},loadingText="Loaded! Please wait...")});IMG.addEventListener("error",function(a){loadingError=1;loadingErrorText="Error loading image "+a.target.src});IMG.src=images[key][subkey];images[key][subkey]=IMG;loadingText="Loading images ("+loadedImages+ + " / "+totalImages+")"}var levels=[{data:"[[1,1,2],[1,1,3],[5,1,4],[1,1,1],[2,0,3],[2,0,2],[2,0,1],[4,0,0],[5,1,0],[5,2,0],[5,3,0],[5,4,0],[5,6,0],[5,5,0],[5,7,0],[6,8,0],[0,9,0],[0,10,0],[2,8,1],[2,8,2],[2,8,3],[8,8,4],[5,7,4],[5,5,4],[5,6,4],[5,4,4],[5,2,4],[5,3,4],[7,0,4],[1,2,3],[9,2,2],[1,2,1],[1,3,1],[1,3,2],[1,3,3],[1,4,3],[1,4,2],[1,4,1],[1,5,1],[1,5,2],[1,5,3],[1,6,3],[10,6,2],[1,6,1],[1,7,1],[1,7,2],[1,7,3]]"},{name:"First Floor"}]; + hamsterRef={file:images.player.car,nl:{x:1,y:1,w:32,h:16},b:{x:35,y:1,w:32,h:16},br:{x:1,y:20,w:32,h:16},r:{x:35,y:20,w:32,h:16}}; + for(var levelRef={file:images.level.tileset,"default":{x:0,y:0,w:32,h:32,type:"blank"},tiles:[{},{x:32,type:"floor"},{x:64,type:"wall"},{x:96,type:"wall"},{x:128,type:"wall"},{x:160,type:"wall"},{x:192,type:"wall"},{x:224,type:"wall"},{x:256,type:"wall"},{x:32,type:"floor"},{x:32,type:"floor"}]},$jscomp$iter$4=$jscomp.makeIterator(levelRef.tiles),$jscomp$key$tile=$jscomp$iter$4.next();!$jscomp$key$tile.done;$jscomp$key$tile=$jscomp$iter$4.next()){var tile=$jscomp$key$tile.value,key$13;for(key$13 in levelRef["default"])tile[key$13]|| + (tile[key$13]=levelRef["default"][key$13])}console.debug(images);var targFPS=60,frame=0,menu=new Room("menu");menu.s=0;menu.o=[{t:"Play",a:function(a){setRoom(4)}},{t:"Editor",a:function(a){setRoom(3)}}]; + menu.drawGUI=function(){c.dT("Death by Hamster",c.w/2,c.h/2-25,4,4,"white","middle","middle");c.dT("W/Up or S/Down to select",c.w/2,c.h/2,1,1,"gray","middle","middle");c.dT("Space or ENTER to activate",c.w/2,c.h/2+8,1,1,"gray","middle","middle");for(var a in menu.o){var b=c.dT(""+menu.o[a].t,c.w/2,c.h/2+50+20*a,2,2,"#fff","middle","top");if(menu.s==a){var e=images.ui.a,d=c.w/2+b.w/2+e.width-4;c.drawImg(e,c.w/2-b.w/2-e.width-4,c.h/2+50+20*a,2*e.width,2*e.height);c.drawImg(e,d,c.h/2+50+20*a,2*e.width, + 2*e.height,180)}}};var nextRoom=function(){roomI++;roomI>=rooms.length&&(roomI=0);cRoom=rooms[roomI];cRoom.start()},prevRoom=function(){roomI--;0>roomI&&(roomI=rooms.length-1);cRoom=rooms[roomI];cRoom.start()},setRoom=function(a){cRoom=rooms[a];cRoom.start()};menu.keyDown=function(a){if("ArrowUp"==a||"KeyW"==a)--menu.s,0>menu.s&&(menu.s=menu.o.length-1);if("ArrowDown"==a||"KeyS"==a)menu.s+=1,menu.s>menu.o.length-1&&(menu.s=0);"Space"!=a&&"Enter"!=a||menu.o[menu.s].a()};var gameRoom=new Room("Game"); + gameRoom.level=levels[0];var player=new Entity("Player",0,0);player.speed=0;player.maxSpeed=5;player.direction=0;player.accel=1;player.sprite=images.player.car;console.debug(player.sprite);player.crop=hamsterRef.nl;player.x=0;player.y=0;player.w=2*player.crop.w;player.h=2*player.crop.h; + player.step=function(){player.x+=player.speed*Math.cos(player.direction*pi/180);player.y+=player.speed*Math.sin(player.direction*pi/180);player.speed*=.009;for(var a=$jscomp.makeIterator(gameRoom.level),b=a.next();!b.done;b=a.next())b=b.value,player.x/64>b.x&&player.x/64<b.x+b.w&&player.y/64>b.y&&player.y/64<b.y+b.h&&(player.speed=0);c.setCamera(player.x-c.w/2,player.y-c.h/2)};console.log(player); + player.draw=function(){c.sliceImage(player.sprite,player.x,player.y,player.w,player.h,player.crop.x,player.crop.y,player.crop.w,player.crop.h,player.direction);var a=images.player.gun,b=player.x+player.w/2-13*Math.cos(player.direction*pi/180)-0*Math.sin(player.direction*pi/180),e=player.y+player.h/2-13*Math.sin(player.direction*pi/180)+0*Math.cos(player.direction*pi/180);player.gx=b;player.gy=e;player.aim=180*Math.atan2(c.mousePos.y-e,c.mousePos.x-b)/pi;c.drawImg(a,b,e,2*a.width,2*a.height,player.aim, + b,e)};player.shoot=function(){var a=new Entity("Bullet",player.gx,player.gy);a.speed=20;a.direction=player.aim;a.step=function(){for(var b=0;b<cRoom.objects.length;b++){var e=cRoom.objects[b];if(e!=a&&e.intersects(a)){e!=player&&(cRoom.objects.splice(b,1),cRoom.objects.splice(cRoom.objects.indexOf(a),1));return}}a.x+=a.speed*Math.cos(a.direction*pi/180);a.y+=a.speed*Math.sin(a.direction*pi/180)};a.draw=function(){c.drawRect(a.x,a.y,2,2,"white")};cRoom.spawn(a)};gameRoom.spawn(player); + gameRoom.keyDown=function(a){console.log(a);if("ArrowUp"==a||"KeyW"==a)player.speed+=2*player.accel,player.speed>player.maxSpeed&&(player.speed=player.maxSpeed);if("ArrowDown"==a||"KeyS"==a)player.speed-=1.5*player.accel,player.speed<-player.maxSpeed&&(player.speed=-player.maxSpeed);if("ArrowLeft"==a||"KeyA"==a)player.direction-=2.5,0>player.direction&&(player.direction=360);if("ArrowRight"==a||"KeyD"==a)player.direction+=2.5,360<player.direction&&(player.direction=0);"Space"==a&&player.shoot()}; + gameRoom.keyHeld=function(a){if("ArrowUp"==a||"KeyW"==a)player.speed+=1.9*player.accel,player.speed>player.maxSpeed&&(player.speed=player.maxSpeed);if("ArrowDown"==a||"KeyS"==a)player.speed-=1.53*player.accel,player.speed<-player.maxSpeed&&(player.speed=-player.maxSpeed);if("ArrowLeft"==a||"KeyA"==a)player.direction-=2.5,0>player.direction&&(player.direction=360);if("ArrowRight"==a||"KeyD"==a)player.direction+=2.5,360<player.direction&&(player.direction=0)};gameRoom.click=function(a){player.shoot()}; + gameRoom.start=function(){customLv&&(gameRoom.level=customLv);gameRoom.level=JSON.parse(gameRoom.level);for(var a={},b=$jscomp.makeIterator(gameRoom.level),e=b.next();!e.done;a={$jscomp$loop$prop$pooman$23:a.$jscomp$loop$prop$pooman$23,$jscomp$loop$prop$checkwall$22:a.$jscomp$loop$prop$checkwall$22},e=b.next())e=e.value,9===e[0]&&(player.x=64*e[1]+32,player.y=64*e[2]+32),10===e[0]&&(a.$jscomp$loop$prop$checkwall$22=function(d,f){for(var h=$jscomp.makeIterator(gameRoom.level),g=h.next();!g.done;g= + h.next())if(g=g.value,"wall"==levelRef.tiles[g[0]].type&&g[1]==d&&g[2]==f)return!0;return!1},a.$jscomp$loop$prop$pooman$23=new Entity("Human",64*e[1],64*e[2],images.mouse.cursor),a.$jscomp$loop$prop$pooman$23.step=function(d){return function(f){if(0>=d.$jscomp$loop$prop$pooman$23.timer){f=Math.floor(4*Math.random());d.$jscomp$loop$prop$pooman$23.direction=90*f;var h=Math.floor(d.$jscomp$loop$prop$pooman$23.x/64),g=Math.floor(d.$jscomp$loop$prop$pooman$23.y/64);0!==f||d.$jscomp$loop$prop$checkwall$22(h, + g-1)||(d.$jscomp$loop$prop$pooman$23.y-=64);1!==f||d.$jscomp$loop$prop$checkwall$22(h+1,g)||(d.$jscomp$loop$prop$pooman$23.x+=64);2!==f||d.$jscomp$loop$prop$checkwall$22(h,g+1)||(d.$jscomp$loop$prop$pooman$23.y+=64);3!==f||d.$jscomp$loop$prop$checkwall$22(h-1,g)||(d.$jscomp$loop$prop$pooman$23.x-=64);d.$jscomp$loop$prop$pooman$23.timer=90}d.$jscomp$loop$prop$pooman$23.timer--}}(a),a.$jscomp$loop$prop$pooman$23.draw=function(d){return function(f){c.drawImage(images.mouse.cursor,d.$jscomp$loop$prop$pooman$23.x, + d.$jscomp$loop$prop$pooman$23.y,64,64,d.$jscomp$loop$prop$pooman$23.direction);c.dT(d.$jscomp$loop$prop$pooman$23.timer+" :: "+d.$jscomp$loop$prop$pooman$23.direction,d.$jscomp$loop$prop$pooman$23.x,d.$jscomp$loop$prop$pooman$23.y,1,1,"white","middle","middle")}}(a),a.$jscomp$loop$prop$pooman$23.timer=90,gameRoom.spawn(a.$jscomp$loop$prop$pooman$23))}; + gameRoom.draw=function(){for(var a=$jscomp.makeIterator(gameRoom.level),b=a.next();!b.done;b=a.next())b=b.value,c.sliceImage(levelRef.file,64*b[1],64*b[2],64,64,levelRef.tiles[b[0]].x,0,32,32);for(a=0;a<cRoom.objects.length;a++)cRoom.objects[a].draw()};var editor=new Room("Editor");editor.i=0;editor.t=levelRef;editor.l=[];editor.n="LV1";editor.saving=!1;editor.sa=0;editor.start=function(a){editor.dPos=[15,65]}; + editor.draw=function(a){a=$jscomp.makeIterator(editor.l);for(var b=a.next();!b.done;b=a.next())b=b.value,c.sliceImage(levelRef.file,32*b[1]+editor.dPos[0],32*b[2]+editor.dPos[1],32,32,32*b[0],0,32,32),c.drawRect(editor.dPos[0],editor.dPos[1],1,1,"red")};editor.step=function(a){0>editor.i&&(editor.i=levelRef.tiles.length-1);editor.i>levelRef.tiles.length-1&&(editor.i=0)}; + editor.generate=function(a){editor.saving=1;a=encodeURIComponent(JSON.stringify(editor.l));a!=editor.data&&(a="?lvl="+a,document.getElementById("leveltext").innerText=a);editor.data=a;editor.saving=0;editor.sa=1}; + editor.click=function(a,b){if(50>b)516<a&&50>b&&(editor.saving||editor.generate(),editor.saveclick=!0);else{a=Math.floor((a-editor.dPos[0])/32);b=Math.floor((b-editor.dPos[1])/32);for(var e in editor.l)if(editor.l[e][1]==a&&editor.l[e][2]==b){editor.l[e]=[editor.i,a,b];return}editor.l.push([editor.i,a,b]);editor.sa=0}}; + editor.keyHeld=function(a){switch(a){case "KeyW":case "ArrowUp":editor.dPos[1]+=4;break;case "KeyS":case "ArrowDown":editor.dPos[1]-=4;break;case "KeyA":case "ArrowLeft":editor.dPos[0]+=4;break;case "KeyD":case "ArrowRight":editor.dPos[0]-=4}}; + editor.drawGUI=function(a){c.drawRect(0,0,c.w,50,"gray");c.dT("DBH Editor::"+editor.n,15,25,2,2,"#fff","start","middle");a=c.dT("Save",c.w-15,25,2,2,"#fff","end","middle");c.mousePos.x>c.w-30-a.w&&50>c.mousePos.y&&c.dT("Save",c.w-15,25,2,2,"#e5e5e5","end","middle");editor.sa&&c.dT("Save",c.w-15,25,2,2,"#1fdc2f","end","middle");editor.saving&&c.dT("Save",c.w-15,25,2,2,"#1fccdc","end","middle");c.sliceImage(editor.t.file,c.mousePos.x+16,c.mousePos.y+16,32,32,32*editor.i,0,32,32)};var lvlS=new Room("Level Select"); + lvlS.s=0;lvlS.o=levels;lvlS.drawGUI=function(){c.dT("Death by Hamster",c.w/2,25,2,2,"white","middle","top");c.dT("Level Select",c.w/2,44,1,1,"gray","middle","middle");for(var a in lvlS.o){var b=parseInt(a)+1;c.dT(""+b,20+32*b,70,2,2,"#fff","middle","middle");a==lvlS.s&&c.strokeRect(6+32*b,54,32,32,"#fff")}}; + lvlS.keyDown=function(a){if("ArrowUp"==a||"ArrowRight"==a||"KeyW"==a||"KeyD"==a)--lvlS.s,0>lvlS.s&&(lvlS.s=lvlS.o.length-1);if("ArrowDown"==a||"ArrowLeft"==a||"KeyW"==a||"KeyA"==a)lvlS.s+=1,lvlS.s>lvlS.o.length-1&&(lvlS.s=0);if("Space"==a||"Enter"==a)gameRoom.level=lvlS.o[lvlS.s].data,setRoom(2)};rooms.push(loader);rooms.push(menu);rooms.push(gameRoom);rooms.push(editor);rooms.push(lvlS);var roomI=gPar("goto")?gPar("goto"):0,cRoom=rooms[roomI],keysPressed={},keysLastPressed={}; + document.addEventListener("keydown",function(a){keysPressed[a.code]=!0});document.addEventListener("keyup",function(a){keysPressed[a.code]=!1;keysLastPressed[a.code]=!1});var lastTime=0,mse={x:0,y:0},lastClick={x:0,y:0},startclicked=!1,endclicked=!1;c.c.addEventListener("mousemove",function(a){mse=c.getMousePos(a)});c.c.addEventListener("mousedown",function(a){lastClick=c.getMousePos(a);mse=c.getMousePos(a);startclicked=!0}); + c.c.addEventListener("mouseup",function(a){lastClick=c.getMousePos(a);mse=c.getMousePos(a);endclicked=!0});window.onwheel=function(a){0<a.deltaY&&(editor.i+=1);0>a.deltaY&&--editor.i};cRoom.start(); + var gameLoop=setInterval(function(){c.tW=c.c.offsetWidth;c.tH=c.c.offsetHeight;c.scale=c.tW/c.w;frame++;c.fill("#151f1f");for(var a in keysPressed)keysPressed[a]&&(keysLastPressed[a]?keysLastPressed[a]&&cRoom.keyHeld(a):(cRoom.keyDown(a),keysLastPressed[a]=!0));startclicked&&(cRoom.click(lastClick.x,lastClick.y),startclicked=!1);cRoom.step();cRoom.draw();cRoom.drawGUI();c.dT("FPS:"+Math.round(1E3/(Date.now()-lastTime)),0+c.camera.x,0+c.camera.y,1,1,"#fafafa","left","top");switch(cRoom.name){case "menu":case "Editor":c.ctx.drawImage(images.mouse.cursor, + Math.round(mse.x),Math.round(mse.y),2*images.mouse.cursor.width,2*images.mouse.cursor.height);break;case "Game":c.ctx.drawImage(images.mouse.ingame,Math.round(mse.x)-16,Math.round(mse.y)-16,32,32)}lastTime=Date.now()},1E3/targFPS);</script> \ No newline at end of file diff --git a/build/t.png b/build/t.png new file mode 100644 index 0000000000000000000000000000000000000000..0407f3076ee71a85e6fbb154bb333a3b4c19aa58 Binary files /dev/null and b/build/t.png differ diff --git a/assets/byemclogo.png b/byemclogo.png similarity index 100% rename from assets/byemclogo.png rename to byemclogo.png diff --git a/assets/crazyabackground_a.png b/crazyabackground_a.png similarity index 100% rename from assets/crazyabackground_a.png rename to crazyabackground_a.png diff --git a/assets/crazyabackground_a_big.png b/crazyabackground_a_big.png similarity index 100% rename from assets/crazyabackground_a_big.png rename to crazyabackground_a_big.png diff --git a/editor.html b/editor.html deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/assets/flor.png b/flor.png similarity index 100% rename from assets/flor.png rename to flor.png diff --git a/game.js b/game.js index b8de109c5605bb4657fbb41e18b5e4b3907a5c49..beee64c9ffcc6c7421716793bd04a642aac597af 100644 --- a/game.js +++ b/game.js @@ -53,17 +53,17 @@ class Canvas { // Mouse position crap getMousePos(evt) { var rect = this.c.getBoundingClientRect(), // abs. size of element - scaleX = this.c.width / rect.width, // relationship bitmap vs. element for x - scaleY = this.c.height / rect.height; // relationship bitmap vs. element for y + scaleX = this.c.width / rect.width, // relationship bitmap vs. element for x + scaleY = this.c.height / rect.height; // relationship bitmap vs. element for y this.mousePos.x = ((evt.clientX - rect.left) * scaleX) + this.camera.x; this.mousePos.y = ((evt.clientY - rect.top) * scaleY) + this.camera.y; - + return { - x: (evt.clientX - rect.left) * scaleX, // scale mouse coordinates after they have - y: (evt.clientY - rect.top) * scaleY // been adjusted to be relative to element + x: (evt.clientX - rect.left) * scaleX, // scale mouse coordinates after they have + y: (evt.clientY - rect.top) * scaleY // been adjusted to be relative to element } - } + } translate(x, y) { this.ctx.translate(x, y); @@ -122,10 +122,18 @@ class Canvas { // console.log(chars); let charWidth = 7 - let strLength = (chars.length * charWidth - 1) * scalex; + let charOff = 0; + // check if there's an odd number of chars + if (chars.length % 2 == 1) { + charOff = 1 + } + let strLength = (chars.length * charWidth - charOff) * scalex; let charHeight = 7 let strHeight = (charHeight * scaley); + if (strHeight % 2 == 1) { + strHeight += 1; + } switch(align) { case "start": @@ -326,14 +334,14 @@ c.dT("Death By Hamster", c.w / 2, c.h / 2 - 40, 2, 2, "white", "middle"); // Load images var images = { "mouse": { - "ingame": "./assets/aimerthing.png", + "ingame": "./aimerthing.png", "cursor": "./cursor.png" }, "level": { - "tileset": "./t.png" + "tileset": "./t.png", + "human": "./human.png" }, "player": { - "debugarrow": "./assets/arrow.png", "car": "./hamster.png", "gun": "./gun.png", }, @@ -493,6 +501,13 @@ var levelRef = { ] } +var humanRef = { + "file": images.level.human, + "bladie": { + + } + + for (let tile of levelRef.tiles) { // if the tile is missing properties from the default, add them for (let key in levelRef.default) { @@ -594,31 +609,66 @@ player.x = 0; player.y = 0; player.w = player.crop.w*2; player.h = player.crop.h*2; +player.oldDir = 0; + +player.step = _=> { + // check that the player won't go into a wall on the next step, and if so, stop. + player.checkpoints = []; + for (let i = 0; i < 2; i++) { + + let carCx = player.x + player.w/2; + let carCy = player.y + player.h/2; + + let pointOx = 0; + let pointOy = 0; + if (i==0) { + pointOx = -32; + } else if (i==1) { + pointOx = 32; + } + + // get gunx and guny by moving backwards (gunOx and gunOy) from the center of the car in this.direction + let pointX = carCx - pointOx * Math.cos(player.direction * pi / 180) - pointOy * Math.sin(player.direction * pi / 180); + let pointY = carCy - pointOx * Math.sin(player.direction * pi / 180) + pointOy * Math.cos(player.direction * pi / 180); + + player.checkpoints.push({x: pointX, y: pointY}); + } + for (let checkpoint of player.checkpoints) { + let x = checkpoint.x / 64; + let y = checkpoint.y / 64; + if (gameRoom.checkwall(x, y)) { + checkpoint.stuck = true; + } + } + if (player.checkpoints[0].stuck || player.checkpoints[1].stuck) { + // move down sideways if stuck + let change = player.direction - player.oldDir; + player.direction -= change; + + let sChange = player.speed - player.oldSpeed; + player.speed -= sChange+0.01; + } -player.step = () => { // move in this.direction, which is an angle in degrees player.x += player.speed * Math.cos(player.direction * pi / 180); player.y += player.speed * Math.sin(player.direction * pi / 180); player.speed *= 0.009; - // check that the player won't go into a wall on the next step, and if so, stop. - for (let tile of gameRoom.level) { - if (player.x/64 > tile.x && player.x/64 < tile.x + tile.w && player.y/64 > tile.y && player.y/64 < tile.y + tile.h) { - player.speed = 0; - } - } - // keep the camera centered on the player c.setCamera(player.x - c.w/2, player.y - c.h/2); + player.oldDir = player.direction; + player.oldSpeed = player.speed; + } console.log(player); -player.draw = () => { +player.draw = _=> { // draw this.sprite at this.x, this.y c.sliceImage(player.sprite, player.x, player.y, player.w, player.h, player.crop.x, player.crop.y, player.crop.w, player.crop.h, player.direction); + // c.dT(`${player.x/64} ${player.y/64}`, player.x, player.y, 1,1,"white","middle","middle"); // canvas.strokeRect(player.x, player.y, player.w, player.h, "white"); let gun = images.player.gun; @@ -641,6 +691,11 @@ player.draw = () => { c.drawImg(gun, gunx, guny, gun.width*2, gun.height*2, player.aim, gunx, guny); // these two vars at the end are where the gun's center is placed // canvas.drawRect(gunx, guny, 1,1, "red"); + for (let checkpoint of player.checkpoints) { + c.drawRect(checkpoint.x, checkpoint.y, 1,1, "black"); + + } + } player.shoot = () => { @@ -648,6 +703,8 @@ player.shoot = () => { let bullet = new Entity("Bullet", player.gx, player.gy); bullet.speed = 20; bullet.direction = player.aim; + bullet.w = 2; + bullet.h = 2; bullet.step = () => { // for each step, check if it's path intersects with any other entity @@ -655,11 +712,12 @@ player.shoot = () => { let ent = cRoom.objects[i]; if (ent != bullet && ent.intersects(bullet)) { // if it does, remove the bullet and the entity unless it's the player + console.log(ent); if (ent != player) { cRoom.objects.splice(i, 1); cRoom.objects.splice(cRoom.objects.indexOf(bullet), 1); + return; } - return; } } // if it doesn't, move the bullet @@ -667,7 +725,7 @@ player.shoot = () => { bullet.y += bullet.speed * Math.sin(bullet.direction * pi / 180); } bullet.draw = () => { - c.drawRect(bullet.x, bullet.y, 2,2, "white"); + c.drawRect(bullet.x, bullet.y, bullet.w,bullet.h, "#2f2f2f"); } cRoom.spawn(bullet); } @@ -735,6 +793,16 @@ gameRoom.keyHeld = (key) => { gameRoom.click = (e) => { player.shoot(); } +gameRoom.checkwall = (tx,ty) => { + tx = Math.floor(tx); + ty = Math.floor(ty); + for (let tile of gameRoom.level) { + if (levelRef.tiles[tile[0]].type == "wall" && tile[1] == tx && tile[2] == ty) { + return true; + } + } + return false; +} gameRoom.start = () =>{ if (customLv) { @@ -748,16 +816,10 @@ gameRoom.start = () =>{ player.y = (tile[2]*64)+32 } if(tile[0]===10){ - let checkwall = (tx,ty) => { - for (let tile of gameRoom.level) { - if (levelRef.tiles[tile[0]].type == "wall" && tile[1] == tx && tile[2] == ty) { - return true; - } - } - return false; - } let pooman = new Entity("Human", (tile[1]*64),(tile[2]*64), images.mouse.cursor) + pooman.w = 64 + pooman.h = 64 pooman.step = _=>{ if (pooman.timer<=0){ let director = Math.floor(Math.random()*4) @@ -765,22 +827,22 @@ gameRoom.start = () =>{ let tX = Math.floor(pooman.x / 64) let tY = Math.floor(pooman.y / 64) if (director === 0){ - if (!checkwall(tX,tY-1)){ + if (!gameRoom.checkwall(tX,tY-1)){ pooman.y -= 64; } } if (director === 1){ - if (!checkwall(tX+1,tY)){ + if (!gameRoom.checkwall(tX+1,tY)){ pooman.x += 64; } } if (director === 2){ - if (!checkwall(tX,tY+1)){ + if (!gameRoom.checkwall(tX,tY+1)){ pooman.y += 64; } } if (director === 3){ - if (!checkwall(tX-1,tY)){ + if (!gameRoom.checkwall(tX-1,tY)){ pooman.x -= 64; } } @@ -790,7 +852,7 @@ gameRoom.start = () =>{ } pooman.draw = _=>{ c.drawImage(images.mouse.cursor, pooman.x, pooman.y, 64, 64, pooman.direction); - c.dT(`${pooman.timer} :: ${pooman.direction}`, pooman.x, pooman.y, 1, 1, "white", "middle", "middle"); + // c.dT(`${pooman.timer} :: ${pooman.direction}`, pooman.x, pooman.y, 1, 1, "white", "middle", "middle"); } pooman.timer = 90; gameRoom.spawn(pooman); @@ -855,7 +917,7 @@ editor.click = (x,y)=>{ editor.saveclick = true } } - else { + else { x = Math.floor((x-editor.dPos[0])/32) y = Math.floor((y-editor.dPos[1])/32) // console.debug(x,y) @@ -996,46 +1058,55 @@ window.onwheel = (e)=>{ } } +try { cRoom.start(); -var gameLoop = setInterval(() => { - c.tW = c.c.offsetWidth; - c.tH = c.c.offsetHeight; - c.scale = c.tW / c.w; - frame++; - c.fill("#151f1f"); - - for (let key in keysPressed) { - if (keysPressed[key]) { - if (!keysLastPressed[key]) { - cRoom.keyDown(key); - keysLastPressed[key] = true; - } else if (keysLastPressed[key]) { - cRoom.keyHeld(key); + var gameLoop = setInterval(() => { + c.tW = c.c.offsetWidth; + c.tH = c.c.offsetHeight; + c.scale = c.tW / c.w; + frame++; + c.fill("#151f1f"); + + for (let key in keysPressed) { + if (keysPressed[key]) { + if (!keysLastPressed[key]) { + cRoom.keyDown(key); + keysLastPressed[key] = true; + } else if (keysLastPressed[key]) { + cRoom.keyHeld(key); + } } } - } - if (startclicked) { - cRoom.click(lastClick.x, lastClick.y); - startclicked = false; - } - - cRoom.step(); - cRoom.draw(); - cRoom.drawGUI(); - - /* BEDUG INFO */ - c.dT(`FPS:${Math.round(1000 / (Date.now() - lastTime))}`, 0+c.camera.x, 0+c.camera.y, 1, 1, "#fafafa", "left", "top"); - - switch (cRoom.name) { - case "menu": - case "Editor": - c.ctx.drawImage(images.mouse.cursor, Math.round(mse.x), Math.round(mse.y), images.mouse.cursor.width*2, images.mouse.cursor.height*2); - break; - case "Game": - c.ctx.drawImage(images.mouse.ingame, Math.round(mse.x)-16, Math.round(mse.y)-16, 32, 32); - break; - } - lastTime = Date.now(); - -} , 1000/targFPS); // 60 fps + if (startclicked) { + cRoom.click(lastClick.x, lastClick.y); + startclicked = false; + } + + cRoom.step(); + cRoom.draw(); + cRoom.drawGUI(); + + /* BEDUG INFO */ + c.dT(`FPS:${Math.round(1000 / (Date.now() - lastTime))}`, 0+c.camera.x, 0+c.camera.y, 1, 1, "#fafafa", "left", "top"); + + switch (cRoom.name) { + case "menu": + case "Editor": + c.ctx.drawImage(images.mouse.cursor, Math.round(mse.x), Math.round(mse.y), images.mouse.cursor.width*2, images.mouse.cursor.height*2); + break; + case "Game": + c.ctx.drawImage(images.mouse.ingame, Math.round(mse.x)-16, Math.round(mse.y)-16, 32, 32); + break; + } + lastTime = Date.now(); + + } , 1000/targFPS); // 60 fps + +} catch (error) { + c.fill("#1c1c1c"); + c.dT("Death By Hamster", c.w / 2, c.h / 2 - 40, 2, 2, "white", "middle"); + c.dT(`${error}`, c.w/2, c.h / 2, 1, 1, "red", "middle"); + c.dT(`pls let Bye know by emailing him via`, c.w /2, c.h / 2 + 40, 1, 1, "white", "middle"); + c.dT('bye[at]byecorps.com', c.w / 2, c.h / 2 + 60, 2, 2, "white", "middle"); +} diff --git a/human.aseprite b/human.aseprite index 977d23f02f8006c4001bae5c8558a35737815ac1..bbf2d18c519bd69806ac0458053acf1603e986b1 100644 Binary files a/human.aseprite and b/human.aseprite differ diff --git a/human.png b/human.png index 6dc00291784b44a78d4b1c0bd5217f9b5e3124c0..10ef95d45000bfd431d73903090245bd39b61fcf 100644 Binary files a/human.png and b/human.png differ diff --git a/index.html b/index.html index 30b0ff2b9e91458b00512b7c4a8542470ed48404..15b0ec2f1b2715aa228172678504692a974b97d0 100644 --- a/index.html +++ b/index.html @@ -32,10 +32,9 @@ cursor: none; </style> <aside > - <pre id="leveltext"> </pre> +<pre id="leveltext"></pre> </aside> <canvas width="600" height="400" id="gameCanvas"> </canvas> <script id="fontScript" src="./letters.js"></script> -<script src="./l.js"></script> <script src="./game.js"></script> \ No newline at end of file diff --git a/l.js b/l.js deleted file mode 100644 index 8325473c334e3026b295599210201c9958b7bf25..0000000000000000000000000000000000000000 --- a/l.js +++ /dev/null @@ -1 +0,0 @@ -load_level=b=>{d={};d.t=b.codePointAt(0)-32;d.w=b.codePointAt(1)-32;d.h=b.codePointAt(2)-32;d.z=+b[3];d.m=[];d.M=[];for(i=4;i<b.length;i+=3)d.m.push([b.codePointAt(i)-32,b.codePointAt(i+1)-32,b.codePointAt(i+2)-32]);return d} \ No newline at end of file