1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Checkers game, getting the piece i've jumped overs location!

  1. Mar 28, 2008 #1
    1. The problem statement, all variables and given/known data
    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

    2. Relevant equations

    3. 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
  2. jcsd
  3. Mar 28, 2008 #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: Mar 28, 2008
  4. Mar 28, 2008 #3
    wow... i just spent a million years thinking that was wrong :'(

    thanks anyway!!!
    Last edited: Mar 28, 2008
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook