Imagine you have a circle, which would vary in size ... how do you animate a sprite on the edge of a circle, even if the circle changes size realtime??
Animating object on a circle
BlitzPlus Forums/BlitzPlus Beginners Area/Animating object on a circle The formula for converting polar coordinates to cartesian is:
X = Radius * Cos(Angle)
Y = Radius * Sin(Angle)
So, if I want to place a circle centered at 320, 240, and place a sprite at angle 0, which is the right side of the circle, then I would go:
SpriteAngle# = 0
SpriteXOff# = CircleRadius# * Cos(SpriteAngle#)
SpriteYOff# = CircleRadius# * Sin(SpriteAngle#)
SpriteX# = 320.0 + SpriteXOff#
SpriteY# = 240.0 + SpriteYOff#
Note that 90 is the top of the circle, and that SpriteXOff# and SpriteYOff# will be negative at times, because the polar coordinate equation produces a circle centered at 0,0 in cartesian space.
X = Radius * Cos(Angle)
Y = Radius * Sin(Angle)
So, if I want to place a circle centered at 320, 240, and place a sprite at angle 0, which is the right side of the circle, then I would go:
SpriteAngle# = 0
SpriteXOff# = CircleRadius# * Cos(SpriteAngle#)
SpriteYOff# = CircleRadius# * Sin(SpriteAngle#)
SpriteX# = 320.0 + SpriteXOff#
SpriteY# = 240.0 + SpriteYOff#
Note that 90 is the top of the circle, and that SpriteXOff# and SpriteYOff# will be negative at times, because the polar coordinate equation produces a circle centered at 0,0 in cartesian space.