Live data from Hacker News

HTML5 Deck of Cards

pakastin.github.io

91–100 of 165 posts

Re: HTML5 Deck of Cards

#91
post #42

Maybe it's a weird takeaway, but this line is really clever: var suit = i / 13 | 0; That's such a clean way to get a 0, 1, 2 or 3 from each card's `i` and I never would have thought of it.

1.89% faster than Math.Floor, 100% more hard to read.

I used http://jsperf.com/or-vs-floor/2 in Firefox 40.0.3 and it was only 0.37% faster. Was similar in Chrome.

Re: HTML5 Deck of Cards

#92
post #25

Earlier quoted context omitted.

I used HTML5 just because the original version was made with Flash back in 2006 ( http://pakastin.fi/cards_2006 ). Then I made a Angular.js version, which is lost, but was featured on Chrome Experiments. This is actually HTML5 Deck of Cards 2 :)

Anyway, great job. This the best deck of cards I've seen on the web. I'm pretty sure it won't be long before we see a Meteor app that uses this.

Thanks! I look forward to seeing what other people make out of it.. :)

Re: HTML5 Deck of Cards

#94
post #84

Earlier quoted context omitted.

Its because they don't do the same thing Math.floor() favors the number equal to/less than the parameter, Math.floor(-15.5) is -16 while (-15.5 | 0) is -15 Also because the returned value is int32[0], Math.floor(2147483648.5) is 2147483648 while (2147483648.5 | 0) is -2147483648 You are fine if you know the input is less than (2^31) + 1 and you want to truncate, rather than floor. [0]: http://www.ecma-international.o…

Hmm, pretty sure floor rounds a number downward to its nearest integer. So Math.floor(-15.5) would be 15. https://developer.mozilla.org/pt-PT/docs/Web/JavaScript/Refe...

Literally the first example on that page:

> Math.floor( 45.95); // 45

> Math.floor(-45.95); // -46

Its not like its hidden or anything... Its in the center of the page on my 1920x1080 screen.

Re: HTML5 Deck of Cards

#96
post #9

Earlier quoted context omitted.

I think "value | 0" is basically same as "Math.floor(value)"

Yes, but it is 18% faster do run the bitwise or on my machine: https://jsperf.com/or-vs-floor/2

And every time a developer sees that, they're going to google "bar javascript" "single bar javascript" "bitwise or javascript" "bitwise or javascript effect" until they figure out WTF is going on.

This all to save a fraction of a microsecond on an operation that's called 60 times on the page.

Re: HTML5 Deck of Cards

#97

Earlier quoted context omitted.

Sure but implementing the card back image is more difficult, which is what I think the parent post was getting at, rather than the flipping itself. The rest of the page is implemented without any images, which is neat; you'd have to work some SVG magic or something to create e.g. a Bicycle-esque card back without loading an image.

http://lea.verou.me/css3patterns/ could provide a pretty good source for patterned card backs.

Nice

http://lea.verou.me/css3patterns/#marrakesh

Re: HTML5 Deck of Cards

#98
post #71

This is similar to something my room mate is working on: https://github.com/thejoshwolfe/board-gamer-2d The user can create a JSON string that represents a game (checkers, solitare, dominion, smash up, etc). Then the engine creates cards, tokens, dice, etc. It does not enforce rules but it supports multi player and some rules about visibility to other players. Its intended use case is for testing out new games or exp…

This seems to be all static html, why doesn't he just turn the branch into a github page?

It is a github page, it's hosted on github.io. The branch is https://github.com/pakastin/deck-of-cards/tree/gh-pages

Re: HTML5 Deck of Cards

#99
post #71

This is similar to something my room mate is working on: https://github.com/thejoshwolfe/board-gamer-2d The user can create a JSON string that represents a game (checkers, solitare, dominion, smash up, etc). Then the engine creates cards, tokens, dice, etc. It does not enforce rules but it supports multi player and some rules about visibility to other players. Its intended use case is for testing out new games or exp…

This seems to be all static html, why doesn't he just turn the branch into a github page?

There's a node server required too, to coordinate the multiple connected clients.

Re: HTML5 Deck of Cards

#100

This is similar to something my room mate is working on: https://github.com/thejoshwolfe/board-gamer-2d The user can create a JSON string that represents a game (checkers, solitare, dominion, smash up, etc). Then the engine creates cards, tokens, dice, etc. It does not enforce rules but it supports multi player and some rules about visibility to other players. Its intended use case is for testing out new games or exp…

Had the same idea but I also have a hundred others to distract me, so thanks for the heads up. I'll keep an eye on it.
Post reply on HN