import browser.Applet;
import awt.Color;
import awt.Image;
import awt.Font;
import awt.Graphics;
import java.lang.*;
import java.util.Enumeration;
import java.util.Vector;
class ColorItem extends Object {
String key;
Color value;
ColorItem() {}
ColorItem(String _key, Color _value) {
key = _key;
value = _value;
}
}
class k extends Applet {
ColorItem box_color;
ColorItem letter_color_item;
Vector colv = new Vector();
Enumeration colors;
int bs = 150;
int i;
int letter_color;
int draw_pic;
int Ax,Ay;
int cx,cy;
int ocx,ocy;
int cw,ch;
boolean down;
boolean need_push;
int bx1,bx2,by1,by2;
int n_word;
int p_word;
int word;
int w_index;
String c;
String s[];
Font wordFont;
Image pictureImages[];
public void init() {
colv.addElement(new ColorItem("green",Color.green));
colv.addElement(new ColorItem("magenta",Color.magenta));
colv.addElement(new ColorItem("cyan",Color.cyan));
colors = colv.elements();
wordFont = getFont("Dialog", Font.BOLD,24);
Ax = 600;
Ay = 400;
resize(Ax,Ay);
cx = 300;
ocx = 300;
cy = 300;
ocy = 300;
ch = 24;
cw = 24;
down = false;
n_word = 3;
word = 0;
p_word = 0;
s = new String[n_word];
s[0] = "CALVIN";
s[1] = "CRAB";
s[2] = "DUCK";
bx1 = 50;
bx2 = 50;
by1 = 50;
by2 = 50;
w_index = 0;
need_push = false;
pictureImages = new Image[3];
for (i=0; i <3; i++)
pictureImages[i] = getImage("http://web.syr.edu/~furm/backup/ZZ/images/my-prog/b"+ i + ".gif");
}
public void paint(Graphics g) {
g.setFont(wordFont);
if (!need_push) p_word = word;
g.setForeground(Color.menuFore);
g.fillRect(0, 0, width, height);
/* g.paint3DRect(0,0,Ax,Ay,false,true); */
for (i=0;i= (cx + cw))) return;
if ((y < cy) || (y >= (cy + ch))) return;
down = true;
cx = x;
cy = y;
repaint();
}
public void mouseDrag(int x, int y) {
if (need_push) return;
if (!down) return;
cx = x;
cy = y;
repaint();
}
public void mouseUp(int x, int y) {
if (need_push) {
need_push = false;
repaint();
return;
}
if (!down) return;
for (i=0; ((y > ((200-bs)/2)+bs) || (y < (200-bs)/2) ||
(x > ((200-bs)/2)+bs+200*i) || (x < (200-bs)/2+200*i)) && (i != 3) ;i++);
if ((i < 3) && (letter_color == i)) {
letter_color = ((int)(Math.random()*1000.0) % 3);
w_index++;
if (w_index+1 > s[word].length()) {
w_index = 0;
word++;
if (word+1 > n_word) word = 0;
need_push = true;
draw_pic = 1;
}
cx = ocx;
cy = ocy;
}
else {
cx = x;
cy = y;
}
down = false;
repaint();
}
}