/*My intention when I wrote this program was to make all the variables dependent and proportional. To do this a reference had to be determined. For this I used the head. All X/Y coordinats use the X/Y initialization point for the head. In addition, all values should be proportional to the head. So in theory the entire skeleton can be animated and moved. There are instances where I used constants in- stead of Variables. If the sizes were to be changed these values should be looked at.**/ import java.awt.*; import java.applet.*; import java.util.*; /* */ public class Man extends Applet { int xhead,yhead,whead,hhead,xref,yref; /*Global to head*/ int x_eye1,x_eye2,y_eyes,h_eye,w_eye,cnt=0,cnt2=1; public void init() { /*Set the default colors*/ setBackground(Color.black); setForeground(Color.pink); } public void update(Graphics g) /*Overwrite update to eliminate screen flash*/ { paint(g); } public void eyes(Graphics g) /*This method in turn calls 2 methods*/ { h_eye=(whead/5); w_eye=(h_eye*8/5); x_eye1=((xhead +2*whead/7)-(w_eye/2)); x_eye2=((xhead + 5*whead/7)-(w_eye/2)); y_eyes=((yhead+(hhead/3))-(h_eye/2)); g.setColor(Color.white); g.fillOval(x_eye1,y_eyes,w_eye,h_eye); g.fillOval(x_eye2,y_eyes,w_eye,h_eye); eyeballs(g); eyebrows(g); } public void eyeballs(Graphics g) /*This method will move the eyeballs as well*/ { int x_eyeball1,x_eyeball2,y_eyeballs,ofset=0; y_eyeballs=((y_eyes + h_eye/2)-(h_eye/6)); x_eyeball1=((x_eye1+w_eye/2)-(h_eye/6)); x_eyeball2=((x_eye2+w_eye/2)-(h_eye/6)); Color c=new Color(50,10,200); g.setColor(c); if(cnt<3) ofset=(w_eye*cnt/12); else if (cnt>=2 && cnt<6) ofset+=-1*(w_eye*cnt/20); g.fillOval((x_eyeball1+ofset),y_eyeballs,(h_eye/3),(h_eye/3)); g.fillOval((x_eyeball2+ofset),y_eyeballs,(h_eye/3),(h_eye/3)); repaint(500); cnt++; if (cnt==6) cnt=ofset=0; } public void eyebrows(Graphics g) /*This method moves the eyeballs as well.*/ { int ofset=0; if(cnt2%2==1) ofset=(5+(cnt2*2)); else ofset=(5+(-1*cnt2*2)); g.setColor(Color.darkGray); g.drawArc(x_eye1,(y_eyes-ofset),w_eye,h_eye,20,150); g.drawArc(x_eye1,(y_eyes-(ofset+1)),w_eye,h_eye,20,140); g.drawArc(x_eye2,(y_eyes-ofset),w_eye,h_eye,30,150); g.drawArc(x_eye2,(y_eyes-(ofset+1)),w_eye,h_eye,20,150); repaint(500); cnt2++; if (cnt2==3) cnt2=ofset=1; } public void nose(Graphics g) /*Make a nose*/ { int x1=(xhead+whead/2); int y1=(yhead+hhead/2); int x[]={x1,(x1+whead/10),(x1-whead/10)}; int y[]={y1,(y1+hhead/6),(y1+hhead/6)}; Color c=new Color(200,100,100); g.setColor(c); g.fillPolygon(x,y,3); } public void mouth(Graphics g) /*Make the mouth*/ { g.setColor(Color.darkGray); g.fillOval((xhead+whead/3),(yhead+(3*hhead/4)),hhead/4,whead/6); } public void head(Graphics g) /*The main methode*/ { xhead=160; yhead=40; whead=80; hhead=120; g.fillOval(xhead,yhead,whead,hhead); eyes(g); nose(g); mouth(g); } public void paint(Graphics g) /*Main body of the program*/ { g.setColor(Color.pink); g.fillRect((xhead+whead/3+2),(yhead+9*hhead/10), /*Make the neck.*/ (whead/3),(hhead/2));//Neck g.fillOval((xhead-whead/4),(yhead+(7*hhead/6)), /*make the body.*/ (3*whead/2),(2*hhead));//Body g.fillRect(xhead+3,(yhead+(3*hhead-4)), /*Make a leg.*/ (whead/8),(2*hhead));//leg1 g.fillRect((xhead+whead-12),(yhead+(3*hhead-4)), /*Make a leg.*/ (whead/8),(2*hhead));//leg2 head(g); /*Call method head.*/ } } /*The update methode used my sun. Left this here becuase it might prove usefull*/ /* public void destroy(Graphics g) { g.setColor(getBackground()); g.fillRect(0,0,getSize().width,getSize().height); paint(g); } */