import java.awt.Color; import java.awt.Graphics; public class Star { public void Update(Graphics g) { g.setColor(color); int i = (int)x; g.drawLine(i, y, i + speed4, y); x += speed; if(i > maxwidth) init_star(); } private void init_star() { x = 1.0D; y = (int)(Math.random() * (double)maxheight); speed = Math.random() * (double)maxs + 1.0D; speed4 = (int)(speed * 4D); c = (int)(speed * (double)(255 / maxs)); if(c<0){ c= -c; } while(c>255){ c= (int) ((double)c/2.0); } color = new Color(c, c, c); } Star(int i, int j) { maxs = 6; maxwidth = j; maxheight = i; init_star(); } private int y; private int speed4; private double speed; private double x; private Color color; private int maxs; private int c; private int maxwidth; private int maxheight; }