- Oct 31, 2006
- 52
- 0
- 66
Hi guys, I have a question for any of you java experts. I'm writing a small application program for Computer Science 2 that basically has two ellipses on it and has a gif picture that is supposed to circle around within the boundaries of these two ellipses. it does this by repainting the gif in new x and y coordinates each time to animate. It is a modification of a program that made the smiley face ("happyFace.gif") move back and forth on the screen triggered by a timer. and reversed direction when it got to a wall (multiplied moveX and moveY by -1). The teacher has hinted that an ellipse in a standard cartesian system with long axis a and short axis b and the origin in the middle has an x coordinates on this ellipse of x = a cos(angle) and a y coordinates of
y=b sin(angle). I've managed to draw the ellipses but I can't get the gif figure to move in the elliptical pattern.
I've spent literally ten hours on this one, anybody got any suggestions?
Here is the main class followed by the class that creates the program panel.
The last if statement of the panel doesn't do the correct thing, but the panel displays the two ellipses OK.
Code attached
y=b sin(angle). I've managed to draw the ellipses but I can't get the gif figure to move in the elliptical pattern.
I've spent literally ten hours on this one, anybody got any suggestions?
Here is the main class followed by the class that creates the program panel.
The last if statement of the panel doesn't do the correct thing, but the panel displays the two ellipses OK.
Code attached