Ejemplo n.º 1
0
Archivo: Game.cs Proyecto: bosoni/csat
        public override void Init()
        {
            Settings.TextureDir = "../../data/texture/";
            string AudioDir = "../../data/";

            back = Texture2D.Load("bg.jpg");
            img[0] = Texture2D.Load("head.png", true);
            img[1] = Texture2D.Load("ball.png", true);
            crosshair = Texture2D.Load("cross.png", true);

            font = BitmapFont.Load("fonts/comic12.png");

            BaseGame.Instance.CursorVisible = false; // hide mouse cursor
            //System.Windows.Forms.Cursor.Hide();

            if (player == null)
            {
                player = new OggPlayerFBN();
                player.SetCurrentFile(AudioDir + "music.ogg");

            }
            player.Play();

            snd1 = new AudioClip(AudioDir + "snd2.ogg");
            snd2 = new AudioClip(AudioDir + "snd1.ogg");

            Camera.Set2D();
            base.Init();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes OpenAL and loads two sound clips.
        /// </summary>
        public InteractivePlayerForm()
        {
            // Setup OpenTK audio stuff
            AudioContext ac = new AudioContext();
            XRamExtension xram = new XRamExtension();

            // Load the .ogg files
            guitar = new AudioClip("GuitarSample.ogg");
            boing = new AudioClip("BoingSample.ogg");

            externalClip = null;

            InitializeComponent();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            // Setup OpenTK audio stuff
            AudioContext ac = new AudioContext();
            XRamExtension xram = new XRamExtension();

            // Load the .ogg files
            string guitarFile = "GuitarSample.ogg";
            AudioClip guitarClip = new AudioClip(guitarFile);

            string boingFile = "BoingSample.ogg";
            AudioClip boingClip = new AudioClip(boingFile);

            // Play it.  The first time a clip is played, a background thread is
            // launched to handle all audio.  Playing the clip again or playing
            // a new clip will use the already existing thread.  To avoid
            // threading, construct your own AudioManager.
            guitarClip.Play();

            // Play the "boing" clip every 2 seconds during the guitar clip
            boingClip.Play();
            Thread.Sleep(2000);

            boingClip.Play();
            Thread.Sleep(2000);

            boingClip.Play();
            Thread.Sleep(2000);

            // Finally play some overlapping sounds to demonstrate a sound can
            // have more than one instance played at a time.
            boingClip.Play();
            Thread.Sleep(200);

            boingClip.Play();
            Thread.Sleep(200);

            boingClip.Play();
            Thread.Sleep(200);

            boingClip.Play();
            Thread.Sleep(200);

            // Give the last "boing" time to finish
            Thread.Sleep(800);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Loads an external audio clip to play.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonLoadFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Filter = "Ogg files (*.ogg)|*.ogg|All files (*.*)|*.*";
            fileDialog.FilterIndex = 1;
            fileDialog.RestoreDirectory = true;

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    externalClip = new AudioClip(fileDialog.FileName);
                    textBoxFile.Text = fileDialog.FileName;
                    buttonPlayExternal.Enabled = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }