//
import java.awt.*;
public class Fred extends BufferedApplet
{
int width = 0, height = 0;
Color shapeColor = Color.red;
public void render(Graphics g) {
double time = System.currentTimeMillis() / 1000.0;
if (width == 0) {
width = bounds().width;
height = bounds().height;
}
g.setColor(Color.white);
g.fillRect(0, 0, width, height);
int x = (int)(width/2 + width/4 * Math.sin(0.2 * Math.PI * time));
int y = (int)(height/2 + width/4 * Math.sin(0.4 * Math.PI * time));
drawMyShape(g, x, y, 0.5 + 0.5 * Math.sin(5 * time));
animating = true;
}
void drawMyShape(Graphics g, int x, int y, double openEyes) {
g.setColor(shapeColor);
g.fillOval(x - 50, y - 50, 100, 100);
g.setColor(Color.white);
int dy = (int)(openEyes * 10);
g.fillOval(x - 20, y - 20-dy, 15, 2*dy);
g.fillOval(x + 5, y - 20-dy, 15, 2*dy);
g.setColor(Color.black);
g.drawOval(x - 20, y - 20-dy, 15, 2*dy);
g.drawOval(x + 5, y - 20-dy, 15, 2*dy);
g.drawLine(x - 20, y + 20, x + 20, y + 20);
}
public boolean mouseUp(Event e, int x, int y) {
shapeColor = Color.blue;
System.err.println("hi mom!");
damage = true;
return true;
}
}