Checkers game, getting the piece i've jumped overs location

  • Thread starter Dave2041
  • Start date
  • Tags
    Game
In summary, the conversation discusses how to calculate the square that was jumped over in a game of checkers using start and end square locations. The formula provided is sx+distx/2 for the x value and sy+disty/2 for the y value. The person asking for help was struggling with negative numbers when jumping upwards, but it turns out the formula was correct all along and they had just been using the wrong positions.
  • #1
Dave2041
2
0

Homework Statement


in checkers you jump over the enemys piece and land on a square after that.
i'm making this game in c++ using sdl~

i just want to know how to get the square i have jumped over using the end square and start square locations


Homework Equations





The Attempt at a Solution


where sx, sy = start x,y and ex, ey and the end position x,y

disty = ey - sy;
distx = ex - sx;

sx+distx/2 - should be the x val of the square i jumped over

sy+disty/2 - should be the y val of the square i jumped over


is this correct? i tryed it on paper and it seems to work one way but not another, jumping upwards for example gives me a negative number for example, any ideas appreciated :(

should be simple, perhaps i have been looking at this for too long lol.
thanks in advance
 
Physics news on Phys.org
  • #2
I don't get what you mean by "upwards". Your formula should work regardless. Maybe you failed to give your positions values that mean enough to you, i.e. one corner's square is (0,0) and the opposite corner is (8,8).
 
Last edited:
  • #3
wow... i just spent a million years thinking that was wrong :'(

thanks anyway!
 
Last edited:

1. Where does the piece I've jumped over end up on the board?

The piece that is jumped over in a game of checkers is removed from the board and placed to the side of the board. It is not returned to the board during the game.

2. Can I jump over my own pieces in checkers?

No, in checkers you are only allowed to jump over your opponent's pieces. You cannot jump over your own pieces.

3. If I have multiple jumps available, do I have to take all of them?

In most variations of checkers, you are required to take all available jumps. This is known as the "mandatory capture" rule. However, there are some variations of the game where this rule is not enforced.

4. Can a piece move backwards in checkers?

In traditional checkers, a piece can only move diagonally forward. However, in some variations of the game, there are special rules that allow pieces to move backwards or in other directions.

5. What happens if I have no legal moves left in checkers?

If a player has no legal moves left, the game is considered a draw or a tie. This is known as a "stalemate". In some variations of the game, the player with no legal moves may also be declared the loser.

Similar threads

  • Precalculus Mathematics Homework Help
Replies
1
Views
780
Replies
5
Views
1K
  • Introductory Physics Homework Help
Replies
5
Views
2K
  • Programming and Computer Science
Replies
12
Views
3K
Replies
6
Views
1K
  • Introductory Physics Homework Help
Replies
2
Views
16K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
6K
  • General Math
Replies
2
Views
964
  • Math Proof Training and Practice
3
Replies
83
Views
17K
Replies
5
Views
2K
Back
Top