Here, not in my inbox.
The program I'm writing moves a box from the top left to the bottom right and then back up the same way but changes colors from red to blue. I cant get the box to go up and was hoping you may know what I'm doing wrong.
Code
import java.awt.*;
public class MovingPoints extends AnimationBase
{
public void drawFrame(Graphics g)
{
int x = 10, y = 10;
int f_num;
int rx, ry;
f_num = (getFrameNumber() % 37);
if(f_num > 0)
{
rx = x + (f_num - 1) * 5;
ry = y + (f_num - 1) * 5;
}
else
{
rx = x + (36) * 5;
ry = y + (36) * 5;
}
if ( f_num < 19)
{
g.setColor(Color.white);
g.fillRect(rx,ry,5,5);
x = x + (f_num) * 5;
y = y + (f_num) * 5;
g.setColor(Color.red);
g.fillRect(x,y,5,5);
}
else
{
g.setColor(Color.white);
g.fillRect(rx,ry,5,5);
x = x + (f_num) * 5;
y = y + (f_num) * 5;
g.setColor(Color.blue);
g.fillRect(x,y,5,5);
}
} //End of drawFrame()
} //End of class MovingPoints