20 likes | 149 Views
Sound Effects. Managing Sound Events. Song spacesound; SoundEffect bonk; int soundtime; soundtime = 0; spacesound = Content.Load< Song >( "scifi026" ); bonk = Content.Load< SoundEffect >( "scifi034" ); MediaPlayer .IsRepeating = true ; MediaPlayer .Play(spacesound);
E N D
Managing Sound Events Song spacesound; SoundEffect bonk; int soundtime; soundtime = 0; spacesound = Content.Load<Song>("scifi026"); bonk = Content.Load<SoundEffect>("scifi034"); MediaPlayer.IsRepeating = true; MediaPlayer.Play(spacesound); if (x > maxX || x < minX) { vx *= -1; bonk.Play(spritescale.X / (float)3.0, (float)1.0, (float)0.0); } if (y > maxY || y < minY) { vy *= -1; bonk.Play(spritescale.X / (float)3.0, (float)1.0, (float)0.0); } spritescale.X *= (float)vscale; spritescale.Y *= (float)vscale; if (spritescale.X < 0.1 || spritescale.X > 2.5) { vscale = 1.0 / vscale; bonk.Play(spritescale.X / (float)3.0, (float)1.0, (float)0.0); } soundtime += gameTime.ElapsedGameTime.Milliseconds; if (soundtime > soundframetime) { MediaPlayer.Volume = spritescale.X / (float)3.0; soundtime = 0; } global declarations initialization loading contect updates