Added Sound

This commit is contained in:
Heli-o 2021-05-28 14:32:22 +02:00
parent 5ee5d8eecb
commit b1e72a16b0
12 changed files with 26 additions and 2 deletions

Binary file not shown.

View 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();
}
}
}

View file

@ -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>

View file

@ -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.

View file

@ -1 +1 @@
4ec7a7f8cafda8845629d58d71d67896e75d37b3 348d5ad308b3803dddd051ec17e7b10c11b6970d