import java.awt.*;
import java.util.Random;
import java.applet.Applet;
public class SimpleGame extends Applet implements Runnable {
public int x;
public int y;
public int color;
public void init() {
setBackground(Color.black);
}
public void start() {
Thread current = new Thread(this);
current.start();
}
public void run() {
Random rand = new Random();
try {
while (true) {
color = (rand.nextInt(3) % 3);
x = rand.nextInt(300);
y = rand.nextInt(300);
Thread.sleep(300);
repaint();
}
} catch (Exception e) {}
}
public void mouseClicked(Event e, int x, int y) {}
public void paint(Graphics g) {
switch (color) {
case 0: g.setColor(Color.green); break;
case 1: g.setColor(Color.red); break;
case 2: g.setColor(Color.yellow); break;
}
g.fillOval(x,y,20,20);
}
}