RE: Post making contest
06-18-2016, 03:27 AM
(06-18-2016, 03:22 AM)Kaynato Wrote: »function vec2(a,b){this.x=a,this.y=b,this.add=function(a,b){this.x+=a,this.y+=b},this.sub=function(a,b){this.x-=a,this.y-=b},this.mul=function(a,b){this.x*=a,this.y*=b},this.set=function(a,b){this.x=a,this.y=b},this.addV=function(a){this.add(a.x,a.y)},this.subV=function(a){this.sub(a.x,a.y)},this.mulV=function(a){this.mul(a.x,a.y)},this.setV=function(a){this.set(a.x,a.y)},this.toString=function(){return"("+this.x+", "+this.y+")"},this.toPx=function(){return this.x+"px "+this.y+"px"}}function cssdiv(a){this.e=$(a),this.getLeft=function(){return this.e.cssNumber("left")},this.getTop=function(){return this.e.cssNumber("top")},this.getWidth=function(){return this.e.cssNumber("width")},this.getHeight=function(){return this.e.cssNumber("height")},this.getRight=function(){return this.getLeft()+this.getWidth()},this.getBottom=function(){return this.getTop()+this.getHeight()},this.setLeft=function(a){this.e.css("left",L+"px")},this.setTop=function(a){this.e.css("top",a+"px")}}function updateTicks(a){tickSpeed=a,clearInterval(fticks),fticks=setInterval("figur.tick()",tickSpeed)}function queue(a,b,c){clearTimeout(queueEvent),queueEvent=setTimeout(a,b*tickSpeed+c)}function randInt(a){return Math.floor(Math.random()*a)}function chance(a,b){return randInt(b)<a}function trigger(a,b){return a>b?1:-b>a?-1:0}function between(a,b,c){return a>b&&c>a}function decf(a,b){return b>=a?a:b}function dbTxt(a,b){DEBUG&&$("#debug"+a).text(b)}function getFrame(a){1==a.dir?a.elem.e.removeClass("flip"):-1==a.dir&&a.elem.e.addClass("flip");for(var b=a.state[a.framenum];void 0==b;)a.framenum--,b=a.state[a.framenum];var c=b[0]*-a.dim.x,d=b[1]*-a.dim.y;return++a.framenum>=a.state.length&&(a.framenum-=a.framenum),0!=c&&(c+="px"),0!=d&&(d+="px"),c+" "+d}function activePhysics(){var a=$(".mass");if(!figur.dragged){figur.v.y+=gravity;var b=detTop(a),c=detLeft(a);a.css("top",b-$(document).scrollTop()+"px"),a.css("left",c+"px")}if(!figur.airborne){var d=1*figur.v.x,e=1-friction;figur.v.x=d>0?Math.floor(e*d):Math.ceil(e*d)}var f=figur.activevx+figur.v.x;inBounds(figur,mouse.r.x,mouse.r.y)&&(figur.alone-=decf(figur.alone,figur.friendliness)),dbTxt(7,figur.state_name(figur.state)+" : "+figur.framenum),dbTxt(9,"position: "+figur.r.toString()+"\n"+figur.elem.getLeft()+" "+figur.elem.getTop()),dbTxt(10,"vel: "+f+", "+figur.v.y),dbTxt(11,(figur.active?"ACTIVE":"INACTIVE")+" "+(figur.animate?"ANIMATE":"STILL")+" ticks: "+tickSpeed),dbTxt(12,figur.hurt+" >> "+figur.recoveryTime),dbTxt(13,$(document).scrollTop()),dbTxt(15,figur.airborne?"ON AIR":"ON GROUND")}function detTop(a){var b=$(document).scrollTop()+window.innerHeight,c=b-a.cssNumber("height"),d=figur.r.y,e=d+figur.v.y;if(e>=c)return figur.ground©;var f=figur.state;return figur.dirsign(figur.activevx+figur.v.x),figur.v.y>0&&f!=figur.ff.fall&&f!=figur.ff.beginfall&&figur.beginfall(),figur.airborne=1,figur.r.y=e,Math.floor(figur.r.y)}function detLeft(a){return figur.activevx=figur.xVelbase*figur.mouseDistFactor(),figur.r.x+=figur.v.x+figur.activevx,figur.r.x<0&&(figur.v.x<33&&(figur.hurt-=figur.v.x/33),figur.v.x*=figur.v.x>=0?.9:-.9),figur.r.x+a.cssNumber("width")>window.innerWidth&&(figur.v.x>33&&(figur.hurt+=figur.v.x/33),figur.v.x*=figur.v.x>=0?-.9:.9),Math.floor(figur.r.x)}function inBounds(a,b,c){var d=" < ";return dbTxt(2,a.getLB()+d+b+d+a.getRB()),dbTxt(3,a.getTB()+d+c+d+a.getBB()),between(b,a.getLB(),a.getRB())&&between(c,a.getTB(),a.getBB())}var DEBUG=0,gravity=.8,tickSpeed=200,tickSpeed_default=200,friction=.05,queueEvent=null,gravi=setInterval("activePhysics()",20),fticks=setInterval("figur.tick()",tickSpeed),mouse={r:new vec2(window.innerWidth/2,window.innerHeight/2),v:new vec2(0,0)},Vector={sum:function(a,b){return new vec2(a.x+b.x,a.y+b.y)},diff:function(a,b){return new vec2(a.x-b.x,a.y-b.y)}};jQuery.fn.cssNumber=function(a){var b=parseInt(this.css(a),10);return isNaN(b)?0:b};var figur={id:-1,elem:new cssdiv("#figure"),initialize:function(){void 0==window.fstack?window.fstack=[this]:window.fstack.push(this),this.id=window.fstack.length-1,this.elem=new cssdiv("#figure"),this.elem.setTop(0),this.r=new vec2(this.elem.getLeft(),this.elem.getTop()+$(document).scrollTop()),this.state=this.ff.idle},leave:function(){clearTimeout(gravi),clearTimeout(fticks),window.fstack.forEach(function(a,b,c){a.id==this.id&&c.splice(b,1)}),this.elem.e.remove()},skin:0,r:new vec2(0,0),activevx:0,xVelbase:0,v:new vec2(0,0),alone:0,dir:0,dragged:0,airborne:1,active:1,recoveryTime:1,hurt:0,animate:1,friendliness:10,down:0,maxAllowV:20,mOff:new vec2(0,0),fov_angle:Math.PI/12,framenum:0,dim:new vec2(150,150),fr_xMargin:25,fr_topMargin:0,ff:{idle:[[0,0],[1,0],[2,0],[3,0]],seek:[[3,1],[3,1],[4,1],[4,1],[4,1],[4,1],[3,1],[3,1],[3,1]],turn:[[3,0],[3,0],[3,0],[3,0],[4,0],[4,0],[4,0],[4,0],[4,0]],tocen:[[5,0],[4,0],[3,0]],tosid:[[3,0],[4,0],[5,0]],walk:[[5,0],[0,1],[1,1],[2,1]],dragged:[4,1],fall:[[5,1],[0,2]],floor:[[1,2],[2,2],[3,2],[3,2]],beginfall:[[3,3],[4,3],[5,3],[3,2],[3,2],[1,2],[1,2]],sleep:[[3,2]],rise:[[4,2],[4,2],[5,2],[5,2],[5,2],[5,2]],prepjumpup:[[0,3]],jumpup:[[1,3]],prepjumpside:[[2,3]],jumpside:[[3,3]]},state:0,is:function(a){return figur.state===a},tick:function(){this.dragged||(this.animate&&this.elem.e.css("background-position",getFrame(this)),!this.airborne&&this.active&&(this.is(this.ff.idle)&&chance(this.alone,80)||this.is(this.ff.walk)?this.seekMouse():this.alone++)),dbTxt(6,"time: "+this.alone),dbTxt(8,"direction: "+this.dir)},getLB:function(){return this.elem.getLeft()+this.fr_xMargin},getRB:function(){return this.elem.getRight()-this.fr_xMargin},getTB:function(){return this.elem.getTop()+this.fr_topMargin+$(document).scrollTop()},getBB:function(){return this.elem.getBottom()+$(document).scrollTop()},seekMouse:function(){var a=this.getLB(),b=this.getRB(),c=this.getTB();if(between(mouse.r.x,a,b))mouse.r.y<c?this.seek(0,1,0,0):(this.changeDir(0),this.alone=0,this.hurt-=decf(this.hurt,.2));else{var d=mouse.r.x>b?1:-1,e=mouse.r.x>b?mouse.r.x-b:a-mouse.r.x,f=Math.atan2(c-mouse.r.y,e),g=Math.PI/2-this.fov_angle;f<this.fov_angle?this.is(this.ff.idle)?this.seek(d,0,e,d):this.setWalk(d,0):f>g?this.seek(0,1,e,d):this.seek(d,1,e,d)}},mouseDistFactor:function(){return 1+2*(mouse.r.x>this.getLB()?mouse.r.x-this.getLB():this.getLB()-mouse.r.x)/window.innerWidth},seek:function(a,b,c,d){0!=a?b?this.prepJump(a,c,d):this.setSeekHoriz(a):b&&(chance(this.a
I don't think this passes 3
This passes 4 though.
(06-18-2016, 03:24 AM)Kaynato Wrote: »abcdeFGHIJklmnoPQRSTuvwxyZ0000
Passes 4
(06-18-2016, 03:25 AM)Akumu Wrote: »Of sheqel, boys codgers view the expert zither jive
Passes 245