void CreateSoundBuffers() { //Buffers must be created in same order as the enumerated type "Sounds" AddBuffer(MediaUtilities.FindFile("shipappear.wav"), Sounds.ShipAppear, false); AddBuffer(MediaUtilities.FindFile("shield.wav"), Sounds.ShipShield, false); AddBuffer(MediaUtilities.FindFile("gunfire.wav"), Sounds.ShipFire, false); AddBuffer(MediaUtilities.FindFile("bangbang.wav"), Sounds.ShipExplode, false); AddBuffer(MediaUtilities.FindFile("rev.wav"), Sounds.ShipThrust, false); AddBuffer(MediaUtilities.FindFile("skid.wav"), Sounds.ShipBrake, false); AddBuffer(MediaUtilities.FindFile("bounce.wav"), Sounds.ShipBounce, false); AddBuffer(MediaUtilities.FindFile("hum.wav"), Sounds.ShipHum, true); AddBuffer(MediaUtilities.FindFile("level.wav"), Sounds.LevelStart, false); AddBuffer(MediaUtilities.FindFile("d_bang.wav"), Sounds.DonutExplode, false); AddBuffer(MediaUtilities.FindFile("p_bang.wav"), Sounds.PyramidExplode, false); AddBuffer(MediaUtilities.FindFile("d_bang.wav"), Sounds.CubeExplode, false); //should be c_bang AddBuffer(MediaUtilities.FindFile("p_bang.wav"), Sounds.SphereExplode, false); //should be s_bang }
private void Initialize() { try { //Common DirectX setup calls... PresentParameters presentParams = new PresentParameters(); presentParams.Windowed = true; // presentParams.BackBufferHeight = screenHeight; // presentParams.BackBufferWidth = screenWidth; presentParams.SwapEffect = SwapEffect.Discard; presentParams.BackBufferFormat = Format.Unknown; presentParams.AutoDepthStencilFormat = DepthFormat.D16; presentParams.EnableAutoDepthStencil = true; // Store the default adapter int adapterOrdinal = D3D.Manager.Adapters.Default.Adapter; CreateFlags flags = CreateFlags.SoftwareVertexProcessing; // Check to see if we can use a pure hardware device D3D.Caps caps = D3D.Manager.GetDeviceCaps(adapterOrdinal, D3D.DeviceType.Hardware); // Do we support hardware vertex processing? if (caps.DeviceCaps.SupportsHardwareTransformAndLight) { // Replace the software vertex processing flags = CreateFlags.HardwareVertexProcessing; } // Do we support a pure device? if (caps.DeviceCaps.SupportsPureDevice) { flags |= CreateFlags.PureDevice; } device = new D3D.Device(0, D3D.DeviceType.Hardware, this, flags, presentParams); device.DeviceReset += new System.EventHandler(this.OnResetDevice); OnResetDevice(device, null); //Space Donuts setup donutTexture = TextureLoader.FromFile(device, MediaUtilities.FindFile(TileSetFileName), 1024, 1024, 1, 0, Format.A8R8G8B8, Pool.Managed, Filter.Point, Filter.Point, (unchecked ((int)0xff000000))); donutTileSet = new TileSet(donutTexture, 0, 0, 6, 5, 32, 32); pyramidTileSet = new TileSet(donutTexture, 0, 384, 4, 10, 16, 16); sphereTileSet = new TileSet(donutTexture, 0, 512, 2, 20, 8, 8); cubeTileSet = new TileSet(donutTexture, 0, 544, 2, 20, 8, 8); shipTileSet = new TileSet(donutTexture, 0, 576, 4, 10, 16, 16); nixiesTileSet = new TileSet(donutTexture, 0, 832, 1, 14, 8, 8); bulletTileSet = new TileSet(donutTexture, 304, 832, 1, 1, 8, 2); //set up DirectInput keyboard device... kbd = new DI.Device(SystemGuid.Keyboard); kbd.SetCooperativeLevel(this, DI.CooperativeLevelFlags.Background | DI.CooperativeLevelFlags.NonExclusive); kbd.Acquire(); soundHandler = new SoundHandler(this); sm.OnCollisionEventHandler += new SpriteManager.HandleCollision(this.CollisionHandler); hrt.Start(); } catch (DirectXException) { // Catch any errors and return a failure } }