# Making a pawn move correctly according to dice roll

**URL:** <https://forum.kirupa.com/t/making-a-pawn-move-correctly-according-to-dice-roll/265891>\
**Category:** flash\
**Created:** [July 14, 2008, 11:17am UTC](https://forum.kirupa.com/t/making-a-pawn-move-correctly-according-to-dice-roll/265891 "2008-07-14T11:17:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![avukovi4](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@avukovi4](https://forum.kirupa.com/u/avukovi4)\
**Post date:** [July 14, 2008, 11:17am UTC](https://forum.kirupa.com/t/making-a-pawn-move-correctly-according-to-dice-roll/265891/1 "2008-07-14T11:17:25Z")

</div>

I’m trying to reach out the solution for the deadlock in my code for days and I’m really becoming, let’s say _slightly_, mad!

I’m trying to create a board game with a dice. I have a pawn which is supposed to move through the fields on the board according to the number on the dice, after it was rolled. The board has rectangle shape.

I’ve created a function **rollDice()** which is controlling dice rolling and the movement of the pawn. The dice itself is event handler.  
The board itself is within movie clip **“map\_mc”** in which I’ve created a separated mc, called “node” + the number of the field, for each board field.  
So, there are “node0” to “node37” inside “map\_mc”, as there are 37 fields on the board. The pawn “tiger\_mc” is also inside the parent “map\_mc”.

**The problem is next:**  
I somehow can’t achieve that the pawn move from the current field to the next (according to the dice number) **step by step**. The movement is too quick and the pawn **“is cutting”** the corner of the board.

**Explanation of the code:**  
The whole code for dice rolling and pawn movement is inside rollDice() function which is called by pressing the dice itself. It tracks both current position of the pawn (var curr\_position) and it’s next position (var next\_position). It also push index of all fields in between into array fields\_arr. I’ve created a counter inside that function which goes through fields\_arr elements and changes the pawn’s \_x and \_y accordingly, up to the last field - the new position. But **the pawn is moving as directly from the current to the new position** (not gradually over the fields in between). So the effect of such movement is that the pawn **“is cutting the corner of the board”**. For instance, if the current position is “node7” (which is on the one side of the rectangle/board) and the next position is “node12” (which is on the next side of the rectangle/board), the pawn is not moving gradually node8-node9-…-node12 but as directly from node7 to node12, not by the corner of the board but cutting that corner!

---

<div class="post-metadata">

**Author:** ![cooldude88](https://avatars.discourse-cdn.com/v4/letter/c/e0b2c6/32.png) [@cooldude88](https://forum.kirupa.com/u/cooldude88)\
**Post date:** [July 15, 2008, 5:58am UTC](https://forum.kirupa.com/t/making-a-pawn-move-correctly-according-to-dice-roll/265891/2 "2008-07-15T05:58:30Z")

</div>

well personally i havnt had much work in this area but a way i found that works start with psuedo code just words that make everything fit together but arent actual commands then slowly replicate this code into actual syntax approved code. I realize this isnt a terrible amount of help and i know where your coming from but this just isnt my area of expertise. maybe it will help. sorry if it doesnt.
