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.
One thing I don't understand is the role of the "</svg>" closing tag. I didn't immediately see any reference to an open or closing svg tag anywhere in the source.
Same with the </canvas> 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 added.
Why was this code and a lot of similar code posted to github only 2 hours ago?
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!
I also had performance issues in Firefox, so I tried something else: just holding the up key. It was surprisingly effective. Not that it didn't fail a lot, but it progressed through the levels at a fairly even pace.
Unless I misunderstand the maths, the hold-up strategy has the same probability of winning regardless of which level one is at, since the levels only increase the speed of the obstacles and not their density. I would have thought the difficulty would ramp up such that even stupid strategies get less effective at higher levels, but not this time!
> the levels only increase the speed of the obstacles and not their density.
But your speed is the same at every level.
Instead of looking at the width of each obstacle, instead look at the amount of space that the obstacle covers during the time you are in its path. If it moves faster then it covers more space during the time it takes you to cross, so it is effectively wider.
Imagine if the obstacles moved so fast that they crossed from one side of the screen to the other in the time it takes you to move up one line. You would never be able to pass any obstacle.
I was under the impression my speed was one unit distance per frame. That would mean the speed of the obstacles is irrelevant becuse either they are in my location in that one frame or they are not -- and it doesn't matter how fast they go.
Edit: actually thanks to their double thickness it does matter! I didn't think of that.
I suppose it depends on how collision detection is implemented. Maybe the cars tunnel through the frog at later levels? Although it does not seem to get easier at higher levels (got up to level 62 using the potato method).
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.
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.
Looks like the lag can be fixed by only updating b.innerText once per frame. This seems like a ff bug to be honest, but it appears that rapidly updating the size of innerText is the culprit.
Turns out if you do this, then hold the up key, it would appear that you avoid collision detection. Also, it appears your X position is preserved between levels, allowing you to hold the up arrow to rapidly advance levels.
Since this respawns really fast and there's no life limit, I wanted to see how far I could get through the mere persistence strategy of holding the up key. I automated this with an ethernet crimping tool whose weight and shape is ideal for pressing it down. After about 40 minutes it's at level 38
Pretty cute, and it gets super fast pretty quickly.
I got to level six on the first go, but after that I noticed if you move one pixel off the side of the screen you could just hold down "UP" to advance levels every few seconds.
If you're patient, you can just hold 'up' anywhere and it will eventually clear the level. It started taking quite awhile at level 20 or so - I got bored and gave up.
I like this, except I'm really not a fan of needing to rapidly tap a key to move repeatedly in one direction. I don't know how many shortcuts were needed to get to 256 bytes, but I think the game would benefit from significantly shorter key repeat.
The repeat delay is actually controlled by your OS here because it's just a simple onkeydown event. Implementing movement rate would require far more code because you need up and down listeners and a state.
It depends on an up arrow keystroke, so technically you could use Android Debug Bridge... Unless there is a way to overlay a software button in the foreground on a phone that I'm not aware of.
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.
His web desktop showcasing his generative stuff https://generative.3d2k.com/
He makes lots of tiny code demos like this and shares on twitter every once in a while https://twitter.com/KilledByAPixel
His dwitter work https://www.dwitter.net/u/KilledByAPixel/top
His games https://killedbyapixel.newgrounds.com/games
His blogposts https://frankforce.com/