//----------------------------------------------------------------------------------- // Losing Song method - Plays song if user loses // params: none // return: none //----------------------------------------------------------------------------------- private static void LosingSong() { while (!gameOver) { /* Play 7/8 of first measure */ for (int i = 1; i < 5; i++) { /* Play 8th note */ Tones.SoftToneWrite(SPEAKER, 392); /* Delay */ try { WiringPi.Timing.delay(120); } catch (System.OverflowException) {} /* Rest for 8th note */ if (i != 4) { Tones.SoftToneWrite(SPEAKER, 0); try { WiringPi.Timing.delay(120); } catch (System.OverflowException) {} } } /* Play dotted 16th note */ Tones.SoftToneWrite(SPEAKER, 440); /* Delay */ try { WiringPi.Timing.delay(90); } catch (System.OverflowException) {} /* Brief pause to end of measure */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(30); } catch (System.OverflowException) {} /* Play 7/8 of second measure */ for (int i = 1; i < 5; i++) { /* Play 8th note */ Tones.SoftToneWrite(SPEAKER, 370); /* Delay */ try { WiringPi.Timing.delay(120); } catch (System.OverflowException) {} /* Rest for 8th note */ if (i != 4) { Tones.SoftToneWrite(SPEAKER, 0); try { WiringPi.Timing.delay(120); } catch (System.OverflowException) {} } } /* Play dotted 16th note */ Tones.SoftToneWrite(SPEAKER, 330); /* Delay */ try { WiringPi.Timing.delay(90); } catch (System.OverflowException) {} /* Brief pause to end of measure */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(30); } catch (System.OverflowException) {} /* Play 7/8 of third measure */ for (int i = 1; i < 5; i++) { /* Play 8th note */ Tones.SoftToneWrite(SPEAKER, 247); /* Delay */ try { WiringPi.Timing.delay(120); } catch (System.OverflowException) {} /* Rest for 8th note */ if (i != 4) { Tones.SoftToneWrite(SPEAKER, 0); try { WiringPi.Timing.delay(120); } catch (System.OverflowException) {} } } /* Play dotted 16th note */ Tones.SoftToneWrite(SPEAKER, 277); /* Delay */ try { WiringPi.Timing.delay(90); } catch (System.OverflowException) {} /* Brief pause to end of measure */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(30); } catch (System.OverflowException) {} /* Play 7/8 of fourth measure */ for (int i = 1; i < 5; i++) { /* Play 8th note */ Tones.SoftToneWrite(SPEAKER, 233); /* Delay */ try { WiringPi.Timing.delay(120); } catch (System.OverflowException) {} /* Rest for 8th note */ if (i != 4) { Tones.SoftToneWrite(SPEAKER, 0); try { WiringPi.Timing.delay(120); } catch (System.OverflowException) {} } } /* Play dotted 16th note */ Tones.SoftToneWrite(SPEAKER, 277); /* Delay */ try { WiringPi.Timing.delay(90); } catch (System.OverflowException) {} /* Brief pause to end of measure */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(30); } catch (System.OverflowException) {} } }
//----------------------------------------------------------------------------------- // Winning Song method - Plays song if user wins // params: none // return: none //----------------------------------------------------------------------------------- private static void WinningSong() { while (!gameOver) { /* Play note */ Tones.SoftToneWrite(SPEAKER, 370); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 370); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 294); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 247); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(273); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 247); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(273); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 330); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(273); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 330); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(273); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 330); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 415); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 415); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 440); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 494); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 440); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 440); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 440); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 330); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(273); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 294); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(273); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 370); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(273); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 370); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(273); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 370); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 330); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 330); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 370); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Play note */ Tones.SoftToneWrite(SPEAKER, 330); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} /* Rest */ Tones.SoftToneWrite(SPEAKER, 0); /* Delay */ try { WiringPi.Timing.delay(91); } catch (System.OverflowException) {} } }