aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-04-15 15:08:21 -0400
committerMichael <[email protected]>2017-04-15 15:08:21 -0400
commit0807e04881336ef51b1c473d2e61d344c8bef113 (patch)
treeef95db0c591c66e78a901a4d23103c6e83963f91
parent51050a02d4d5eff361cfa697eeba777ddafa085a (diff)
downloadshiftos_thereturn-0807e04881336ef51b1c473d2e61d344c8bef113.tar.gz
shiftos_thereturn-0807e04881336ef51b1c473d2e61d344c8bef113.tar.bz2
shiftos_thereturn-0807e04881336ef51b1c473d2e61d344c8bef113.zip
Add sounds to pong and fix audio bugs
-rw-r--r--ShiftOS.WinForms/Applications/Dialog.cs10
-rw-r--r--ShiftOS.WinForms/Applications/Pong.Designer.cs14
-rw-r--r--ShiftOS.WinForms/Applications/Pong.cs13
-rw-r--r--ShiftOS_TheReturn/AudioManager.cs32
4 files changed, 40 insertions, 29 deletions
diff --git a/ShiftOS.WinForms/Applications/Dialog.cs b/ShiftOS.WinForms/Applications/Dialog.cs
index 171bdc4..593d64b 100644
--- a/ShiftOS.WinForms/Applications/Dialog.cs
+++ b/ShiftOS.WinForms/Applications/Dialog.cs
@@ -52,15 +52,7 @@ namespace ShiftOS.WinForms.Applications
public void OnLoad()
{
AppearanceManager.SetWindowTitle(this, this.Title);
- var str = Properties.Resources.infobox;
- var bytes = new byte[str.Length];
- str.Read(bytes, 0, bytes.Length);
- ShiftOS.Engine.AudioManager.Stop();
- if (File.Exists("snd.wav"))
- File.Delete("snd.wav");
- File.WriteAllBytes("snd.wav", bytes);
-
- ShiftOS.Engine.AudioManager.Play("snd.wav");
+ ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.infobox);
}
public void OnSkinLoad()
diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs
index e619eaa..f28868a 100644
--- a/ShiftOS.WinForms/Applications/Pong.Designer.cs
+++ b/ShiftOS.WinForms/Applications/Pong.Designer.cs
@@ -174,7 +174,7 @@ namespace ShiftOS.WinForms.Applications
this.pgcontents.Dock = System.Windows.Forms.DockStyle.Fill;
this.pgcontents.Location = new System.Drawing.Point(0, 0);
this.pgcontents.Name = "pgcontents";
- this.pgcontents.Size = new System.Drawing.Size(1867, 819);
+ this.pgcontents.Size = new System.Drawing.Size(912, 504);
this.pgcontents.TabIndex = 20;
this.pgcontents.Paint += new System.Windows.Forms.PaintEventHandler(this.pgcontents_Paint);
this.pgcontents.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove);
@@ -617,7 +617,7 @@ namespace ShiftOS.WinForms.Applications
//
this.paddleComputer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.paddleComputer.BackColor = System.Drawing.Color.Black;
- this.paddleComputer.Location = new System.Drawing.Point(1833, 134);
+ this.paddleComputer.Location = new System.Drawing.Point(878, 134);
this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 150);
this.paddleComputer.Name = "paddleComputer";
this.paddleComputer.Size = new System.Drawing.Size(20, 100);
@@ -629,7 +629,7 @@ namespace ShiftOS.WinForms.Applications
this.lbllevelandtime.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbllevelandtime.Location = new System.Drawing.Point(0, 0);
this.lbllevelandtime.Name = "lbllevelandtime";
- this.lbllevelandtime.Size = new System.Drawing.Size(1867, 22);
+ this.lbllevelandtime.Size = new System.Drawing.Size(912, 22);
this.lbllevelandtime.TabIndex = 4;
this.lbllevelandtime.Tag = "header1";
this.lbllevelandtime.Text = "Level: 1 - 58 Seconds Left";
@@ -641,7 +641,7 @@ namespace ShiftOS.WinForms.Applications
| System.Windows.Forms.AnchorStyles.Right)));
this.lblstatscodepoints.AutoSize = true;
this.lblstatscodepoints.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.lblstatscodepoints.Location = new System.Drawing.Point(239, 775);
+ this.lblstatscodepoints.Location = new System.Drawing.Point(239, 460);
this.lblstatscodepoints.Name = "lblstatscodepoints";
this.lblstatscodepoints.Size = new System.Drawing.Size(116, 23);
this.lblstatscodepoints.TabIndex = 12;
@@ -654,7 +654,7 @@ namespace ShiftOS.WinForms.Applications
this.lblstatsY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.lblstatsY.AutoSize = true;
this.lblstatsY.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.lblstatsY.Location = new System.Drawing.Point(1395, 775);
+ this.lblstatsY.Location = new System.Drawing.Point(440, 460);
this.lblstatsY.Name = "lblstatsY";
this.lblstatsY.Size = new System.Drawing.Size(76, 23);
this.lblstatsY.TabIndex = 11;
@@ -667,7 +667,7 @@ namespace ShiftOS.WinForms.Applications
this.lblstatsX.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblstatsX.AutoSize = true;
this.lblstatsX.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.lblstatsX.Location = new System.Drawing.Point(3, 775);
+ this.lblstatsX.Location = new System.Drawing.Point(3, 460);
this.lblstatsX.Name = "lblstatsX";
this.lblstatsX.Size = new System.Drawing.Size(83, 23);
this.lblstatsX.TabIndex = 5;
@@ -683,7 +683,7 @@ namespace ShiftOS.WinForms.Applications
this.Controls.Add(this.pgcontents);
this.DoubleBuffered = true;
this.Name = "Pong";
- this.Size = new System.Drawing.Size(1867, 819);
+ this.Size = new System.Drawing.Size(912, 504);
this.Load += new System.EventHandler(this.Pong_Load);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove);
this.pgcontents.ResumeLayout(false);
diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs
index a7b1aeb..5d09ca0 100644
--- a/ShiftOS.WinForms/Applications/Pong.cs
+++ b/ShiftOS.WinForms/Applications/Pong.cs
@@ -167,6 +167,7 @@ namespace ShiftOS.WinForms.Applications
{
ball.Location = new Point(ball.Location.X, 0);
yVel = -yVel;
+ ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound);
}
// Check for bottom wall.
@@ -174,12 +175,13 @@ namespace ShiftOS.WinForms.Applications
{
ball.Location = new Point(ball.Location.X, pgcontents.Height - ball.Size.Height);
yVel = -yVel;
+ ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound);
}
// Check for player paddle.
if (ball.Bounds.IntersectsWith(paddleHuman.Bounds))
{
- ball.Location = new Point(paddleHuman.Location.X + ball.Size.Width, ball.Location.Y);
+ ball.Location = new Point(paddleHuman.Location.X + ball.Size.Width + 1, ball.Location.Y);
//randomly increase x or y speed of ball
switch (rand.Next(1, 3))
{
@@ -194,14 +196,17 @@ namespace ShiftOS.WinForms.Applications
break;
}
xVel = -xVel;
+ ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.writesound);
+
}
// Check for computer paddle.
if (ball.Bounds.IntersectsWith(paddleComputer.Bounds))
{
- ball.Location = new Point(paddleComputer.Location.X - paddleComputer.Size.Width + 1, ball.Location.Y);
+ ball.Location = new Point(paddleComputer.Location.X - paddleComputer.Size.Width - 1, ball.Location.Y);
xveldec = xveldec + incrementx;
xVel = -xVel;
+ ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.writesound);
}
// Check for left wall.
@@ -288,6 +293,7 @@ namespace ShiftOS.WinForms.Applications
gameTimer.Stop();
SendHighscores();
}
+
lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString();
}
SetupStats();
@@ -508,15 +514,18 @@ namespace ShiftOS.WinForms.Applications
case 1:
lblcountdown.Text = "1";
countdown = countdown - 1;
+ ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound);
break;
case 2:
lblcountdown.Text = "2";
countdown = countdown - 1;
+ ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound);
break;
case 3:
lblcountdown.Text = "3";
countdown = countdown - 1;
lblcountdown.Show();
+ ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound);
break;
}
diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs
index 54ee1f1..1dd2a8b 100644
--- a/ShiftOS_TheReturn/AudioManager.cs
+++ b/ShiftOS_TheReturn/AudioManager.cs
@@ -26,6 +26,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
@@ -62,20 +63,29 @@ namespace ShiftOS.Engine
public static void Play(string file)
{
- new Thread(() =>
+ try
{
- try
- {
- _reader = new AudioFileReader(file);
- _out = new WaveOut();
- _out.Init(_reader);
- _out.Volume = _provider.Volume;
- _out.Play();
- }
- catch { }
- }).Start();
+ _reader = new AudioFileReader(file);
+ _out = new WaveOut();
+ _out.Init(_reader);
+ _out.Volume = _provider.Volume;
+ _out.Play();
+ }
+ catch { }
}
+ public static void PlayStream(Stream str)
+ {
+ var bytes = new byte[str.Length];
+ str.Read(bytes, 0, bytes.Length);
+ ShiftOS.Engine.AudioManager.Stop();
+ if (File.Exists("snd.wav"))
+ File.Delete("snd.wav");
+ File.WriteAllBytes("snd.wav", bytes);
+
+ ShiftOS.Engine.AudioManager.Play("snd.wav");
+
+ }
internal static void Kill()
{