Tic tac toe logic?

SkyMapleSkyMaple Member Posts: 817
edited November -1 in Working with GS (Mac)
How can I set up the logic for calculating the position of the shapes in tic tac toe to find which shape has "three in a row"?

Comments

  • RedlerTechRedlerTech Member Posts: 1,583
    you could line the Xs & Os up in snap to grid (have 5 X actors & 5 Os) then when X1 position Y = X2 Position Y = X3 Position Y you have 3 in a row. Same with X. Does anyone have the math for diagonal?
  • RedlerTechRedlerTech Member Posts: 1,583
    0.o wow that sucks :( Skymaple & I really need this equation to do a mini game for someone
  • RedlerTechRedlerTech Member Posts: 1,583
    The screen will be divided downward and sideways 3 pieces. 3x3. Does anyone have the math to see if one actor is exactly up 1/3 the scene & right 1/3 the scene? O wait would that just be it? If actor position X is X1.PositionX + (1/3*Screen Size Width). Would it be like that?
  • ApplaudAppsApplaudApps Member Posts: 308
    Maybe not the simplest way but couldn't you have nine integer attributes called space1, space2 ... space9. Set them to 1 when X positioned in the space or to 2 when 0 positioned.

    Then after every move check with a set of rules

    If space1=1 & space2=1 & space3=1 then X has a row (horizontal)
    If space1=1 & space4=1 & space7=1 then X has a row (vertical)
    If space1=1 & space5=1 & space9=1 then X has a row (diagonal)

    and do every permutation and same rules for the noughts.
    If space1=2 & space2=2 & space3=2 then 0 has a row (horizontal)

    Might be long way round but will work no?
  • ApplaudAppsApplaudApps Member Posts: 308
    NextGenEntertainment said:
    The screen will be divided downward and sideways 3 pieces. 3x3. Does anyone have the math to see if one actor is exactly up 1/3 the scene & right 1/3 the scene? O wait would that just be it? If actor position X is X1.PositionX + (1/3*Screen Size Width). Would it be like that?

    Oh, you mean the actual positioning. Why not snap the pieces into the closest one of the nine positions? You could use invisible actors as the hotspots and use magnitude to work out how close when touch released
  • RedlerTechRedlerTech Member Posts: 1,583
    Actually I like that :)

    Thank You :)

    _________________________________________________________________________________
    GameSalad Community Project
    Quality Game Making Service
    1 On 1 Project Help
  • RedlerTechRedlerTech Member Posts: 1,583
    ApplaudApps said:
    Oh, you mean the actual positioning. Why not snap the pieces into the closest one of the nine positions?

    Well everything will be in the exact center of each square so i thought we could do it that way
Sign In or Register to comment.