Skip to content

Packed code misbehaving in Chrome #81

@nrkn

Description

@nrkn

Wondering if you had any advice or if you've come across something similar before

My packed js1k entry is misbehaving in Chrome (working in FF, Edge) - the unpacked version works fine

If you want to see the issue happening, this is the project, you can just open index.html in Chrome:

https://github.com/nrkn/js1k-2018-roguelike

As soon as you go down the stairs - > - on the first level it starts behaving strangely

Using the online packer with 1/0/0 most copies first

Code in question, before packing:

let l,t=0,e=[0,0,0,10,"@","#39f"],f=l=>Math.random()*l|0,r=(l,t)=>{for(let e=0;e<l.length;e++)if(l[e][3]&&t[0]==l[e][0]&&t[1]==l[e][1])return l[e]},h=(l,t,e,f)=>{f?l[0]<t[0]?t[0]--:l[0]>t[0]?t[0]++:l[1]<t[1]?t[1]--:l[1]>t[1]&&t[1]++:1==e?t[1]--:2==e?t[0]++:3==e?t[1]++:t[0]--},o=()=>{l=[[[e[0],e[1],3,1,".","#aaa"]],[e]];let a=f(10*t)+10,o=f(10*t)+10,i=f(2*t)+2,n=f(2*t)+2,u=f(2*t)+2,c=(t,e,h,i)=>{let n=[f(a),f(o),t,e,h,i];return r(l[0],n)&&!r(l[1],n)?(l[1].push(n),n):c(t,e,h,i)},d=(t,e)=>{if(r(l[0],e)||l[0].push([e[0],e[1],3,1,".","#aaa"]),t[0]==e[0]&&t[1]==e[1])return;let a=f(4);h(t,e,a,!f(3)),d(t,e)};for(let t=0;t<i;t++)d(l[0][f(l[0].length)],[f(a),f(o)]);c(2,1,t>8?"$":">",t>8?"#39f":"#000");for(let l=0;l<n;l++)c(1,1,"m","#f00");for(let l=0;l<u;l++)c(4,1,"¢","#f90")},i=()=>{a.width=a.width;let f=e[3]<1,h=t>9;for(let t=0;t<25;t++)for(let a=0;a<25;a++){let o=e[0]-12+a,i=e[1]-12+t,n=r(l[1],[o,i])||r(l[0],[o,i]);n||(l[1].push([o,i,5,1,"#","#aaa"]),n=r(l[1],[o,i])),a>=8&&t>=8&&a<17&&t<17&&(n[6]=1),c.fillStyle=f||h?"#39f":n[5],c.fillText(h?"$":f?0:n[6]?n[4]:" ",10*a,10*t)}f||h||(c.fillStyle="#000",c.fillText(1+t+" ¢"+e[3],0,250))},n=(a,i)=>{let n=[a[0],a[1]];h(e,n,i,1==a[2]&&f(5));let u=r(l[1],n);u&&1==a[2]&&0==u[2]&&f(2)?u[3]--:u&&0==a[2]&&1==u[2]&&f(2)?u[3]--:u&&0==a[2]&&2==u[2]?(t++,o()):u&&4==u[2]?(a[3]++,u[3]--):r(l[0],n)&&!u&&(a[0]=n[0],a[1]=n[1])};b.onkeydown=(t=>{n(e,t.which-37);for(let t=0;t<l[1].length;t++)l[1][t][3]&&1==l[1][t][2]&&n(l[1][t],f(4));i()}),o(),i()

Any ideas? I thought I could maybe work around it by using different settings but sadly none of the others get it down to 1024 bytes

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions