-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.min.js
More file actions
1 lines (1 loc) · 7.07 KB
/
Copy pathapp.min.js
File metadata and controls
1 lines (1 loc) · 7.07 KB
1
(function(){const t=h.drawLine.bind(h),o=h.fillRect.bind(h),n=h.drawString.bind(h),e=new Int16Array(20);let l=null,r=null;const c=0;let i="TITLE_SCREEN",v=-1,s=5,y=2,a=new Int16Array(0),x={x:0,y:0,w:18,h:18,hitW:16,hitH:16},f=0,d=0,R=[],A=1,C=0;const u={1:"R",2:"O",3:"A",4:"C",5:"H"},w=10.7,S=21.4,M=new Float32Array(21),O=new Float32Array(21);for(let t=-10;t<=10;t++){const o=.017453292519943295*t;M[t+10]=Math.cos(o),O[t+10]=Math.sin(o)}const F=new Int16Array([420,205,22,62,0,392,260,40,27,2,160,18,160,200,326,113,326,298,340,150,22,110,2,160,95,160,225,323,75,323,245,32,220,22,38,3,18,160,340,160,395,18,465,94,395,298,465,226,75,176,450,36,3,18,160,180,160,300,160,465,160,240,220,240,298,165,210,348,28,3,200,184,200,298,120,110,200,184,330,18,330,165,357,130,22,110,4,160,160,223,70,95,160,158,250,310,160,373,70,245,160,308,250,35,65,190,28,4,140,18,140,135,100,215,220,250,300,115,465,115,316,175,316,258,172,172,22,38,4,18,160,219,160,175,235,246,120,350,18,380,145,290,220,385,220,250,186,22,32,5,18,145,305,145,90,145,90,210,305,145,305,238,140,238,305,238,382,66,465,116]);function I(t){let o=0;for(let n=0;n<t;n++)o+=5+4*F[o+4];return o}function L(){i="TITLE_SCREEN",v=-1,h.setColor(0).fillRect(0,0,480,320).setColor(2).drawRect(18,18,465,298),h.setFont("Monofonto36").setFontAlign(0,-1).setColor(3).drawString("RADROACH RACES",240,52).setFont("Monofonto18").setFontAlign(0,-1).setColor(2).drawString("by Theeohn",360,94),h.setColor(2).drawLine(55,180,425,180).drawLine(55,200,425,200);for(let t=75;t<425;t+=35)h.fillRect(t,150,t+15,230);for(let t=35;t<445;t+=12)h.drawLine(t,230,t-4,210).drawLine(t+3,230,t+6,205);h.setColor(3).fillEllipse(200,165,280,215).fillCircle(240,150,18).drawLine(236,138,205,105).drawLine(244,138,275,105).drawPoly([205,165,180,175,165,200],!1).drawPoly([200,190,175,200,160,230],!1).drawPoly([275,165,300,175,315,200],!1).drawPoly([280,190,305,200,320,230],!1),h.setFont("Monofonto23").setFontAlign(0,-1).setColor(3).drawString("PRESS LEFT WHEEL TO START!",240,255),Pip.onExclusive("knob1",T)}function T(t){0===t&&("TITLE_SCREEN"===i?(Pip.audioStart("HOLO/RADROACH_RACES/assets/BUGLE.WAV"),p()):"GAMEOVER"===i&&L())}function p(){i="COUNTDOWN",s=5,y=Math.randInt(10);const t=I(y),o=F[t+4];a=new Int16Array(4*o);for(let n=0;n<o;n++){const o=t+5+4*n,e=4*n;a[e]=F[o],a[e+1]=F[o+1],a[e+2]=F[o+2],a[e+3]=F[o+3]}x.x=F[t],x.y=F[t+1],f=F[t+2],d=F[t+3];const n=1===y||5===y||7===y,e=n?[0,21,42,63,84]:[0,23,44,65,86];for(let t=4;t>0;t--){const o=Math.randInt(t+1),n=e[t];e[t]=e[o],e[o]=n}R=[{id:1,cx:f+7+(n?e[0]:0),cy:d+7+(n?0:e[0]),vx:0,vy:0},{id:2,cx:f+7+(n?e[1]:0),cy:d+7+(n?0:e[1]),vx:0,vy:0},{id:3,cx:f+7+(n?e[2]:0),cy:d+7+(n?0:e[2]),vx:0,vy:0},{id:4,cx:f+7+(n?e[3]:0),cy:d+7+(n?0:e[3]),vx:0,vy:0},{id:5,cx:f+7+(n?e[4]:0),cy:d+7+(n?0:e[4]),vx:0,vy:0}];for(let t=0;t<R.length;t++)N(R[t],4);r&&clearInterval(r),r=setInterval(P,1e3),P()}function P(){"COUNTDOWN"===i&&(h.setColor(0).fillRect(0,0,480,320),H(),m(),s>0?(h.setFont("Monofonto96").setFontAlign(0,0).setColor(3).drawString(s.toString(),240,160),h.setColor(0).fillRect(67,226,407,275).setColor(3).drawRect(69,228,405,273),h.setFont("Monofonto36").setFontAlign(0,-1).setColor(3).drawString("PLACE YOUR BETS!!!",240,230),s--):(clearInterval(r),r=null,i="RACING",A=1))}function m(){"ram";h.setColor(3).setFont("Monofonto23").setFontAlign(0,0);for(let t=0;t<R.length;t++){const o=R[t];n(u[o.id],o.cx,o.cy)}}function H(o,n,e,l){"ram";void 0===o&&(o=0,n=0,e=480,l=320),o<=465&&e>=18&&n<=298&&l>=18&&h.setColor(3).drawRect(18,18,465,298);for(let r=0;r<a.length;r+=4){const c=a[r],i=a[r+1],v=a[r+2],s=a[r+3],y=void 0,x=void 0,f=void 0,d=void 0;(c<v?v:c)<o||(c<v?c:v)>e||(i<s?s:i)<n||(i<s?i:s)>l||t(c,i,v,s)}e>=225&&o<=320&&l>=302&&n<=316&&h.setFont("Monofonto14").setFontAlign(-1,-1).setColor(3).drawString("Map "+(y+1),225,302);const r=x.x-6,c=x.y-8,i=x.x+x.w+6,v=x.y+x.h+11;e>=r&&o<=i&&l>=c&&n<=v&&h.setColor(3).fillRect(x.x,x.y,x.x+x.w,x.y+x.h).setColor(2).fillRect(x.x+6,x.y-8,x.x+11,x.y).fillRect(x.x-6,x.y+6,x.x,x.y+11)}function N(t,o){const n=void 0,e=.017453292519943295*Math.randInt(400);t.vx=Math.cos(e)*o,t.vy=Math.sin(e)*o}function W(t){"ram";const o=Math.randInt(21),n=M[o],e=O[o],l=t.vx,r=t.vy;t.vx=l*n-r*e,t.vy=l*e+r*n}function D(t){"ram";let o=!1;const n=w;t.cx-n<=18?(t.cx=28.7,t.vx=t.vx<0?-t.vx:t.vx,o=!0):t.cx+n>=465&&(t.cx=454.3,t.vx=t.vx>0?-t.vx:t.vx,o=!0),t.cy-n<=18?(t.cy=28.7,t.vy=t.vy<0?-t.vy:t.vy,o=!0):t.cy+n>=298&&(t.cy=287.3,t.vy=t.vy>0?-t.vy:t.vy,o=!0);for(let e=0;e<a.length;e+=4){const l=a[e],r=a[e+1],c=void 0,i=void 0,v=a[e+2]-l,s=a[e+3]-r,y=v*v+s*s;let x=y>0?((t.cx-l)*v+(t.cy-r)*s)/y:0;x<0?x=0:x>1&&(x=1);const f=l+x*v,d=r+x*s,R=t.cx-f,A=t.cy-d,C=R*R+A*A;if(C<n*n&&C>0){const e=Math.sqrt(C),l=R/e,r=A/e,c=n-e;t.cx+=l*c,t.cy+=r*c;const i=t.vx*l+t.vy*r;if(i<0){t.vx-=2*i*l,t.vy-=2*i*r;const n=Math.sqrt(t.vx*t.vx+t.vy*t.vy);n>0&&(t.vx=t.vx/n*3,t.vy=t.vy/n*3),W(t),o=!0}}}if(o){getTime()-C>=.2&&(C=getTime(),Pip.audioStart("HOLO/RADROACH_RACES/assets/FLAP.WAV"));const o=t.vx<0?-t.vx:t.vx,e=t.vy<0?-t.vy:t.vy;let l=0;if(t.cx-n<=19?o<1.5&&(t.vx=1.5,l=1):t.cx+n>=464&&o<1.5&&(t.vx=-1.5,l=1),t.cy-n<=19?e<1.5&&(t.vy=1.5,l=1):t.cy+n>=297&&e<1.5&&(t.vy=-1.5,l=1),l){const o=Math.sqrt(t.vx*t.vx+t.vy*t.vy);o>0&&(t.vx=t.vx/o*3,t.vy=t.vy/o*3)}}}function b(){"ram";for(let t=0;t<R.length;t++)for(let o=t+1;o<R.length;o++){const n=R[t],e=R[o],l=S,r=n.cx-e.cx,c=n.cy-e.cy,i=r*r+c*c;if(i<l*l&&i>0){const t=Math.sqrt(i),o=r/t,v=c/t,s=l-t;n.cx+=o*s*.5,n.cy+=v*s*.5,e.cx-=o*s*.5,e.cy-=v*s*.5;const y=void 0;if((n.vx-e.vx)*o+(n.vy-e.vy)*v>=0)continue;const a=n.vx*o+n.vy*v,x=e.vx*o+e.vy*v;n.vx+=(x-a)*o,n.vy+=(x-a)*v,e.vx+=(a-x)*o,e.vy+=(a-x)*v;let f=Math.sqrt(n.vx*n.vx+n.vy*n.vy);f>0&&(n.vx=n.vx/f*4,n.vy=n.vy/f*4),f=Math.sqrt(e.vx*e.vx+e.vy*e.vy),f>0&&(e.vx=e.vx/f*4,e.vy=e.vy/f*4),W(n),W(e),getTime()-C>=.2&&(C=getTime(),Pip.audioStart("HOLO/RADROACH_RACES/assets/FLAP.WAV"))}}}function G(){"ram";if("RACING"!==i)return;if(A)return A=0,h.setColor(0).fillRect(0,0,480,320),H(),m(),h.flip(),Pip.lastFlip=getTime(),void 0;let t=0;h.setColor(0);const n=w;for(let l=0;l<R.length;l++){const r=R[l],c=r.cx-n-2,i=r.cy-n-2,v=r.cx+n+2,s=r.cy+n+2;o(c,i,v,s),e[t++]=c,e[t++]=i,e[t++]=v,e[t++]=s}for(let t=0;t<R.length;t++){const o=R[t];o.cx+=o.vx,o.cy+=o.vy,D(o)}b();let l=e[0],r=e[1],c=e[2],s=e[3];for(let t=4;t<20;t+=4)e[t]<l&&(l=e[t]),e[t+1]<r&&(r=e[t+1]),e[t+2]>c&&(c=e[t+2]),e[t+3]>s&&(s=e[t+3]);h.setClipRect(l,r,c,s),H(l,r,c,s),h.setClipRect(0,0,480,320);const y=x.x-n,a=x.x+x.hitW+n,f=x.y-n,d=x.y+x.hitH+n;for(let t=0;t<R.length;t++){const o=R[t];if(o.cx>=y&&o.cx<=a&&o.cy>=f&&o.cy<=d){i="GAMEOVER",v=o.id,Pip.audioStart("HOLO/RADROACH_RACES/assets/WINNER.WAV");break}}m(),"GAMEOVER"===i&&V(),h.flip(),Pip.lastFlip=getTime()}function V(){h.setColor(0).fillRect(120,130,360,190).setColor(3).drawRect(122,132,358,188),h.setFont("Monofonto16").setFontAlign(0,-1).setColor(3).drawString('"'+u[v]+'" ROACH WINS!!!',240,140).setFont("Monofonto14").drawString("Press left wheel to race again!",240,167)}function _(){"ram";"RACING"===i&&G()}return L(),l=setInterval(_,33),{id:"RADROACHRACES",notDefault:!0,fullscreen:!0,remove:function(){l&&(clearInterval(l),l=null),r&&(clearInterval(r),r=null),Pip.removeListener("knob1",T),Pip.audioStop()}}});