Your player is at x2, y2. You jump right and land at x4, y2 |
|
|
rej3kt wrote: |
---|
I'm basically creating a game, peg solitaire, where the board is a sort of cross and you jump over pegs to eliminate them. I've got my grid sorted with a 2d array (o's for pegs and . for blank space). I've got a function which draws the grid, and I ask the user to input two numbers to represent co-ordinates of the array, saved as "selection1 and selection2", then I ask the user to input the direction they want to move their peg, N,E,S,W. My problem is, I can't quite figure out how to tell the program to eliminate the peg that is jumped over, for example peg 3,4 moving west would jump over another peg and into the centre of the board. What would be the easiest way of doing this, I was thinking a switch statement for N,E,S,W and some statement saying something like for north: row - 2 or column -2 for the array, not entirely sure how to change the value (row + column are the names of the two parts to the array). Thanks for any help, I know it sounds confusing. |