public DemoGame() : base() { this.Window.Title = "Snowball Demo Game"; this.graphicsDevice = new GraphicsDevice(this.Window); this.Services.AddService(typeof(IGraphicsDevice), this.graphicsDevice); this.keyboard = new Keyboard(); this.Services.AddService(typeof(IKeyboard), this.keyboard); this.mouse = new Mouse(this.Window); this.Services.AddService(typeof(IMouse), this.mouse); this.gamePad = new GamePad(GamePadIndex.One); this.soundDevice = new SoundDevice(); this.Services.AddService(typeof(ISoundDevice), this.soundDevice); this.starfield = new Starfield(this.graphicsDevice); this.ship = new Ship(this.graphicsDevice, this.keyboard, this.gamePad); this.console = new GameConsole(this.Window, this.graphicsDevice); this.console.InputEnabled = true; this.console.InputColor = Color.Blue; this.console.InputReceived += (s, e) => { this.console.WriteLine(e.Text); }; this.console.IsVisibleChanged += (s, e) => { this.console.WriteLine("Console toggled."); }; this.contentManager = new ContentManager<DemoGameContent>(this.Services); this.RegisterContent(); }
public static SoundEffect FromFile(SoundDevice soundDevice, string fileName) { if (!File.Exists(fileName)) throw new FileNotFoundException("Unable to load file \"" + fileName + "\"."); using(Stream stream = File.OpenRead(fileName)) return FromStream(soundDevice, stream); }
public static SoundEffect FromStream(SoundDevice soundDevice, Stream stream) { SharpDX.Multimedia.SoundStream waveStream = new SharpDX.Multimedia.SoundStream(stream); return new SoundEffect(soundDevice.InternalDevice, waveStream); }