Live data from Hacker News

Cross My Heart – A Frogger Demake in 256 Bytes of HTML/JS

killedbyapixel.github.io

31–40 of 51 posts

Re: Cross My Heart – A Frogger Demake in 256 Bytes of HTML/JS

#31

Here is the entire script of the game (I added line breaks, I hope in places that don't break the code): X=Y=V=U=Z=t=1;onkeydown=e=>(k=e.which)&1?X-=k-38:Y-=k-39; setInterval("for(++t,o=Z,i=50;i--;)for(b.innerText=o+='\\n',j=99; j--;Y>49?Z+=Y=1:o+=i-Y|j-X-50?q?'.':'':q?'♥':Y=1) q=((j+t*Math.sin(A=i>>1)/9*Z>>3)*A*Z)**4%97 The obstacle generation code is very strange and deserves more study. But really remarkable - a t…

You can replace the two " with ` so that the code in setInterval is still treated as a string.

Also, see the section:

q?'♥':Y=1

The code is minimized by setting Y back to 1 instead of providing a character to display but this has the visual side effect of "squashing" the player when they are run over.

Re: Cross My Heart – A Frogger Demake in 256 Bytes of HTML/JS

#32
post #25
post #12

Earlier quoted context omitted.

Looks like a job for the new profiler.firefox.com

Here's a profile of the freeze being caused the GC if anyone wants to try and debug: https://share.firefox.dev/487vDxG

The profile actually shows the freeze is not caused by normal JS garbage collection, but by cycle collection. So probably something related to DOM nodes.

Re: Cross My Heart – A Frogger Demake in 256 Bytes of HTML/JS

#33
post #28
post #20

Chatgpt 3.5 actually gave a pretty good answer on what the code does: https://chat.openai.com/share/1d55622a-c9cc-4daf-97de-d766e2...

"The animation has some randomness" - really? Where?

The expression involving Math.sin is acting as a PRNG. The vehicles have randomised sizes and speeds.

Re: Cross My Heart – A Frogger Demake in 256 Bytes of HTML/JS

#36

Very fun for 256 bytes. The script itself looks beautifully compressed as well. I think gameplay is a bit dampened by the scale of the board vs your character though. In Frogger (at least the one I remember) the cars are the same size as the player. Here they are double height which quickly turns it into a game of trying to tap as fast as possible even when you're only trying to pass one oncoming car a few levels in.…

Same with the tag. Are these closing tags needed for some "reason"? I suspect the second (and third) line is included by mistake. Also, if we are counting bytes, the closing pre tag is required and should be counted. The game also relies on filtering out non-arrow key presses but this code isn't compressed or counted at all. The instruction "Do not press any other keys" seems superfluous with the extra onkeydown code…

hey just a quick update from the author. I release3d this just today. Only the top part of the code (256 bytes) is necessary, bottom stuff is just a bit extra to add some context for people going directly to the github version!

Re: Cross My Heart – A Frogger Demake in 256 Bytes of HTML/JS

#38
post #20

Chatgpt 3.5 actually gave a pretty good answer on what the code does: https://chat.openai.com/share/1d55622a-c9cc-4daf-97de-d766e2...

4.0, as expected, even seems aware it's a small code demo and some more insight https://chat.openai.com/c/68a51900-4d33-4d1b-bd14-247a739183...

Re: Cross My Heart – A Frogger Demake in 256 Bytes of HTML/JS

#39

Earlier quoted context omitted.

Same with the tag. Are these closing tags needed for some "reason"? I suspect the second (and third) line is included by mistake. Also, if we are counting bytes, the closing pre tag is required and should be counted. The game also relies on filtering out non-arrow key presses but this code isn't compressed or counted at all. The instruction "Do not press any other keys" seems superfluous with the extra onkeydown code…

hey just a quick update from the author. I release3d this just today. Only the top part of the code (256 bytes) is necessary, bottom stuff is just a bit extra to add some context for people going directly to the github version!

Ahh yeah, that makes sense. Cheers for doing that. I enjoyed unwinding it and playing with it.

Re: Cross My Heart – A Frogger Demake in 256 Bytes of HTML/JS

#40

Another game ruined by garbage collection. At least run the gc on every frame.

I don't think there is a way to do that on a standard browser setup (nor would I want the browser trying to assume this kind of output should be collected every frame itself). Not to mention even if there was it'd probably not be worth the extra bytes in this kind of demo.
Post reply on HN