sound works

This commit is contained in:
Chris Forbes
2009-10-14 10:35:24 +13:00
parent 2709118d48
commit 74ebdc5f93
7 changed files with 138 additions and 6 deletions

View File

@@ -3,7 +3,8 @@ using OpenRa.FileFormats;
using OpenRa.Game.Graphics;
using OpenRa.TechTree;
using System.Drawing;
using System.Linq;
using System.Linq;
using IrrKlang;
namespace OpenRa.Game
{
@@ -24,7 +25,9 @@ namespace OpenRa.Game
public readonly Dictionary<int, Player> players = new Dictionary<int, Player>();
public Player LocalPlayer { get { return players[localPlayerIndex]; } }
public BuildingInfluenceMap LocalPlayerBuildings;
public BuildingInfluenceMap LocalPlayerBuildings;
ISoundEngine soundEngine;
public Game(string mapName, Renderer renderer, int2 clientSize)
{
@@ -52,7 +55,22 @@ namespace OpenRa.Game
network = new Network();
controller = new Controller(this); // CAREFUL THERES AN UGLY HIDDEN DEPENDENCY HERE STILL
worldRenderer = new WorldRenderer(renderer, this);
worldRenderer = new WorldRenderer(renderer, this);
var sound = AudLoader.LoadSound(FileSystem.Open("intro.aud"));
soundEngine = new ISoundEngine();
var soundSource = soundEngine.AddSoundSourceFromPCMData(sound, "intro.aud",
new AudioFormat()
{
ChannelCount = 1,
FrameCount = sound.Length / 2,
Format = SampleFormat.Signed16Bit,
SampleRate = 22050
});
soundEngine.Play2D(soundSource, true, false, true);
}
public void Tick()

View File

@@ -29,7 +29,8 @@ namespace OpenRa.Game
FileSystem.Mount(new Package("redalert.mix"));
FileSystem.Mount(new Package("conquer.mix"));
FileSystem.Mount(new Package("hires.mix"));
FileSystem.Mount(new Package("general.mix"));
FileSystem.Mount(new Package("general.mix"));
FileSystem.Mount(new Package("local.mix"));
FormBorderStyle = FormBorderStyle.None;
BackColor = Color.Black;

View File

@@ -60,6 +60,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Ijw.DirectX\Ijw.Framework\IjwFramework\bin\Debug\IjwFramework.dll</HintPath>
</Reference>
<Reference Include="irrKlang.NET2.0, Version=1.1.3.0, Culture=neutral, PublicKeyToken=a854741bd80517c7, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\thirdparty\irrKlang.NET2.0.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>

View File

@@ -148,7 +148,7 @@ namespace OpenRa.Game
{
if (mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Down)
{
var point = new float2(mi.Location.X, mi.Location.Y);
var point = mi.Location.ToFloat2();
var item = GetItem(point);
if (item != null)
{
@@ -162,7 +162,7 @@ namespace OpenRa.Game
}
else if( mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down )
{
var point = new float2(mi.Location.X, mi.Location.Y);
var point = mi.Location.ToFloat2();
var item = GetItem(point);
if( item != null )
{