JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
snap to grid so edges line up
authorJason Woofenden <jason@jasonwoof.com>
Tue, 1 Nov 2011 03:06:33 +0000 (23:06 -0400)
committerJason Woofenden <jason@jasonwoof.com>
Tue, 1 Nov 2011 03:06:47 +0000 (23:06 -0400)
This is important now that mouse hover makes the card come to the foreground,
because it's frustrating when you're pile isn't perfect, and as you go to hover
over the front card you hover over one pixel of a lower card, and then it
obscures the card you were aiming for.

client.coffee
server.coffee

index 255d455..99a70a7 100644 (file)
@@ -61,11 +61,10 @@ instantiate_card = (card) ->
        if card.flipped
                view.addClass 'flipped'
        $table.append view
-       view.draggable containment: '#table'
+       view.draggable containment: '#table', grid: [20, 20]
        view.bind 'dragstart', (event, ui) ->
                view.css 'z-index': card.z = next_card_z()
        view.bind 'dragstop', (event, ui) ->
-               #view.css 'z-index': card.z
                p = view.position()
                state.move state.agent, card.number, transform_x(p.left), transform_y(p.top)
        card.view = view
index 94672a9..46d48c5 100644 (file)
@@ -185,14 +185,14 @@ test_init = ->
        timeout 4000, ->
                test_game.set_cards 'server', [
                        { text: "Wildabeast 2/2", x: 220, y: 200, owner: 'p2'}
-                       { text: "Wild beast 2/2", x: 350, y: 200, owner: 'p2'}
+                       { text: "Wild beast 2/2", x: 360, y: 200, owner: 'p2'}
                        { text: "Angora bunny 1/1", x: 500, y: 200, owner: 'p2'}
-                       { text: "Ambulatory Cactus 2/1", x: 650, y: 200, owner: 'p2'}
+                       { text: "Ambulatory Cactus 2/1", x: 660, y: 200, owner: 'p2'}
                        { text: "Ent 0/5", x: 800, y: 200, owner: 'p2'}
                        { text: "Carnivore 2/1", x: 220, y: 420, owner: 'p1'}
-                       { text: "Herbivore 1/2", x: 350, y: 420, owner: 'p1'}
+                       { text: "Herbivore 1/2", x: 360, y: 420, owner: 'p1'}
                        { text: "Stone Wall 0/10", x: 500, y: 420, owner: 'p1'}
-                       { text: "Log 0/1", x: 650, y: 420, owner: 'p1'}
+                       { text: "Log 0/1", x: 660, y: 420, owner: 'p1'}
                        { text: "Ent 0/5", x: 800, y: 420, owner: 'p1'}
                ]