package examples.alarmbeep;

import fang.*;


/**Demonstrates Alarms and audio.
 * Be sure to turn the sound on when
 * running this example in order to
 * hear the beep.  
 * @author Jam Jenkins
 */
public class AlarmBeep extends GameLoop
{
	/**the sound object capable of playing
	 * the audio file*/
	private Sound clip;

	/**schedules an alarm to go off in 1.0
	 * second from the start of the game
	 */
	public void startGame()
	{
		clip=new Sound("resources/DingLower.wav");
		scheduleRelative(new Beeper(), 1.0);
		setHelp("resources/AlarmBeepHelp.txt");
	}

	public void advanceFrame(double tinme)
	{
		clip.setPan(getPlayer().getMouse().getLocation().x);
	}

	/**class which plays the audio clip and
	 * schedules the next playing in 3.0 
	 * seconds
	 * @author Jam Jenkins
	 */
	private class Beeper implements Alarm
	{
		public void alarm()
		{
			clip.play();
			scheduleRelative(this, 3.0);
		}
	}

	public static void main(String[] args)
	{
		new AlarmBeep().runAsApplication();
	}
}

