Live data from Hacker News

HTML5 Deck of Cards

pakastin.github.io

121–130 of 165 posts

Re: HTML5 Deck of Cards

#121
post #71

Earlier quoted context omitted.

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.

you can still run a demo off github pages without the multiplayer.

Re: HTML5 Deck of Cards

#122

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.

on my deck hacks i use proper data structures but on the initializer for the deck i have `suit = i % 4`.

which has the advantage of working with any size of deck. important since in brazillian truco you leave most of the numbers out ;)

Re: HTML5 Deck of Cards

#123

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 is actually something you can do with Tabletop Simulator on steam, as I'm using it for that exact purpose. It even uses JSON as the underlying data structure. Granted, it's proprietary and not free.

My room mate tried to use that and he said it was garbage. The thing that I remember was having to type file paths manually, but there was a bunch of other specific and egregious problems he pointed out. Beyond that though, 3D brings nothing to the table; it's just a gimmick.

Re: HTML5 Deck of Cards

#125

Earlier quoted context omitted.

Maybe instead of trashing other people's work you could just link to yours instead.

This is the real world: just because you do work doesn't mean you were working on the right thing, the right way, at the right time, for the right people, etc. Maybe pretending everything is awesome feels good now, but it won't feel good when you're in your 40s with nothing lasting to show for 20 years of professional development work. I won't be linking to my work for 2 reasons: 1. I say unpopular things with this a…

It's easy to say unpopular things with an anonymous account, but it kind of takes the weight out of them IMO. Own your opinions, I say.

Re: HTML5 Deck of Cards

#126
post #107

Earlier quoted context omitted.

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.

Actually only 52 :D But yeah, I agree about googling part: I remember having Googled "tilde javascript" and "pipe javascript".. :) Tilde is useful with indexOf: if (~array.indexOf(item)) {} ..equals to: if (array.indexOf(item) > -1) {}

This is the sort of thing that makes Perl readable in comparison to Javascript :)

Re: HTML5 Deck of Cards

#128
post #46

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.

If you're referring to |0 then I would disagree. It shows how horrible JavaScript is. This is very confusing if you're not familiar with this trick or strange behavior of the language. suit = int(i / 13) suit = (int)(i / 13) suit = math.floor(i / 13) Are much easier to understand for someone not familiar with the code.

Languages are what they are, and if you're going to use one you might as well use it idiomatically. Maybe it's just me, but I see "|0" all the time in JS, not as some kind of crazy performance hack, but used idiomatically to mean "truncate".

And on the flip side with JS's lack of number types, any code that looks like it's doing type casts (rather than math) looks out of place. If one must mess around with JS number types then all you can really do is give hints to the optimizing compiler, in which case "|0" is the standard way to hint that you want a small int.

Obviously what looks clean is a matter of opinion, but FWIW.

Re: HTML5 Deck of Cards

#130
gorgeous! really fine work. (granted i have no design talent, though i did work for an online poker shop for six years and i have played a lot of poker with friends and a lot house poker in casinos.

particularly awesome is "sort", which i think really nicely simulates a (reverse) shuffle; it seemed like i could see the top edge of the cards lift as they rotated along the bottom edge

Post reply on HN