Play snake in the URL address bar

demian.ferrei.ro

840 points by macote 3 days ago


Franciscouzo - 3 days ago

I made a similar thing some time ago, but with the favicon.

https://franciscouzo.github.io/favisnake/

MontyCarloHall - 3 days ago

This is awesome. My only issue is that the character used for whitespace looks janky in my browser, like a bunch of non-monospaced squares. A potential remedy: because Unicode contains all 256 possible 4x2 Braille patterns, why not use ⣿ as the background and carve out the snake/food as negative space, e.g.

⣿⣿⣛⣛⣛⣛⣛⣩⣽⣿⣯⣿⣿⣿

This would ensure uniform spacing and is just as legible.

iamjackg - 3 days ago

I was pleasantly surprised by how responsive it was, and overjoyed when I clicked back and immediately came back to HN: no messy history. Genius idea!

dasefx - 3 days ago

Warning, if you actually use your browser history, play this in incognito mode or equivalent.

kwar13 - 3 days ago

What a neat little idea lol. It's using the Braille patterns to update the URL with the dots. Love it.

https://github.com/epidemian/snake/blob/master/snake.js

Nevermark - 3 days ago

Very cool!

I created a snake game like this on the Tandy Pocket Computer. [0]

I even managed to create a 20 room sub-set of Zork.

Desperately primitive times, required desperate game compression measures.

[0] https://en.wikipedia.org/wiki/Tandy_Pocket_Computer

usaphp - 3 days ago

RIP to your history log in the browser.

Uptrenda - 3 days ago

Incredibly out-of-the box, whoever made this. Gives me severe eye strain but I am impressed at the creativity here! Awesome.

Btw small suggestion: might make the game more playable if the snake could loop-back around if it went out of bounds. It would make up for some responsiveness issues. Then just have failure being if you eat yourself.

system2 - 3 days ago

To an average Joe, this might not look like anything but to me this is wild. How do you people even come up with these things...

akarki15 - 3 days ago

This is why i come to hackernews. :) made my day

foresterre - 3 days ago

For those that missed it initially, and didn't quite got how it works the first time, there is a small cyan question mark at the top left, which states:

> Use the arrow keys or WASD to control the snake on the URL. Click here if you can't see the page URL or if it looks messed up with some weird slashes

Additionally: you need a browser window where you're address bar is long enough to see the world ;).

Love the concept, it works quite well!

charcircuit - 3 days ago

>demian.ferrei.ro/snake#|%E2%96%91%E2%96%91%E2%96%91%E2%96%91%E2%A0%88%E2%96%91%E2%96%91%E2%A0%A4%E2%A0%A4%E2%96%91%E2%96%91%E2%96%91%E2%96%91%E2%96%91%E2%96%91%E2%96%91%E2%96%91%E2%96%91%E2%96%91%E2%96%91|[score:0]

This is too confusing to play on firefox.

pards - 3 days ago

Such a unique, innovative idea. Well played.

arguflow - 3 days ago

Harder than I expected, the extra blank dots all around the snake are kind of distracting, how does it look when they aren't on the page?

CobrastanJorji - 3 days ago

Fantastic. I love people finding really creative ways to make things interactive in weird ways. 100% hacker spirit. Good job.

liqilin1567 - 3 days ago

Very interesting. What inspired you to build this, I'd love to hear the story behind this.

terribleperson - 3 days ago

This actually sent me into a fit of laughter at the sheer absurdity. This is incredibly cool.

amelius - 3 days ago

I'm looking for snake that can be played with voice commands.

- 3 days ago
[deleted]
pbd - 3 days ago

ChatGPT can't invent this :-) . Love the creativity.

mr_tox - 3 days ago

next time doom please :)

Danilka - 3 days ago

What the hack, this is absolutely awesome! Pun intended.

pratikstemkar - 3 days ago

made my day. didn't know this was even possible.

boguscoder - 3 days ago

Mind it, mobile browsers seem to be having hard time with this, which is probably expected

MangoToupe - 3 days ago

Is there a demo somewhere for those of us without the intended browser/os combo?

Edit: https://raw.githubusercontent.com/epidemian/snake/refs/heads...

dankle - 3 days ago

Not on mobile you dont

roggenbuck - 3 days ago

This is really creative! Very well done. Surprisingly fast too.

- 3 days ago
[deleted]
alistairSH - 3 days ago

I just see the address? Safari on iOS.

masteruvpuppetz - 3 days ago

HAHAHA looool!! this is awesome

drbig - 3 days ago

Very clever, and playable! Thanks.

jspann - 3 days ago

This is fun!

tbolt - 3 days ago

10/10

650 - 3 days ago

Very cool, would love to see source code. For what its worth no AI was able to replicate this.

throwmeaway222 - 3 days ago

wow- do doom next

zikero - 3 days ago

this is the most cursed thing i've seen

Velocifyer - 3 days ago

This is cool

nenenejej - 3 days ago

Now make it multiplayer!

cwsx - 3 days ago

This is so fucking cool - took me a bit to figure out how the rendering/movement worked but fun after that.

ai_viewz - 3 days ago

nice i enjoyed it

samixg - 3 days ago

it took me a while to understand how to play it, but holy shit this is impressive! nice work

rabbitlord - 3 days ago

Bro the game is intense!

nicman23 - 3 days ago

.... time to port doom ?

epidemian - 3 days ago

Wow! It's such a surprise to see this old project of mine here on HN front page!

I must say, if you're experiencing any issues playing this, it's probably because it was designed to be played on the browsers of 10 years ago hehe. Here's how the game used to look and play in its former days of glory: https://github.com/epidemian/snake/blob/master/gameplay.gif?...

Since then, browsers have made some so-called "security" "improvements" that heavily hindered the capabilities of addressbar-based videogames. You can see traces of this on the game source code, and on the commit history.

At some point, pushing things to `history.replaceState()` got super rate-limited on Chrome, to something like tens of updates per minute IIRC, which totally wrecked the playing experience. I think i got around this by falling back to using `location.hash` directly. I think Chrome later rose this throttling to something more sensible. IDK if enough to play Crysis at 60fps on the addressbar, but enough for a snake game. And if not, sorry for messing up your Back button!

The worst of these security-excused changes was Firefox and Chrome starting to escape all whitespace characters (and others) on URLs. The game uses Braille characters to "render" its grid world, and blank Braille characters are abundant, especially on the early game. I think i made some comments on the browsers' issue trackers, and even received some sympathy from the developers (or maybe this was on the throttling of history, i don't remember). But of course, and as usual, "security" trumps over fun.

I ended up trying to counteract this URL escaping mechanisms with some horrible, really really horrible, indefensible, shameful, canvas-based font-measuring hack to replace blank Braille characters with some other character that doesn't get escaped and is more or less the same width, and as blank as possible. See https://github.com/epidemian/snake/blob/e9d5591a613afabc7e11.... If you have any idea of how to do this in a less soul-damning way, please let me know!

I think the game never worked properly on Safari. I know the browser used to hide the URL fragment, or maybe everything other than the domain name. I've no idea what it does now; does it even allow users to visit random webpages or does it mandate a separate app for everything? /s

In case my pile of hacks fails thoroughly, i resignedly added a way of showing the intended URL on the actual page content, by clicking on the "?"

Anyways, i should probably write a blog post about this little silly thing. Thanks for playing! :)

revanwjy - 3 days ago

[dead]

unit149 - 3 days ago

[dead]

heroku - 2 days ago

Why do people don't work on useful things. Stop mis-using the internet.