Live data from Hacker News

HTML5 Deck of Cards

pakastin.github.io

61–70 of 165 posts

Re: HTML5 Deck of Cards

#61

Meh, it's all shiny and no functionality: I can't play any games or hook this up to anything. And it's not even that shiny: it would be quite difficult in casual play to differentiate cards at a glance: there are no faces on face cards, etc. I implemented the same functionality (minus drag/drop, which isn't actually useful) a few times myself when I was working on poker bots.

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 account and value my anonymity. 2. It's completely irrelevant. Posting my work would neither prove that I'm justified in what I said nor disprove what you say.

But hey: https://www.youtube.com/watch?v=gSjLiQxEZlM

Re: HTML5 Deck of Cards

#62
post #59

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.

Why not just i % 4?

that would alternate the suit for each card, and all the aces would be the same suit, etc.

Re: HTML5 Deck of Cards

#63
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 expansions before printing them.

It's a little bit early in the project though, so you'd have to run it from source if you want a demo.

Re: HTML5 Deck of Cards

#64

Meh, it's all shiny and no functionality: I can't play any games or hook this up to anything. And it's not even that shiny: it would be quite difficult in casual play to differentiate cards at a glance: there are no faces on face cards, etc. I implemented the same functionality (minus drag/drop, which isn't actually useful) a few times myself when I was working on poker bots.

something to hook it up with : http://deckofcardsapi.com/

Okay, but that doesn't address that it still doesn't have faces on face cards, different numbers of suit icons on each card, etc. There are off-the-shelf stock photo sets that make it easier to tell the difference between the cards.

Re: HTML5 Deck of Cards

#67

Each of these cards could probably be made with one element and some CSS3 pseudo-element selectors, as opposed to the four elements (wrapper element and three child elements) that are currently used per card. Additionally, with three elements (possible just one if you're crazily good at CSS), it'd be possible to have flippable cards. Still just using CSS3. Edit: Can someone explain these downvotes for me?

Browsers implement pseudo elements using actual elements internally, there's no difference in power from using ::before or just putting a as a child. Pseudo elements will probably be a little bit slower though.

Re: HTML5 Deck of Cards

#68

There's one card face missing. That's the back! A nice card back might be a more difficult challenge to do in HTML5.

I had the same thought. You could practice magic tricks if you could flip over the deck and then shuffle and fan it! "Pick a card, any card!"

Re: HTML5 Deck of Cards

#70
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.

suit = Integer(i / 13) suit = Math.floor(i / 13)
Post reply on HN