cs106a – Assignment #3 – Extra Task #1

The complete specification of assignment #3 can be found as part of the stream at iTunes.

Add sounds

The version that is running as an applet on the CS 106A assignment page plays a short bounce sound every time the ball collides with a brick or the paddle. This extension turns out to be very easy. The starter project contains an audio clip file called bounce.au that contains that sound. You can load the sound by writing

AudioClip bounceClip = MediaTools.loadAudioClip("bounce.au");

and later play it by calling

bounceClip.play();

The Java libraries do make some things easy.

As mentioned above add bounceClip as instance variable:

AudioClip bounceClip = MediaTools.loadAudioClip("bounce.au");

and play it everywhere you change the direction of the ball:

bounceClip.play();

The code for this assignment is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Leave a Reply

Your email address will not be published.