import java.awt.*; import java.applet.*; public class SampleApplet extends Applet { Image boss = null; Image pained = null;; boolean hurt = false; int i; public void init() { boss = getImage(getDocumentBase(),"boss.gif"); pained = getImage(getDocumentBase(),"boss_in_pain.gif"); } public void start() { repaint(); } public void paint(Graphics g) { if(hurt) { g.drawImage(pained,0,0, this); hurt = false; } else { g.drawImage(boss, 0,0, this); hurt = true; } } public boolean mouseDown(Event evt, int x, int y) { if(i % 10 == 0) play(getDocumentBase(), "pain.au"); else if(i % 5 == 0) play(getDocumentBase(), "ouch1.au"); else if(i % 3 == 0) play(getDocumentBase(), "ouch2.au"); else play(getDocumentBase(), "ouch3.au"); i++; repaint(); return true; } }