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.
HTML5 Deck of Cards
91–100 of 165 posts
Re: HTML5 Deck of Cards
#92Earlier 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.
Re: HTML5 Deck of Cards
#93What? No 52 pick up? ;-)
Re: HTML5 Deck of Cards
#94Earlier 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...
> 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
#95Re: HTML5 Deck of Cards
#96Earlier 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
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
#97Earlier 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.
Re: HTML5 Deck of Cards
#98This 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?
Re: HTML5 Deck of Cards
#99This 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?
Re: HTML5 Deck of Cards
#100This 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…