View Full Version : Move an texture object around a circle

02-01-2004, 04:15 AM
Hi i am trying to make a texture follow the x and y coordinates of a circle, i.e. the object moves around all drawn points of the circle.

firstly my circle object.public void DrawCircle(){
double radius;
radius = 1.5;

for(double a= 0 ; a <(2 * Math.PI) ; a+=(Math.PI/180))
double x = Math.sin(a) * radius;
double y = Math.cos(a) * radius;

The texture has X and Y, such as

shipPosX = 8.0f //ship is out of screen
shipPosY = 0.0f

I need the ship to move into the screen from the right which i do by, decrementing the X coordinate by 0.02 until it reaches say 5.0 (which then the ship is visible) then it finds the circle and moves around it facing the same way until it is destroyed by the user.

I have a move ship method for now which just decrements the ship all the way to the left of the screen, then regenerates it from the right again. Is it possible to make the ship move around the circle and if so if any one has any views i would be very grateful.

i can translate and scale the object to the required position but where in which method do i make the ship acknowledge the circles points in order for it to follow them.

02-01-2004, 11:52 AM
Hi !

I am not sure if I got it right, but it all sounds very 2D to me, and in that case can't you just use the coordinates you calculate in the loop as translation values for the ship ? you will of course still have the problem getting the ship facing the right direction, but if you use a vector from the center of the circle to the coordinate you can calculate the normal 90 degree from that.