# Need help with a card swapping game

**URL:** <https://forum.kirupa.com/t/need-help-with-a-card-swapping-game/298835>\
**Category:** programming\
**Created:** [October 26, 2009, 7:45am UTC](https://forum.kirupa.com/t/need-help-with-a-card-swapping-game/298835 "2009-10-26T07:45:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![adBuryD](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@adBuryD](https://forum.kirupa.com/u/adBuryD)\
**Post date:** [October 26, 2009, 7:45am UTC](https://forum.kirupa.com/t/need-help-with-a-card-swapping-game/298835/1 "2009-10-26T07:45:31Z")

</div>

hi friends,  
Eventhough this is gonna be a pain for a lot of you, i am posting my dilemma anyways.  
I have made a game where four cards are in a row along three columns.

```
    basic idea is to arrange in order the cards i have placed the cards in an array as below

```

[[\_lvl0.c0\_0,\_lvl0.c0\_1,\_lvl0.[COLOR=black]c0\_2[/COLOR],\_lvl0.c0\_3], [\_lvl0.c1\_0,\_lvl0.c1\_1,\_lvl0.c1\_2,\_lvl0.c1\_3], [\_lvl0.c2\_0,\_lvl0.c2\_1,\_lvl0.c2\_2,\_lvl0.c2\_3]]

If I move card [0][0] to [1][2] then the array wud look like

[0\_1[COLOR=DarkRed],[/COLOR]0\_2[COLOR=DarkRed],[/COLOR]0\_3[COLOR=DarkRed],[/COLOR][COLOR=Blue]1\_0[/COLOR]], [1\_1[COLOR=DarkRed],[/COLOR]1\_2[COLOR=DarkRed],[/COLOR][COLOR=Blue]0\_0[/COLOR][COLOR=DarkRed],[/COLOR]1\_3], [2\_0[COLOR=DarkRed],[/COLOR]2\_1[COLOR=DarkRed],[/COLOR]2\_2[COLOR=DarkRed],[/COLOR]2\_3]

lly [2][0] to [0][2] the array wud look like

[0\_1[COLOR=DarkRed],[/COLOR]0\_2[COLOR=DarkRed],[/COLOR][COLOR=Blue]2\_0[/COLOR][COLOR=DarkRed],[/COLOR]0\_3], [[COLOR=Blue]1\_0,[/COLOR]1\_1[COLOR=DarkRed],[/COLOR]1\_2[COLOR=DarkRed],[/COLOR][COLOR=Blue]0\_0[/COLOR][COLOR=DarkRed],[/COLOR]], [[COLOR=Blue]1\_3[/COLOR][COLOR=DarkRed],[/COLOR]2\_1[COLOR=DarkRed],[/COLOR]2\_2[COLOR=DarkRed],[/COLOR]2\_3]

I got it all working the array shuffling and all but one problem persists unable to solve it  
For ex:  
Drag card number [0][1] to [1][2] … all the cards shift their positions ….  
Now try dragging [0][2] over [0][3] … The card don’t shift  
Click on reset  
[COLOR=#ff6600]Do the same thing as above again[/COLOR]  
[COLOR=#ff6600]But before the second step click on the card [0][3][/COLOR]  
[COLOR=#ff6600]The do the second step[/COLOR]

Same way  
Drag card no [0][0] directly to [2][0] last coloum in a straight horizont line  
Now try drgging [0][0] over [1][0] noting happens  
Click on reset  
[COLOR=#ff6600]Do the same thing as above again[/COLOR]  
[COLOR=#ff6600]But before the second step click on the card [2][0][/COLOR]  
[COLOR=#ff6600]The do the second step[/COLOR]

```
  The idea is to first shuffle the cards in the dynamic array then place the cards onstage accordingly&#8230; then assign rowId and colId to these cards previously it was set in the &#8220;storevalues&#8221; function but the ids don&#8217;t get assigned to the 

```

cards on stage cards on mousemove… it gets assigned later when you click on the card  
this happens only on **across column shuffle so same row shuffle works fine .**

\*\*since i have already posted this query in another section i am not able to attach the file  
\*\*  
\*\*Please find it here  
\*\*

> **[Need help with fixing a bug in my code that swaps cards onmousemove](https://www.kirupa.com/forum/showthread.php?t=337381)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

  
\*\*Would appreciate any help you can provide  
\*\*  
\*\*Thanks in advance… \*\*
