top | item 47111981

Show HN: 3D Mahjong, Built in CSS

137 points| rofko | 7 days ago |voxjong.com

60 comments

order

codingdave|7 days ago

It is a nice UX, but with a fatal flaw: Tiles are supposed to be free when there is a side free, but you instead have it coded to be free when the top or bottom is free. Your app, your rules, so if you intended to do that, cool. It is just a fundamental divergence from how other implementations do it.

jasperry|7 days ago

If you rotate it so the board looks like the traditional solitaire layout, the direction of free tiles is horizontal as it's supposed to be. But then the images on the tiles are rotated 90 degrees. Either way you look at it, something is non-standard.

The other thing is that this implementation doesn't seem to support overlapping tiles, which is kind of important. For instance, the topmost tile should overlap and block all four tiles under it.

rpdillon|7 days ago

Thanks for mentioning this. I played a little bit and I felt like it was the opposite of what I'd remembered. I do like that the inaccessible tiles are faded somewhat so that I don't inadvertently try to match them.

rofko|7 days ago

Thank you for the feedback! I will triple check the rules

rdescartes|7 days ago

Should it be named Shanghai solitaire Or Mahjong Solitaire ?

gchamonlive|7 days ago

Maybe Mahjunk, am I right?

slowly lowers right hand in awkward silence

alexpotato|7 days ago

Coding + Mahjong related story:

Back in college, while majoring in CS, I had a rough time dealing with semicolons, typos, missed characters while coding.

I thought to myself "I wonder if playing Mahjong in the Windows games would help me get better at scanning code and finding these types of errors". So I tried it and, lo and behold, it did.

Also, in this day and age of LLMs writing a lot of the code, scanning for missing semicolons in code sounds like "I was great at fixing telegraphs!"

sanj|7 days ago

This is lovely! Can I suggest make sure that the board is solveable?

uean|7 days ago

This is part of the game. Many games will not be solvable.

Bender|7 days ago

I think this is a good example of what CSS can do and probably was not easy to make but I will likely stick with Mahjong that comes with most Linux distributions as they follow rules that people I may end up playing against would know and they have many layouts. I could see this being applied to other things however such as games that require building or repairing something. Or something similar to Minecraft?

Impressive work!

koolala|7 days ago

I wonder if versus Mahjong Solitaire could be like Battle Tetris. I've never heard of people playing it competitively.

haunter|7 days ago

Now make it _real_ mahjong (; https://en.wikipedia.org/wiki/Mahjong

Which makes me wonder which ruleset would be the easiest to implement. Probably MCR or HK, riichi has too many edge cases and sepcial rules and yakus.

snvzz|7 days ago

Riichi is the fun one, where skill weights over luck.

akersten|7 days ago

If I click fast enough on mobile it starts trying to select/highlight text, should be able to prevent that with CSS too. I find this is somehow a common issue that separates a lot of PWAs from real apps, the browser text engine is still lurking there in the background trying to recall us all to the glory days of hypermedia

rofko|7 days ago

Thanks for the feedback! Just pushed that fix.

thenthenthen|7 days ago

There are some super weird bugs, sometimes only one of the two pieces are removed and sometimes the field goes blank? Also on every move the faves change?! iOS here. And yeah, no majiang, but still super cool! Nostalgic vibes waiting for my fries and playing the Photo Play touch screen gambling machine (after unlocking it by tapping the words photo and play on the logo with two different fingers and entering the code)

aranw|7 days ago

Really enjoyed that although my final two tiles were stacked and couldn't finish the game!

rofko|7 days ago

That's unfortunate! I'll make sure to patch that case.

Minor49er|7 days ago

This is pretty cool. I like the look and the gameplay. Though playing on mobile, some of the roatation gestures caused the page to refesh on me a couple of times since they triggered the browser's "drag down to refresh" interaction

rofko|7 days ago

Thanks for the report! I added a patch that hopefully fixes that.

DuncanCoffee|7 days ago

Nice! Wish the supported rotation was bigger, maybe +- 90 instead of only 90 deg?

omoikane|7 days ago

Maybe it was done this way so that they don't have to sort the tiles by depth?

snvzz|7 days ago

This ain't mahjong.

Instead, it is some solitaire using mahjong pieces.

koolala|7 days ago

Is mahjong using solitare pieces Rummy?

HardwareLust|7 days ago

Very nice! Worked great on my shitty old Motorola phone.

koolala|7 days ago

I wish you could rotate all the way. On a phone its also easy to do the refresh gesture.

TazeTSchnitzel|7 days ago

Is the lack of a perspective projection option deliberate? CSS can do that too.

tejonutella|7 days ago

Looks cool! Wish I knew how to play Mahjong tho

lieblingautor|6 days ago

i'm confused how to play it but it's pretty amazing this was done with css cool stuff man

soni96pl|7 days ago

Beautiful work, thank you for showing it

user3939382|7 days ago

Some people say “mar” jong it’s the weirdest thing.

thenthenthen|7 days ago

Sounds like dongbeinese (or erhua) haha, ‘marjang’

jsmo|7 days ago

Nice!

alexb_|7 days ago

Disappointed to see that this is solitaire and not Riichi :( would love to see more implementations of actual mahjong

apresmoi|7 days ago

wtf kind of magic is that? I looked at the repo and... you've built a 3d CSS rendering engine to create this?

pverheggen|7 days ago

There's some CSS properties specifically for doing 3D, yeah. You use perspective and perspective-origin to create the view frustum, and then CSS transforms to place your elements in 3D space.

overflyer|7 days ago

This has bothing to do with how Mahjong is actually played.

koolala|7 days ago

Isn't normal Mahjong 2D? 3D is a different game.