Jump to content

Circular movement in java?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
Roders1234

Roders1234

    Newbie

  • Members
  • Pip
  • 4 posts
Hey there everyone.

I'm wondering how I would show an object moving in a circle, around a fixed point in a java applet. Can anyone help me?

Thanks, Rod

#2
Arkie

Arkie

    Learning Programmer

  • Members
  • PipPipPip
  • 92 posts

Roders1234 said:

Hey there everyone.

I'm wondering how I would show an object moving in a circle, around a fixed point in a java applet. Can anyone help me?

Thanks, Rod

Well, however you are drawing your stuff on your applet just change the coordinates.

#3
Roders1234

Roders1234

    Newbie

  • Members
  • Pip
  • 4 posts

Arkie said:

Well, however you are drawing your stuff on your applet just change the coordinates.

I've thought about doing it that way but im going to have about 10 different moving objects, all with different radii and moving at different speeds.
The only logical way i can think of doing this at the moment is to store a selection of the x, y coordinates of each circle in a database and then just have java move each object 'so many' points at each interval.

Am I just being naive?

#4
Arkie

Arkie

    Learning Programmer

  • Members
  • PipPipPip
  • 92 posts
Without seeing any code im unable to tell how the architecture of your design is.

What you can do is create a method that takes one parameter as a basepoint and another one for degrees.

You should also be using threads because of the 10 different objects moving at the same time (i assume)

#5
gszauer

gszauer

    Programmer

  • Members
  • PipPipPipPip
  • 113 posts
[HIGHLIGHT="Java5"]interface CircularMovement {
public void moveCircle (Point center, int radius, int speed);
public void setCenter (Point center);
public void setRadius (int radius);
public void setSpeed (int speed);
public void serCenter (int x, int y);
}[/HIGHLIGHT]

[HIGHLIGHT="Java5"]public class YourClass implements CircularMovement {
...[/HIGHLIGHT]

Give each object a method that moves it in a circle. That way you can manipulate each object individually by calling one of its functions.

~Aristotle said:

It is the mark of an educated mind to entertain a tought without accepting it
If my post was helpful, please help me build some rep Posted Image