// -=¿Æ? |) /-\ |\| |\| ¿Æ?=- import java.applet.*; import java.awt.*; public class gasket extends Applet { int iMaxX, iMaxY; private AudioClip sndStart, sndStop, sndBump; public gasket() { } public String getAppletInfo() { return "Name: gasket\r\n" + "Author: \r\n" + "Created with Microsoft Visual J++ Version 6.0"; } public void init() { iMaxX = 600; iMaxY = 450; resize( iMaxX, iMaxY ); sndStart = getAudioClip (getDocumentBase(), "start.au" ); sndStop = getAudioClip (getDocumentBase(), "stop.au" ); sndBump = getAudioClip (getDocumentBase(), "bump.au" ); } public void destroy() { } public void paint(Graphics g) { g.setColor ( clrBackGround ); g.fillRect ( 0, 0, iMaxX, iMaxY ); //Border for ( int i = 0 ; i < iBorder+1 ; i++ ) { g.setColor ( new Color ( 10*i, 0, 0 )); g.drawRect ( i, i, iMaxX-i-i-1, iMaxY-i-i-1); } sndStart.play(); for ( int i = 0 ; i < iIteration ; i++ ) { iRed = iRed-3; iGreen = iGreen+1; iBlue = iBlue+2; g.setColor ( new Color ( iRed, iGreen, iBlue ) ); g.fillOval ( iX, iY, iBallX, iBallY ); try { Thread.sleep ( iSpeed ); } catch ( InterruptedException ex ) { stop(); } if ( i < iIteration-1 ) { g.setColor ( clrBackGround ); g.fillOval ( iX, iY, iBallX, iBallY ); } if ( iX < iBorder+3 ) { iXDir = +1; iSpeed = 2*iSpeed/3; sndBump.play(); } if ( iY < iBorder+3 ) { iYDir = +1; iSpeed = 2*iSpeed/3; sndBump.play(); } if ( iX > iMaxX-iBallX-iBorder-3 ) { iXDir = -1; iSpeed = 2*iSpeed/3; sndBump.play(); } if ( iY > iMaxY-iBallY-iBorder-3) { iYDir = -1; iSpeed = 2*iSpeed/3; sndBump.play(); } iX += iXDir; iY += 2*iYDir; } sndStop.play(); } public void start() { } public void stop() { sndStart.stop(); sndStop.stop(); sndBump.stop(); } }