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.
HTML5 Deck of Cards
121–130 of 165 posts
Re: HTML5 Deck of Cards
#122Maybe 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.
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
#123This 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.
Re: HTML5 Deck of Cards
#124Re: HTML5 Deck of Cards
#125Earlier 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…
Re: HTML5 Deck of Cards
#126Earlier 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) {}
Re: HTML5 Deck of Cards
#127My own CSS playing cards with proper card faces from 3 years ago is here:
Re: HTML5 Deck of Cards
#128Maybe 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.
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
#129Re: HTML5 Deck of Cards
#130particularly 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