Lurker News

Comments (92) 27 threads

JaneOri5 replies#
I realize this is an absurd thing to do, but it was fun and I wanted to test the limits of CSS again so I could share the results!

I linked to the README since any web devs that see this will probably want to know how buuut here's a link to the game if you want to go hands on:
https://propjockey.github.io/css-sweeper/#randommenu
It's all open source, and I discuss some details of how to do it in that readme, but I am more than happy to answer any questions!
Thanks for checking it out!

ceocoder2 replies#
That is impressive, just impressive. Brought back some fond memories of installing Windows XP over and over again for family and friends with fckgw rhqq2 yxrkt 8tg6w and playing minesweeper before handing it off to them.

Great job!

krrrh1 reply#
“fckgw rhqq2 yxrkt 8tg6w. There’s a name I’ve not heard in a long, long time.”
ceocoder#
this should be like a secret handshake or even better our version of windmill high-five from Top Gun. Still can't believe that I can enter that S/N without having to even think about it.
Aeolun2 replies#
Is there something magic about that code?
ceocoder#
Yes - https://en.wikipedia.org/wiki/Volume_licensing#Leaked_keys

tl;dr I grew up in India where the Indian Rupee was quite weak compared to the USD. Most people I knew couldn't really afford a legitimate copy of Windows XP - 1 USD was about 48.61 INR in 2002, and average wage was about 120 INR/day[0]. At that price a copy of Windows XP (priced at around $300/$400 ~ INR 14,000) was prohibitively expensive for pretty much everyone I knew. Because of that we ended up using leaked keys to setup new PCs, I did that enough times for my family, friends, and classmates that now I can type that key up as if I'm typing "hello world" :)
[0] https://www.ilo.org/wcmsp5/groups/public/---asia/---ro-bangk...

panda88888#
It’s the most popular Windows 98 cd key back in the old days.
jonny_eh2 replies#
This should make white-boarding interviews a lot more fun. "Please implement Minesweeper, but only using HTML + CSS"
ARandomerDude1 reply#
Why would you give "them" ideas?
pedrocx486#
It's good to see which companies you shouldn't work for.
atoav#
At some point questions like these become more like: Guess which exact sentence I am thinking about

I am very good with HTML and CSS and would definitely be able to solve sth like this. But not on a whiteboard, I would have to be able to fool around with it.

elteto2 replies#
Fantastic! Are you proud that you can call yourself an HTML programmer now?
James0x57#
lmao, I've come full circle. Excellent callout. hahaha
Sebb767#
Technically he's a CSS programmer ;)
Diskutant2 replies#
Doesn’t work on iOS?
faeyanpiraat#
Can confirm
Diskutant1 reply#
The "Play it here" link on the github page works.

Seems like the "click click" message, which is shown only on op's direct link, causes some problems.

James0x571 reply#
OHHH I wish the others would have been more specific other than "it doesn't work". Thank you!

The way that random thing works is:
1) #randommenu:target shows the overlay (based on hash in the url)
2) the overlay has a link to "#" (fullscreen) that says "click-click"
3) Then rendered ontop of the link, all 16 level labels are full screen & transparent
4) Animations loop through them (hard-coded random scramble) to change their z-index to be on top, one at a time, for about 0.25s each
5) Clicking on any of the labels causes that layer to disappear, exposing the "#" link
6) Clicking again changes the url to "#" so #randommenu is no longer :target, thus closing the overlay
My guess is it's probably flashing too fast for iOS/Safari to register a full click.. I could probably fix it by making the random sequence take longer.
Can you confirm the URL never changes to "#" and stays stuck on "#randommenu"?

Continue this thread — 1 reply

cnees3 replies#
No way! I've done exactly the same thing. (https://news.ycombinator.com/item?id=15479160) At first I thought this was my own thread! I guess there's a healthy overlap between loving Minesweeper puzzles and CSS puzzles. :)

I used HTML/CSS so I could implement it on a Neopets page, which meant I couldn't use forms, inputs, or CSS3, which means it's less feature-complete and the approach is completely different. The final result, though, is still the same delightful Minesweeper experience.
http://www.neopets.com/~Cism
Codepen link (so you don't have to be signed into Neopets to see it)
https://codepen.io/qaz/pen/bGEzyrJ
Enjoy!

cnees#
To emulate Minesweeper's not-a-bomb-on-the-first-click experience, I start the board off with a generous region revealed, and then to emulate flood-filling, I make blank cells sit in an invisible (overflow hidden) scroll box that scrolls to a revealed version of the region when you click the blank cells, which have relative links. That only works for rectangular regions, but I remember having a way to make it work with irregularly shaped regions and being too lazy to implement it because it was going to be even trickier and uglier than what I was already doing. I'll leave that as an exercise for the reader. :P
LoSboccacc1 reply#
both lack the left+right click that reveals tiles around numbers that have the sufficient amount of bomb marked, I'm curious what's the css/html limitation that prevents the implementation of that behavior?
James0x571 reply#
You can't (afaik) tell if it's a right-click vs left-click in HTML+CSS alone that causes the el state to change - that info is part of the JS event :)

Continue this thread — 1 reply

James0x571 reply#
This is awesome - Could you please explain how you're holding state of each box individually without checkbox:checked? It's not immediately obvious to me how that's possible or where it's happening in your code!
cnees2 replies#
Thanks!

I use scroll position to keep the state. In effect, each square is in a div with overflow:hidden. (In the actual code I used , not , which might've been to save bytes because the server is so slow). It has a fixed visible height, the height of the square. Above the fold (before scrolling) is the un-clicked square, and below the fold (what you see after scrolling) is the clicked square.
Since overflow is hidden, you have to use an in-page anchor link to scroll to the clicked state. The unclicked version of each cell is an anchor to the clicked version.

Continue this thread — 2 replies

uxamanda1 reply#
This is really cool! I saw your responsive library[0] post [1] the other day, but couldn't quite wrap my head around it.

With this post, I think I am starting to grok the (Space Toggle) trick. The Tweet you linked in your library was really helpful [2].
My current understanding is – in CSS, you can set a variable to nothing (a space). When a property contains that "blank" variable, it is replaced by nothing and so the second, "fallback" value is the default. Because you can update CSS variables within more specific or later CSS, you can update the "blank" variable and give it a new value of "initial", this causes it to switch from the default to the defined override.
I realized, you can even combine this with the CSS checkbox hack. I made a (super hacky) version of CSS-only dark mode toggle based on your JSBin (gotta love an absolute positioned bg, lol) [3]
[0] https://propjockey.github.io/css-media-vars/ [1] https://news.ycombinator.com/item?id=23865900 [2] https://twitter.com/James0x57/status/1283596399196680192/pho... [3] https://jsbin.com/xelufoyoka/1/edit

James0x57#
haha, awesome! You nailed it. It's really cool to see it being tested out in the world! Thank you for sharing!
kanobo1 reply#
That's crazy! The large lag between clicking and the UI updating is slightly annoying, but that's just me nitpicking at something other than the cool technical feat.
distrill1 reply#
yeah, i expected it to be instant to be honest, given it's just markup and there's no "thinking"
James0x573 replies#
It's 1.23MB of CSS & HTML - this is meant to be a stress test of the limits, lag is expected for the next several years of average-at-the-time computers!
Tempest1981#
I'm curious how it performs on a 10x10 or 16x16 grid
owl572 replies#
Or until someone packages your madness as a popular library and browsers are forced to optimize it.

Continue this thread — 2 replies

distrill#
yeah fair enough
jedberg1 reply#
I think I see my CPU dripping out the side of my laptop.
zootboy1 reply#
Indeed. This pegged a CPU core and locked up my browser for over a minute just opening the page.
AlfeG1 reply#
Syrange, but it works almost without lags on S10 phone.
rnestler#
Same here, page loaded pretty fast and lag is maybe 200ms on my phone using Firefox.

Load more comments