Question on codemonkey's pool tutorial

ktfrightktfright Member Posts: 964
edited November -1 in Working with GS (Mac)
Nice forum! Had a question for codemonkey or whoever know the answer. In the pool table tutorial, how did you make controls for aiming and shooting the cue ball?

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    I used the position of the cue ball that I click on and the position of the mouse as points of reference.

    With those I can find the angle using the vectorToAngle function, and the power based on the magnitude with a min function to limit the power. The magnitude can also be used to determine the length of the helper tool.

    With the angle and magnitude, using sin/cos of the angle and multiple it by the magnitude, you can find the x/y position of the arrow, respectively.

    That is the short of it. I'm a bit tired right now.
  • ktfrightktfright Member Posts: 964
    Cool, but when you are in tip-top shape, can you elaborate a bit more? And thanks.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    I've started a section in http://gamesalad.com/wiki/tutorials called CodeMonkey's Tutorial Games
    All the vital stuff from the pool table game, but no explaination yet.
Sign In or Register to comment.