Beispiel #1
0
 /// <summary>
 /// Private method to process the next queued music file.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Events_MusicFinished(object sender, MusicFinishedEventArgs e)
 {
     if (MusicPlayer.IsPlaying == false)
     {
         if (CurrentMusic.QueuedMusic != null)
         {
             m_CurrentMusic = CurrentMusic.QueuedMusic;
             m_CurrentMusic.Play();
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// Plays the selected music. The music must be in the "music" folder.
 /// If a music is currently playing, it is stopped.
 /// </summary>
 /// <param name="filename">The name of the music (with extension).</param>
 public void StartMusic(string filename)
 {
     if (!ok) return;
     if (nowPlaying != null) {
         nowPlaying.Dispose();
     }
     nowPlaying = new Music(game.loader.LoadRaw("music/" + filename));
     // When trying to play music/sound without a sound card, a DivideByZeroException
     // is thrown. I couldn't find an easier way to test for the sound card.
     try {
         nowPlaying.Play(true);
     }
     catch (DivideByZeroException) {
         ok = false;
     }
 }
Beispiel #3
0
        public Manager()
        {
            try
            {
                 mVideo = Video.SetVideoMode(1300,600);
                 achtergrond = new Surface("Background.jpg");// achtergrond
                 muziek = new Music("Commander Keen 4.mp3");
            }
            catch (Exception error)
            {
                Console.WriteLine(error);
            }

            held = new Hero();

            //vijand = new Enemy(200, 500,true,false);
            //vijand2 = new Enemy(300, 500, false, true);
            //vijand3 = new Enemy(600, 500, false, true);
            //vijand4 = new Enemy(700, 500, true, false);

            level1 = new Level();
            AantalLevens = new NumberOfLives();
            Gameobjecten = new List<GameObject>();

            Gameobjecten.Add(held);
            //Gameobjecten.Add(vijand);
            //Gameobjecten.Add(vijand2);
            //Gameobjecten.Add(vijand3);
            //Gameobjecten.Add(vijand4);

            Vijanden = new List<Enemy>();
            //Vijanden.Add(vijand);
            //Vijanden.Add(vijand2);
            //Vijanden.Add(vijand3);
            //Vijanden.Add(vijand4);

            MusicPlayer.Volume = 30;
            MusicPlayer.Load(muziek);
            muziek.Play();

            Events.Tick += Events_Tick;
            //Events.Fps = 5;
            Events.KeyboardUp += Events_KeyboardUp;
            Events.Quit += Events_Quit;
            Events.Run();
        }
Beispiel #4
0
        /// <summary>
        /// 
        /// </summary>
        public void Start()
        {
            GameView gameView = new GameView(eventManager);
            gameView.CreateView();
            map.Build();

            if (File.Exists(Path.Combine(dataDirectory, "fard-two.ogg")))
            {
                filePath = "";
            }

            Music music = new Music(Path.Combine(filePath, Path.Combine(dataDirectory, "fard-two.ogg")));

            try
            {
                music.Play(-1);
            }
            catch (DivideByZeroException)
            {
                // Linux audio problem
            }
           
            this.gameStatus = GameStatus.Started;
            eventManager.Publish(new GameStatusEventArgs(this, GameStatus.Started));
        }