Added Sound
This commit is contained in:
parent
5ee5d8eecb
commit
b1e72a16b0
Binary file not shown.
19
Catch the button/AudioSystem.cs
Normal file
19
Catch the button/AudioSystem.cs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Media;
|
||||||
|
|
||||||
|
namespace Catch_the_button {
|
||||||
|
class AudioSystem {
|
||||||
|
static SoundPlayer hit = new SoundPlayer("./resources/hit.wav");
|
||||||
|
static SoundPlayer miss = new SoundPlayer("./resources/miss.wav");
|
||||||
|
static internal void Hit() {
|
||||||
|
hit.Play();
|
||||||
|
}
|
||||||
|
static internal void Miss() {
|
||||||
|
miss.Play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,6 +61,7 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="AudioSystem.cs" />
|
||||||
<Compile Include="Leaderboard.cs" />
|
<Compile Include="Leaderboard.cs" />
|
||||||
<Compile Include="Main.cs">
|
<Compile Include="Main.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
|
|
|
@ -75,7 +75,6 @@ namespace Catch_the_button {
|
||||||
btn.Location = new Point((frm.Width - btn.Width) / 2, (frm.Height - btn.Height) / 2);
|
btn.Location = new Point((frm.Width - btn.Width) / 2, (frm.Height - btn.Height) / 2);
|
||||||
status = true;
|
status = true;
|
||||||
timer.Interval = delay;
|
timer.Interval = delay;
|
||||||
|
|
||||||
}
|
}
|
||||||
static void Go() { //first button hit
|
static void Go() { //first button hit
|
||||||
timer.Start();
|
timer.Start();
|
||||||
|
@ -87,22 +86,27 @@ namespace Catch_the_button {
|
||||||
if (!status) return;
|
if (!status) return;
|
||||||
if (first) {
|
if (first) {
|
||||||
Go();
|
Go();
|
||||||
|
points++;
|
||||||
|
AudioSystem.Hit();
|
||||||
first = false;
|
first = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (stpwch.ElapsedMilliseconds < 500 && !(obj is Form || obj is System.Timers.Timer)) {
|
if (stpwch.ElapsedMilliseconds < 500 && !(obj is Form || obj is System.Timers.Timer)) {
|
||||||
|
AudioSystem.Hit();
|
||||||
points += 2;
|
points += 2;
|
||||||
if (points % milestoneCount == 0 && delay > 400) {
|
if (points % milestoneCount == 0 && delay > 400) {
|
||||||
delay -= delaydown;
|
delay -= delaydown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (stpwch.ElapsedMilliseconds >= 500 && !(obj is Form || obj is System.Timers.Timer)) {
|
else if (stpwch.ElapsedMilliseconds >= 500 && !(obj is Form || obj is System.Timers.Timer)) {
|
||||||
|
AudioSystem.Hit();
|
||||||
points++;
|
points++;
|
||||||
if (points % milestoneCount == 0 && delay > 400) {
|
if (points % milestoneCount == 0 && delay > 400) {
|
||||||
delay -= delaydown;
|
delay -= delaydown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (obj is System.Timers.Timer || obj is Form) {
|
else if (obj is System.Timers.Timer || obj is Form) {
|
||||||
|
AudioSystem.Miss();
|
||||||
points--;
|
points--;
|
||||||
miss++;
|
miss++;
|
||||||
formResetter.Start();
|
formResetter.Start();
|
||||||
|
|
Binary file not shown.
Binary file not shown.
BIN
Catch the button/bin/Debug/resources/hit.wav
Normal file
BIN
Catch the button/bin/Debug/resources/hit.wav
Normal file
Binary file not shown.
BIN
Catch the button/bin/Debug/resources/miss.wav
Normal file
BIN
Catch the button/bin/Debug/resources/miss.wav
Normal file
Binary file not shown.
|
@ -1 +1 @@
|
||||||
4ec7a7f8cafda8845629d58d71d67896e75d37b3
|
348d5ad308b3803dddd051ec17e7b10c11b6970d
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue