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
Circular movement in java?
Started by Roders1234, Feb 25 2008 11:17 AM
4 replies to this topic
#1
Posted 25 February 2008 - 11:17 AM
|
|
|
#2
Posted 25 February 2008 - 11:26 AM
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
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
Posted 25 February 2008 - 11:46 AM
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
Posted 25 February 2008 - 01:42 PM
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)
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
Posted 25 February 2008 - 02:34 PM
[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.
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


Sign In
Create Account

Back to top









