Skip to main content

Rotation and direction

3 replies [Last post]
kram
Offline
Joined: 2007-10-23
Points: 0

Im trying to make a triangle move around the screen, which I can do fine, but I would like the top point of my isosceles triangle to rotate when the user presses the right or left keys (which I know I can use the rotate property) and then make the point of the triangle (which has now been rotated slightly) be the direction that the triangle moves when pressing the up key.

I think Im talking about a relative coordinate system which is relative to the triangle that I need to use, but Im not sure, can anyone help me out with this?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexsch
Offline
Joined: 2007-07-12
Points: 0

Could you post a code snippet with the rotated triangle and point out the thing that does not work?

kram
Offline
Joined: 2007-10-23
Points: 0

Well i have been doing a lot of research and it really turns out that the question Im asking about has nothing to do with JavaFX specifically. More of the maths and theory behind the physics of movement.

I have got the triangle somewhat moving and its just a matter of tweaking it from now on I think.

Thanks for the help though, Im making a sort of asteroids game, so be sure that I'll be posting some more questions as I go along!

alexsch
Offline
Joined: 2007-07-12
Points: 0

The standard way is using linear transformations like rotation matrix:
http://mathworld.wolfram.com/RotationMatrix.html