السلام عليكم
انا عندي كود لتحريك دائرة و اريد التقليل من سرعتها بحيث ان سرعتها كبيرة و كذلك هناك اجسام لا اريد ان اعيد رسمها ما عدا الدائرة
كلاس الدائرة
public class Circle {
public int centerX, centerY, radius;
public Color color=Color.BLUE;
public Circle(int x, int y, int r) {
centerX=x; centerY=y; radius=r;
}
public void move(int xAmount, int yAmount)
{
centerX = centerX + xAmount;
centerY = centerY + yAmount;
}
public void draw(Graphics g)
{
// Translates circle's center to rectangle's origin for drawing.
g.fillOval(centerX , centerY, radius ,radius);
}
public void move()
{
int i=0,j=0;
i++; j++;
move(i,10);
}
}كلاس التحريك
public class search extends Frame {
int a=400;
int b=a/2;
int c=a/6;
Circle cir=new Circle(150, 150, 20);
public void drawRec(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
Rectangle r = new Rectangle(125,125,a,b);
g2.draw(r);
g2.draw(new Line2D.Double((a/6.0+125),125,(a/6+125),b+125));
g2.draw(new Line2D.Double((2*a/6.0+125),125,(2*a/6+125),b+125));
g2.draw(new Line2D.Double((3*a/6.0+125),125,(3*a/6+125),b+125));
g2.draw(new Line2D.Double((4*a/6.0+125),125,(4*a/6+125),b+125));
g2.draw(new Line2D.Double((5*a/6.0+125),125,(5*a/6+125),b+125));
g2.draw(new Line2D.Double(125,b/3+125,a+125,b/3+125));
g2.draw(new Line2D.Double(125,2*b/3+125,a+125,2*b/3+125));
}
public void paint(Graphics g)
{
drawRec(g);
g.setColor(Color.blue);
cir.draw(g);
up(1);
}
public void foward(int amountX)
{
cir.centerX=(cir.centerX + amountX);
repaint();
}
public void back(int x)
{
cir.centerX=(cir.centerX -x);
repaint();
}
public void up(int y)
{
cir.centerY= (cir.centerY -y);
repaint();
}
public void down(int y)
{
cir.centerY= (cir.centerY +y);
repaint();
}
}ماذا افعل حتى لا اعيد رسم drawRec() في كل مرة اعيد رسم الدائرة ؟؟
ارجو المساعدة
