Circling imigis

Hi,

I am making a sprite animation, i wish to make my Image @ x1,y1 to move in a circle with a defined radius.

I was thinking of using x*x+y*y =r*r, using the x1 in place of x and getting a new y and then using the new y to get the next x and so on. But it doesnt seem to be working. I think my method is wrong.

please help !

[351 byte] By [ranabpa] at [2007-9-28 5:46:36]
# 1

Use angles. If w is the angle to which the image should be moved next, (cx,cy) is the center of the circle and it has radius r, then the new coordinates for the image will be something like

x_new = cx + Math.sin(w) * r

y_new = cy + Math.cos(w) * r

You can exchange the sin and the cos, or the signs in front of them

Zyphrusa at 2007-7-9 16:57:25 > top of Java-index,Other Topics,Java Game Development...