Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So your peg is supposed to walk in a square, ei. follow the edge of the board, but instead cuts corners, am I right?</p> <p>If I am so, then the answer is very straight forward. To make sure that the peg follows the squares lain on the board, you must make it move to every square in the path from source square to destination square, otherwise it will simply cut the corner and go straight for the destination square.</p> <p>If the player rolls a 4, and is standing on square 9 and must reach square 13. Then instead of making the peg move directly to square 13, I would force the peg to go first to 10, then 11, then 12 and then at last square 13.<br> Of course if the squares are aligned in a square manor, that is; four edges, then some optimization could be done, and only split up the path if a corner is in between the source square and the destination square.<br> And of course this optimization could also be applied even though the squares are not aligned in a square like manor, just as long as it follows some path, and you know where the 'corners' are.</p> <p>Edit:<br> <img src="https://i.stack.imgur.com/lbegz.png" alt="The described three cases"><br> To try and test my paint skills and to try and visualize the problem at hand, I have created something within paint.</p> <p>What you are doing in the presented code is <strong>Case 1</strong>. You are doing a <em>single</em> animation when moving the peg. What you really want do is <strong>Case 2</strong>, here your function <code>-(void)animatePeg;</code> should recognize that the destination square is more than 1 square away, and therefore not do a <em>single</em> move animation, but a series of move animations, to be more precise, the number of animations is always <code>indexOfDestinationSquare - indexOfSourceSquare</code>. So in the illustrated case, the peg should do a total of <em>eight</em> move animations instead of only <em>one</em>. </p> <p><strong>Case 3</strong> shows how this process could be optimized by recognizing the direction of the move, and only split when going around a corner.</p> <p>I hope this clarifies what approach I would take. To do this approach you need to extend your <code>-(void)animatePeg;</code> function to be able to split up the single move into a series of moves, and then animate the moves one-by-one.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload