/*************************************************** Program: Star.java ***************************************************/ import java.awt.*; import java.applet.Applet; public class Star { private int y; private int speed4; private double speed, x; private Color color; private int maxs = 6; private int c; private int maxwidth, maxheight; Star(int height, int width) { maxwidth = width; maxheight = height; init_star(); } private void init_star() { x = 1; y = (int)(Math.random() * maxheight); speed = Math.random()*maxs + 1; speed4 = (int)(speed * 4); c = (int)(speed * (255 / maxs)); color = new Color(c,c,c); } public void Update(Graphics g) { int intx; g.setColor(color); intx = (int)x; g.drawLine(intx, y, intx+speed4, y); x += speed; if (intx > maxwidth) init_star(); } }