コード例 #1
1
ファイル: Form1.cs プロジェクト: StephGarland/PacMan
        public Form1()
        {
            InitializeComponent();
            rand = new Random();
            dataGrid = new Grid("TileMap.csv");
            Controls.Add(dataGrid);
            sound = new System.Windows.Media.MediaPlayer();
            sound.Open(new Uri("pacmanDubHeavy.mp3", UriKind.Relative));
            sound.Play();

            gameEngine = new GameEngine(dataGrid, rand, timer1.Interval);

            //pacman font
            PrivateFontCollection fontCollection = new PrivateFontCollection();
            fontCollection.AddFontFile("crackman.ttf");

            FontFamily ff = fontCollection.Families[0];
            int fontsize = 12;
            Font pacmanFont = new Font(ff, fontsize, FontStyle.Bold);

            label2.Font = pacmanFont;
            label3.Font = pacmanFont;
            label4.Font = pacmanFont;

            lifeCounter = new PictureBox[3];
            lifeCounter[0] = pictureBox1;
            lifeCounter[1] = pictureBox2;
            lifeCounter[2] = pictureBox3;
        }
コード例 #2
0
        private void MainScreen_Load(object sender, EventArgs e)
        {
            Form form = this.FindForm();

            this.Location = new Point((form.Width - this.Width) / 2, (form.Height - this.Height) / 2);
            backgroundPlayer.Play();
        }
コード例 #3
0
        //start game engine
        public void GameInitialize()
        {
            this.BackgroundImage = Properties.Resources.planet_express_building;

            score          = 0;
            time           = 600;
            zoidbergBoxNum = 0;

            titleLabel.Visible    = false;
            subtitleLabel.Visible = false;
            titleZoidberg.Visible = false;
            adLabel.Visible       = false;
            adPictureBox.Visible  = false;

            gameTimer.Enabled = true;
            gameState         = "running";

            zoidbergBox.Visible = true;
            zoidbergX           = 350;
            objectXList.Clear();
            objectYList.Clear();
            objectSpeedList.Clear();
            objectTypeList.Clear();

            title.Stop();
            theme.MediaEnded += new EventHandler(Theme_Ended);
            theme.Open(new Uri(Application.StartupPath + "/Resources/Futurama theme song.wav"));
            theme.Play();
        }
コード例 #4
0
 //play title music
 public ZoidbergEats()
 {
     InitializeComponent();
     title.MediaEnded += new EventHandler(Title_Ended);
     title.Open(new Uri(Application.StartupPath + "/Resources/Futurama beatbox opening 2.wav"));
     title.Play();
 }
コード例 #5
0
 public GameIntro()
 {
     mp.Open(new Uri(@"dependencies/Epic Chinese Music - Kung Fu.wav", UriKind.Relative));
     mp.Play();
     mp.MediaEnded += mp_MediaEnded;
     InitializeComponent();
 }
コード例 #6
0
ファイル: Form1.cs プロジェクト: Colb98/UI_Media
        private void Play_Click(object sender, EventArgs e)
        {
            CircularButton btn = (CircularButton)sender;

            if (FilePath == null || FilePath.Count == 0)
            {
                return;
            }
            if (playing == false)
            {
                mediaPlayer.Play();
                playing             = true;
                btn.BackgroundImage = UI_Media.Properties.Resources.pause;

                System.Windows.Forms.Integration.ElementHost spectrum = (System.Windows.Forms.Integration.ElementHost)playingUC2.Controls.Find("elementHost1", true)[0];
                spectrum.Visible = true;
            }
            else if (playing == true)
            {
                mediaPlayer.Pause();
                playing             = false;
                btn.BackgroundImage = UI_Media.Properties.Resources.play_button;

                System.Windows.Forms.Integration.ElementHost spectrum = (System.Windows.Forms.Integration.ElementHost)playingUC2.Controls.Find("elementHost1", true)[0];
                spectrum.Visible = false;
            }
        }
コード例 #7
0
 private void GameScreen_Load(object sender, EventArgs e) // when gamescreen is loaded, reset player and play music
 {
     player.y    = this.Height - pheight;
     player.hb.Y = this.Height - pheight;
     music.Stop();
     music.Play();
     music.MediaEnded += music_Loop;
 }
コード例 #8
0
ファイル: GameScreen.cs プロジェクト: berkley1515/Jet-Boi-RD
 private void GameScreen_Load(object sender, EventArgs e)
 {
     player.y    = this.Height - pheight;
     player.hb.Y = this.Height - pheight;
     music.Stop();
     music.Play();
     music.MediaEnded += music_Loop;
 }
コード例 #9
0
 private void exitButton_Enter(object sender, EventArgs e)
 {
     buttonMovePlayer.Open(new Uri(Application.StartupPath + "/Resources/ButtonSwitch.wav"));
     buttonMovePlayer.Play();
     playButton.BackgroundImage        = Properties.Resources.playImage;
     exitButton.BackgroundImage        = Properties.Resources.exitImageSelected;
     multiPlayerButton.BackgroundImage = Properties.Resources._4PlayerButton;
     highScoreButton.BackgroundImage   = Properties.Resources.highScore;
 }
コード例 #10
0
ファイル: Audio.cs プロジェクト: atadjiki/Underworld2171
        /*
         * Plays background music at path specified in the GUI class
         * */
        public static void PlaybackMusic()
        {
            if (backgroundMusicFilePath != null)
            {
                backgroundMusicPlayer.Open(new Uri(backgroundMusicFilePath));
                backgroundMusicPlayer.MediaEnded += new EventHandler(Media_Ended);
                backgroundMusicPlayer.Play();

                return;
            }
        }
コード例 #11
0
        public void PlaySound()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "MP3 files (*.mp3)|*.mp3|All files (*.*)|*.*";

            if (openFileDialog.ShowDialog() == true)
            {
                _mediaPlayer.Open(new Uri(openFileDialog.FileName));
                _mediaPlayer.Play();
            }
        }
コード例 #12
0
ファイル: Form1.cs プロジェクト: Simon13ws/Pong
        public Form1()
        {
            tap.Open(new System.Uri(@"C:\Users\Szymon\Desktop\Sounds\knock.wav"));
            tap.Volume = 0.1;

            wall.Open(new System.Uri(@"C:\Users\Szymon\Desktop\Sounds\tap.wav"));

            backgroundMusic.Open(new System.Uri(@"C:\Users\Szymon\Desktop\Sounds\sound1.wav"));
            backgroundMusic.Volume      = 0.1;
            backgroundMusic.MediaEnded += new EventHandler(backgroundMediaEnded);
            backgroundMusic.Play();
            InitializeComponent();
        }
コード例 #13
0
        private void playButton_Click(object sender, EventArgs e)
        {
            buttonClickPlayer.Open(new Uri(Application.StartupPath + "/Resources/ButtonClick.wav"));
            buttonClickPlayer.Play();
            Form f = this.FindForm();

            f.Controls.Remove(this);
            InstructionScreen gs = new InstructionScreen();

            f.Controls.Add(gs);
            gs.Location = new Point((f.Width - gs.Width) / 2, (f.Height - gs.Height) / 2);
            gs.Focus();
        }
コード例 #14
0
 public void collisionReset()
 {
     collisionPlayer.Open(new Uri(Application.StartupPath + "/Resources/Explosion.wav"));
     collisionPlayer.Play();
     blueDirection = "Up";
     BlueRider.PlayerMoveUpDown(blueDirection);
     orangeDirection = "Down";
     OrangeRider.PlayerMoveUpDown(orangeDirection);
     reset = true;
     playerTrailList.Clear();
     BlueRider.Reset();
     OrangeRider.Reset();
     HighScoreRead();
     HighScoreWrite();
     timer = 0;
     Refresh();
     if (BlueRider.lives == 0 || OrangeRider.lives == 0)
     {
     }
     else
     {
         CountDown();
     }
     reset = false;
     obstaclesList.Clear();
     OnStart();
 }
コード例 #15
0
 private void Play(object sender, EventArgs e)
 {
     if (File.Exists(memoryTextBox5.Text))
     {
         try
         {
             if (mp.Source == null || mp.Source.LocalPath != memoryTextBox5.Text)
             {
                 mp.Open(new Uri(memoryTextBox5.Text));
             }
             mp.Play();
             mp.MediaEnded += delegate(object s, EventArgs args)
             {
                 mp.Stop();
             };
         }
         catch
         {
             MessageBox.Show("Ошибка воспроизведения!");
         }
     }
     else
     {
         MessageBox.Show("Файла не существует!");
     }
 }
コード例 #16
0
ファイル: Sound.cs プロジェクト: ivnikolov/RPG-Teamwork
 public static void PlayFirstSpellSound()
 {
     try
     {
         var firstSpellSound = new System.Windows.Media.MediaPlayer();
         firstSpellSound.Open(new Uri(Directory.GetParent(Directory.GetParent(Directory.GetCurrentDirectory()).ToString()) +
                                      @"\Sound\SoundFiles\Spell1Sound.wav"));
         firstSpellSound.Play();
     }
     catch (FileNotFoundException)
     {
         throw new FileNotFoundException();
     }
     catch (DirectoryNotFoundException)
     {
         throw new DirectoryNotFoundException("The path to the file is incorrect!");
     }
     catch (IOException)
     {
         throw new IOException("Cannot read from file!");
     }
     catch (InvalidOperationException)
     {
         throw new InvalidOperationException();
     }
 }
コード例 #17
0
        private void PlayScoreSound(string fileName)
        {
            string filePath = Path.Combine(Directory.GetCurrentDirectory(), "../../Resources/" + fileName + ".wav");

            _scoreSound.Open(new Uri(filePath));
            _scoreSound.Play();
        }
コード例 #18
0
ファイル: GameStory.cs プロジェクト: Lucho999/AdventureGame
        static public void StoryMiddle(int partOfStory, CharacterClass character)
        {
            Console.WriteLine("You won the battle");
            switch (partOfStory)
            {
            case 1:
                Console.WriteLine("You start looking around for the princess...");
                Console.WriteLine("There is nothing here.. except..");
                Console.WriteLine("Some footprints in the snow that leads higher up the mountains...");
                break;

            case 2:
                Console.WriteLine("What where is she.. ");
                Console.WriteLine("You manage to find a shoe half burrid in the snow...");
                Console.WriteLine("And relize that she must be in the top of the mountain...");
                break;

            case 3:
                Console.WriteLine("You defeted the Boss holding the princess capative.(new quest added)");
                Console.WriteLine("Take the princess of the island (new quest added)");
                character.MainQuest = "Take the princess of the island";
                var p1 = new System.Windows.Media.MediaPlayer();
                p1.Open(new System.Uri(Environment.CurrentDirectory + @"\WinLastBoss.wav"));
                p1.Play();
                break;

            default:
                break;
            }
            Console.ReadKey();
            Console.Clear();
        }
コード例 #19
0
        public tutorialScreen()
        {
            InitializeComponent();

            BMPlayer = new System.Windows.Media.MediaPlayer();
            BMPlayer.Open(new Uri(Application.StartupPath + "/Resources/battle_music.mp3"));
            BMPlayer.Stop();
            BMPlayer.Play();

            // set up background music ^
            // inititalize graphics \/

            xStart = -100;
            xStop  = 50;
            Efire.RotateFlip(RotateFlipType.Rotate180FlipY);
            bm        = new Bitmap(this.Width, this.Height);
            offScreen = Graphics.FromImage(bm);
            gGraphics = this.CreateGraphics();
            Bazooka   = new Bitmap(Properties.Resources.BazookaIcon, Properties.Resources.ATIcon.Width / 2, fire.Height);
            Hvy       = new Bitmap(Properties.Resources.HvyIcon, Properties.Resources.ATIcon.Size);
            Lt        = new Bitmap(Properties.Resources.LtIcon, Properties.Resources.ATIcon.Width / 2, Properties.Resources.ATIcon.Height);
            Md        = new Bitmap(Properties.Resources.MdIcon, Properties.Resources.ATIcon.Width / 2, Properties.Resources.ATIcon.Height);
            Soldier   = new Bitmap(Properties.Resources.SoldierIcon, Properties.Resources.ATIcon.Width / 2, Properties.Resources.ATIcon.Height);
            Sniper    = new Bitmap(Properties.Resources.SniperIcon, Properties.Resources.ATIcon.Width / 2, Properties.Resources.ATIcon.Height);
        }
コード例 #20
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.A && xPlain > 0)
     {
         plane   = Image.FromFile("planeLeft.png");
         xPlain -= 3;
     }
     if (e.KeyCode == Keys.D && xPlain < 455)
     {
         plane   = Image.FromFile("planeRight.png");
         xPlain += 3;
     }
     if (e.KeyCode == Keys.Space)
     {
         for (int i = 0; i < enemy.Length; i++)
         {
             if (xZoom + 33 >= enemy[i].xCastle - 30 &&
                 xZoom + 33 <= enemy[i].xCastle + 130 && yZoom + 33 >= enemy[i].yCastle - 100 &&
                 yZoom + 33 <= enemy[i].yCastle + 65)
             {
                 AnimateImage(i);
                 enemy[i].currentlyAnimating = true;
                 enemy[i].destroy            = true;
                 score += i + 1;
                 boom.Open(new Uri("boom.wav", System.UriKind.Relative));
                 boom.Play();
             }
         }
     }
 }
コード例 #21
0
        private void bulletTimer_Tick(object sender, EventArgs e)
        {
            //fire bullet
            if (spaceDown)//todo move into own timer
            {
                //theta measure for angle of fire, (float uses less memory)
                float thetaAngle = (0 - p.angle);

                // determine the end point for each hand (result must be a double)
                double xStep = Math.Cos(thetaAngle * Math.PI / 180.0);
                double yStep = Math.Sin(thetaAngle * Math.PI / 180.0);

                //bullet object requires float values to draw on screen
                Bullet b = new Bullet(p.x + p.width / 2 - bulletSize / 2,
                                      p.y + p.height / 2 - bulletSize / 2,
                                      bulletSize, bulletSpeed, (float)xStep, (float)-yStep);
                bullets.Add(b);


                var shotPlayer = new System.Windows.Media.MediaPlayer();
                shotPlayer.Open(new Uri(Application.StartupPath + "/Resources/shot.mp3"));
                shotPlayer.Play();
            }

            if (bullets.Count > 0)
            {
                //Use the OffScreen method from the first bullet since we know it exists.
                bullets[0].OffScreen(bullets, this);
            }
        }
コード例 #22
0
        static public void PlaySound(Sound sound)
        {
            string path = "./../../Sounds/";

            switch (sound)
            {
            case Sound.BouncingBall: path += "bouncing_ball";  break;

            case Sound.BreakBrick: path += "break_brick"; break;

            case Sound.BreakReinforcement: path += "break_reinforcement"; break;

            case Sound.Explosion: path += "explosion"; break;

            case Sound.ExtraBall: path += "extra_ball"; break;

            case Sound.ExtraPoints: path += "extra_points"; break;

            case Sound.NextLevel: path += "next_level"; break;

            case Sound.Record: path += "record"; break;
            }
            path += ".mp3";

            var player = new System.Windows.Media.MediaPlayer();

            player.Open(new Uri(path, UriKind.Relative));
            player.Play();
        }
コード例 #23
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            Image  img      = GetScreenshot();
            Bitmap myBitmap = new Bitmap((Bitmap)img);

            //Color currentColor = myBitmap.GetPixel(locations[0].x, locations[0].y);

            //// Look for completion Symbol AKA automation section to be implemented
            //if (!doingProcedure && currentColor == colorToFind)
            //{
            //    doingProcedure = true;
            //}

            if (zavnarZealAlertToolStrip.Checked && !IsQuestInProgress(ref myBitmap))
            {
                mediaPlayer.Volume = (double)trackBar1.Value / 100;
                mediaPlayer.Open(new Uri(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase) + "\\heylisten.wav"));
                mediaPlayer.Play();
                //this.Text = "Can't find quest";
            }
            //else
            // this.Text = "Found quest!";

            // Clean up memory
            img.Dispose();
            myBitmap.Dispose();
        }
コード例 #24
0
        public Form1()
        {
            InitializeComponent();
            rand     = new Random();
            dataGrid = new Grid("TileMap.csv");
            Controls.Add(dataGrid);
            sound = new System.Windows.Media.MediaPlayer();
            sound.Open(new Uri("pacmanDubHeavy.mp3", UriKind.Relative));
            sound.Play();

            gameEngine = new GameEngine(dataGrid, rand, timer1.Interval);

            //pacman font
            PrivateFontCollection fontCollection = new PrivateFontCollection();

            fontCollection.AddFontFile("crackman.ttf");

            FontFamily ff         = fontCollection.Families[0];
            int        fontsize   = 12;
            Font       pacmanFont = new Font(ff, fontsize, FontStyle.Bold);

            label2.Font = pacmanFont;
            label3.Font = pacmanFont;
            label4.Font = pacmanFont;

            lifeCounter    = new PictureBox[3];
            lifeCounter[0] = pictureBox1;
            lifeCounter[1] = pictureBox2;
            lifeCounter[2] = pictureBox3;
        }
コード例 #25
0
        private void AtivaCarta(FrmCarta cart)
        {
            int    codigo   = cart.codigoDaCarta;
            string pastaEXE = Path.GetDirectoryName(Application.ExecutablePath);

            string[] valores = File.ReadAllLines(Path.Combine(pastaEXE, "Cartas.txt"), Encoding.UTF7)[codigo].Split('|');
            if (ptsMagicos - Convert.ToInt32(valores[3]) >= 0)
            {
                cartasJaJogadas++;
                ptsMagicos -= Convert.ToInt32(valores[3]);
                cart.Close();
                cart.Location = new Point(0, 0);

                if (DadosOpcoes.audio == 2)
                {
                    var p2 = new System.Windows.Media.MediaPlayer();
                    p2.Open(new Uri(Path.Combine(Directory.GetCurrentDirectory(),
                                                 "efeitos sonoros", "ativa.wav")));
                    p2.Play();
                }

                FazEfeitoDaCarta(codigo);
            }
            else
            {
                cart.Location = new Point(cart.Location.X - 50, cart.Location.Y + 250);
                MessageBox.Show("Pontos insuficientes");
            }
        }
コード例 #26
0
ファイル: Medium.cs プロジェクト: femiola12/GameProject
        public void coinSound()
        {
            var ballcoins = new System.Windows.Media.MediaPlayer();

            ballcoins.Open(new System.Uri(@"C:\Users\FOladiji\Engineering45\WEEK3\Day5\Coin Pickup Sound.wav"));
            ballcoins.Play();
        }
コード例 #27
0
        private void PlaySound(String soundLocation)
        {
            var sound = new System.Windows.Media.MediaPlayer();

            sound.Open(new System.Uri(soundLocation));
            sound.Play();
        }
コード例 #28
0
 private void Timer3_Tick(object sender, EventArgs e)
 {
     if (startshoot == true && vistrel == false)
     {
         System.Windows.Media.MediaPlayer backgroundMusic;
         backgroundMusic = new System.Windows.Media.MediaPlayer();
         backgroundMusic.Open(new Uri(Directory.GetCurrentDirectory() + "\\shot.wav"));
         backgroundMusic.Play();
         shot.position.Y = player.position.Y + 30;
         shot.position.X = player.position.X + 35;
         startshoot      = false;
         vistrel         = true;
     }
     if (vistrel == true)
     {
         shot.position.Y -= 40;
     }
     if (shot.position.Y < 20 && vistrel == true)
     {
         shot.position.X = -100;
         shot.position.Y = -100;
         vistrel         = false;
         timer3.Enabled  = false;
     }
 }
コード例 #29
0
ファイル: Sound.cs プロジェクト: ivnikolov/RPG-Teamwork
 public static void PlayAttackSound()
 {
     try
     {
         var attackBuffSound = new System.Windows.Media.MediaPlayer();
         attackBuffSound.Open(new Uri(Directory.GetParent(Directory.GetParent(Directory.GetCurrentDirectory()).ToString()) +
                             @"\Sound\SoundFiles\BattleAxeSwing.wav"));
         attackBuffSound.Play();
     }
     catch (FileNotFoundException)
     {
         throw new FileNotFoundException();
     }
     catch (DirectoryNotFoundException)
     {
         throw new DirectoryNotFoundException("The path to the file is incorrect!");
     }
     catch (IOException)
     {
         throw new IOException("Cannot read from file!");
     }
     catch (InvalidOperationException)
     {
         throw new InvalidOperationException();
     }
 }
コード例 #30
0
        void cmdPlay_Click(object sender, EventArgs e)
        {
            Button  cmd = (Button)sender;
            TextBox txt;

            if (cmd.Name == "cmdPlayMessage")
            {
                txt = txtMessage;
            }
            else if (cmd.Name == "cmdPlayEom")
            {
                txt = txtEom;
            }
            else if (cmd.Name == "cmdPlayBriefing")
            {
                txt = txtBriefing;
            }
            else
            {
                txt = txtPrePostWav;
            }

            if (!File.Exists(_wave + txt.Text))
            {
                return;
            }
            var plr = new System.Windows.Media.MediaPlayer();

            plr.MediaEnded += mediaPlayer_MediaEnded;
            plr.Open(new Uri(_wave + txt.Text));
            plr.Play();
            _activeSounds.Add(plr);
        }
        private void tmrTirai2_Tick(object sender, EventArgs e)
        {
            waktuP2Tirai++;
            if (waktuP2Tirai == 1)
            {
                new System.Threading.Thread(() =>
                {
                    var c = new System.Windows.Media.MediaPlayer();
                    c.Open(new System.Uri(@Application.StartupPath + "\\Music\\G6TiraiBuka.wav"));
                    c.Play();
                }).Start();
            }

            picTirai2Ke2.Location = new Point(picTirai2Ke2.Location.X + 75, picTirai2Ke2.Location.Y);
            if (waktuP2Tirai == 5)
            {
                if (jumlahTotalBenarP2 < 5)
                {
                    picP2Angka1.Visible  = true;
                    picP2Angka2.Visible  = true;
                    picP2Angka3.Visible  = true;
                    picP2Angka4.Visible  = true;
                    picTirai2Ke2.Visible = false;
                    lblSoal2.Visible     = true;
                    //label8.Visible = true;
                }
                picTirai2Ke2.Location = new Point(508, 0);
                tmrTirai2.Enabled     = false;
                waktuP2Tirai          = 0;
            }
        }
コード例 #32
0
 public void SpecialAttackdmg(Monster monster)
 {
     if (SpecialAttackCounter < 1)
     {
         SpecialAttackCounter++;
         Console.WriteLine("counter" + SpecialAttackCounter);
         WarCry();
         Console.ForegroundColor = ConsoleColor.Red;
         monster.TakeDmg(SpecialAttack);
         Console.WriteLine("You blaze the monster with a special attack!!!!");
         Console.WriteLine($"You hit for {SpecialAttack}hitpoints...");
         Console.WriteLine("The monster is dazed.. ");
         Console.ForegroundColor = ConsoleColor.White;
         var p1 = new System.Windows.Media.MediaPlayer();
         p1.Open(new System.Uri(Environment.CurrentDirectory + @"\Special.wav"));
         p1.Play();
     }
     else if (SpecialAttackCounter == 3)
     {
         Console.WriteLine("Something in the woods seems to be blocking your special attacks..");
     }
     else
     {
         Console.WriteLine("You can only do one special attack per battle! \nTry running away if you are scared..");
     }
 }
コード例 #33
0
ファイル: Form1.cs プロジェクト: pelad0/juego
 private void soundInicio()
 {
     var p3 = new System.Windows.Media.MediaPlayer();
     //p3.ReadLocalValue(Resources.minions_minion_toy); no funciono
     //p3.SetValue(Resources.minions_minion_toy);falta un parametro
     p3.Open(new System.Uri(@"C:\Users\Sebastian\Desktop\soundJuego\minions-minion-toy.wav"));
     p3.Play();
 }
コード例 #34
0
ファイル: Form1.cs プロジェクト: pelad0/juego
 private void soundMinion()
 {
     var p3 = new System.Windows.Media.MediaPlayer();
     p3.Open(new System.Uri(@"C:\Users\Sebastian\Desktop\soundJuego\minions-hellow.wav"));
     p3.Play();
 }
コード例 #35
0
ファイル: Snake.cs プロジェクト: gornikp/projektKCK
        //public Key k2;
        public void snakeLoop()
        {
            player.SoundLocation = @"C:\content\2.wav";
            if (muzik == true)
            {
                player.PlayLooping();
            }

            //Zmienne :o

            licznik_karmienia_weza = Environment.TickCount;
            licznik_karmienia_weza2 = Environment.TickCount;




            dodawanie_scian(sciany);
            wyswietl.sciany(przeszkody);//klasa game viewer
            narodziny_weza();
            losuj_jedzenie();
            wyswietl.jedzenie(pokarm, 0);//klasa game viewer
            losuj_jedzenie_specjalne();
            wyswietl.jedzenie(pokarm_specjalny, temp);
            wyswietl.weza(wonsz);//klasa game viewer 
            while (true)//TODO: przerobic na kontrole w wpf
            { 
                double mnoznik_za_lvl = (1 / sleepTime) * 33 + (sciany + 1) * 2;


                //if (true)
                //  {
                //ConsoleKeyInfo kl = Console.ReadKey(false); // przerobić na switcha
                //Key k1 = wyswietl.klawisz_mi_daj();
                //return App.Current.Dispatcher.BeginInvoke(new Action(() => { Keyboard.IsKeyDown(Key.P); }));
                if (Keyboard.IsKeyToggled(Key.Left))
                    {
                    if (kierunek_poruszania != (int)kierunek.prawo) kierunek_poruszania = (int)kierunek.lewo;
                    }
                else if (Keyboard.IsKeyToggled(Key.Right))
                {
                    if (kierunek_poruszania != (int)kierunek.lewo) kierunek_poruszania = (int)kierunek.prawo;
                }
                if (Keyboard.IsKeyToggled(Key.Up))
                {
                    if (kierunek_poruszania != (int)kierunek.dol) kierunek_poruszania = (int)kierunek.gora;
                    
                }
                if (Keyboard.IsKeyToggled(Key.Down))
                {
                    if (kierunek_poruszania != (int)kierunek.gora) kierunek_poruszania = (int)kierunek.dol;
                }
                if (Keyboard.IsKeyDown(Key.P))
                { pause(); Thread.Sleep(500); }// bo mi sie kurwa 2 razy odpala pizda jebana;

                Koordynaty aktualnaGlowa = wonsz.Last();
                Koordynaty nowy_kierunek = tablica_skretow[kierunek_poruszania];

                Koordynaty nowaGlowa = new Koordynaty((int)aktualnaGlowa.row + (int)nowy_kierunek.row,
                    (int)aktualnaGlowa.col + (int)nowy_kierunek.col);

                if (nowaGlowa.col < 0) nowaGlowa.col = windowWidth - 1; ///
                if (nowaGlowa.row < 0) nowaGlowa.row = windowHeight - 1;/// Wanrunki przechodzenia przez sciany
                if (nowaGlowa.row >= windowHeight) nowaGlowa.row = 0;  //// zmiana na wymiary okna w nst projekcie
                if (nowaGlowa.col >= windowWidth) nowaGlowa.col = 0;   ////

                if (wonsz.Contains(nowaGlowa) || przeszkody.Contains(nowaGlowa)) // Warunek kończoncy grę !
                {
                    punkty = (wonsz.Count - 10) * mnoznik * (int)mnoznik_za_lvl - punkty_ujemne + punkty_dodatkowe;
                    if (punkty < 0) punkty = 0;
                    punkty = Math.Max(punkty, 0);
                    wyswietl.muzik = this.muzik;
                    player.Stop();
                    //if (elo == true) {
                        App.Current.Dispatcher.BeginInvoke(new Action(() => { wyswietl.game_over(punkty, muzik); }));
                      //  elo = false;
                    //}

                    return;
                }
                

                wonsz.Enqueue(nowaGlowa);// doadnie nowej glowy do kolejki
                wyswietl.usun_stara_glowe(aktualnaGlowa);
                wyswietl.zmien_kierunek_glowy(nowaGlowa, kierunek_poruszania);


                if (nowaGlowa.col == pokarm_specjalny.col && nowaGlowa.row == pokarm_specjalny.row)
                {
                    var p2 = new System.Windows.Media.MediaPlayer();
                    p2.Open(new Uri(@"C:\content\3.wav"));
                    p2.Play();

                    if (temp == 1)
                    {
                        punkty_ujemne += punkty / 2;
                    }
                    if (temp == 2)
                    {
                        punkty_dodatkowe += 500;
                    }
                    if (temp == 3)
                    {
                        sleepTime += 10;
                        punkty_dodatkowe += 153;
                    }
                    if (temp == 4)
                    {
                        punkty_dodatkowe += 153;
                        sleepTime -= 10;
                    }
                    licznik_karmienia_weza2 = Environment.TickCount;
                    punkty = (wonsz.Count - 10) * mnoznik * (int)mnoznik_za_lvl - punkty_ujemne + punkty_dodatkowe;
                    wyswietl.wyswietl_wynik(Math.Max(punkty, 0));
                    wyswietl.usun_pokarm_lub_ogon(pokarm_specjalny);
                    pokarm_specjalny = default(Koordynaty);

                }
                else if (nowaGlowa.col == pokarm.col && nowaGlowa.row == pokarm.row)
                {
                    //Metoda laternatywna
                    //new System.Threading.Thread(() =>
                    //{
                    //    var c = new System.Windows.Media.MediaPlayer();
                    //    c.Open(new System.Uri(@"E:\Users\The_BuBu\Documents\Visual Studio 2013\Projects\ConsoleApplication2\ConsoleApplication2\bin\Debug\3.wav"));
                    //    c.Play();
                    //}).Start();

                    var p2 = new System.Windows.Media.MediaPlayer();
                    p2.Open(new System.Uri(@"C:\content\3.wav"));
                    p2.Play();

                    // karmienie weza
                    losuj_jedzenie();
                    licznik_karmienia_weza = Environment.TickCount;
                    punkty = (wonsz.Count - 10) * mnoznik * (int)mnoznik_za_lvl - punkty_ujemne + punkty_dodatkowe;
                    wyswietl.wyswietl_wynik(Math.Max(punkty, 0));
                    wyswietl.jedzenie(pokarm, 0);//klasa game viewer
                }
                else
                {
                    // prouszanie się węża - usunięcie ogona jesli nic nie zjadł
                    Koordynaty last = wonsz.Dequeue(); // uzyskiwanie "adresu" ogona 
                    wyswietl.usun_pokarm_lub_ogon(last);
                }

                if (Environment.TickCount - licznik_karmienia_weza2 >= 25000)
                {
                    wyswietl.usun_pokarm_lub_ogon(pokarm_specjalny);
                    pokarm_specjalny = default(Koordynaty);
                    // random do losowania koordynat nowych smakołyków
                    temp = generator.Next(1, 5);
                    if (temp == 1)
                    {
                        losuj_jedzenie_specjalne();
                        wyswietl.jedzenie(pokarm_specjalny, 1);
                    }
                    if (temp == 2)
                    {
                        losuj_jedzenie_specjalne();
                        wyswietl.jedzenie(pokarm_specjalny, 2);
                    }
                    if (temp == 3)
                    {
                        losuj_jedzenie_specjalne();
                        wyswietl.jedzenie(pokarm_specjalny, 3);
                    }
                    if (temp == 4)
                    {
                        losuj_jedzenie_specjalne();
                        wyswietl.jedzenie(pokarm_specjalny, 4);
                    }
                    licznik_karmienia_weza2 = Environment.TickCount;
                }
                if (Environment.TickCount - licznik_karmienia_weza >= czas_usuniecia_jedzenia) // usuwanie pokarmu po okreslonym czasie
                {
                    punkty_ujemne = punkty_ujemne + 50;
                    wyswietl.usun_pokarm_lub_ogon(pokarm);
                    losuj_jedzenie();
                    licznik_karmienia_weza = Environment.TickCount;
                }
                wyswietl.jedzenie(pokarm, 0);
                //sleepTime -= 0.001;
                Thread.Sleep((int)sleepTime);
            }           
        }     
コード例 #36
0
ファイル: Form1.cs プロジェクト: pelad0/juego
        /// <summary>
        /// grafica una explosión en objetivo
        /// </summary>
        /// <param name="p"></param>
        private void Explosion(Point p)
        {
            if (sonido)
            {
                var ex = new System.Windows.Media.MediaPlayer();
                ex.Open(new System.Uri(@"C:\Users\Sebastian\Desktop\soundJuego\bomb.wav"));
                ex.Play();
            }

            for (int i = 0; i < 15; i++)
            {
                gBase.DrawImage(Resources.blanco, p.X, p.Y, 48, 48);
                gBase.DrawImage(explosion[i], p.X, p.Y, 48, 48);
                //Application.DoEvents();
                System.Threading.Thread.Sleep(50);
            }
            gBase.DrawImage(Resources.blanco, p.X, p.Y, 48, 48);
        }
コード例 #37
0
ファイル: Snake.cs プロジェクト: gornikp/projektKCK
        public void Snake_Init()
        {
            player.SoundLocation = "2.wav";
            if (muzik == true)
            {

                player.Stop();
                //var p1 = new System.Windows.Media.MediaPlayer();
                //p1.Open(new System.Uri(@"E:\Users\The_BuBu\Documents\Visual Studio 2013\Projects\ConsoleApplication2\ConsoleApplication2\bin\Debug\2.wav"));
                //p1.Play();
                //new System.Threading.Thread(() =>
                //{
                //    var c = new System.Windows.Media.MediaPlayer();
                //    c.Open(new System.Uri(@"E:\Users\The_BuBu\Documents\Visual Studio 2013\Projects\ConsoleApplication2\ConsoleApplication2\bin\Debug\2.wav"));
                //    c.Play();
                //}).Start();
                player.PlayLooping();
            }
            double mnoznik_za_lvl = (1 / sleepTime) * 33 + (sciany+1)*2;
            Console.CursorSize = 12;
            Console.BufferHeight = 60;
            Console.BufferWidth = 201;
            Console.SetWindowSize(200, 60);
            //Zmienne :o
            int kierunek_poruszania = (int)kierunek.prawo; // początkowy kierunek (by np wonsz nie wpadl na skałę)
            int licznik_karmienia_weza = 0;// odlicza czas od odtatniego karmienia
            int licznik_karmienia_weza2 = 0;
            int czas_usuniecia_jedzenia = 30000; // jak dłygo jedzenie pozostaje na planszy
            int punkty_ujemne = 0; // punkty ujemne za niezjedzone jesdzenie
            licznik_karmienia_weza = Environment.TickCount;
            licznik_karmienia_weza2 = Environment.TickCount;
            int temp=2;

            Koordynaty[] tablica_skretow = new Koordynaty[]
            {
                new Koordynaty(0, 1), // right
                new Koordynaty(0, -1), // left
                new Koordynaty(1, 0), // down
                new Koordynaty(-1, 0), // up
            };
            dodawanie_scian(sciany);
            wyswietl.sciany(przeszkody);//klasa game viewer
            narodziny_weza();
            losuj_jedzenie();
            wyswietl.jedzenie(pokarm,0);//klasa game viewer
            losuj_jedzenie_specjalne();
            wyswietl.jedzenie(pokarm_specjalny, temp);
            wyswietl.weza(wonsz);//klasa game viewer
            while (true)
            {

                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo kl = Console.ReadKey(false); // przerobić na switcha
                    switch (kl.Key)
                    {
                        case ConsoleKey.LeftArrow:
                            if (kierunek_poruszania != (int)kierunek.prawo) kierunek_poruszania = (int)kierunek.lewo;
                            break;
                        case ConsoleKey.RightArrow:
                            if (kierunek_poruszania != (int)kierunek.lewo) kierunek_poruszania = (int)kierunek.prawo;
                            break;
                        case ConsoleKey.UpArrow:
                            if (kierunek_poruszania != (int)kierunek.dol) kierunek_poruszania = (int)kierunek.gora;
                            break;
                        case ConsoleKey.DownArrow:
                            if (kierunek_poruszania != (int)kierunek.gora) kierunek_poruszania = (int)kierunek.dol;
                            break;
                        case ConsoleKey.P:
                            pause();
                            break;
                    }

                }

                Koordynaty aktualnaGlowa = wonsz.Last();
                Koordynaty nowy_kierunek = tablica_skretow[kierunek_poruszania];

                Koordynaty nowaGlowa = new Koordynaty(aktualnaGlowa.row + nowy_kierunek.row,
                    aktualnaGlowa.col + nowy_kierunek.col);

                if (nowaGlowa.col < 0) nowaGlowa.col = Console.WindowWidth - 1; ///
                if (nowaGlowa.row < 6) nowaGlowa.row = Console.WindowHeight - 1;/// Wanrunki przechodzenia przez sciany
                if (nowaGlowa.row >= Console.WindowHeight) nowaGlowa.row = 6;  //// zmiana na wymiary okna w nst projekcie
                if (nowaGlowa.col >= Console.WindowWidth) nowaGlowa.col = 0;   ////

                if (wonsz.Contains(nowaGlowa) || przeszkody.Contains(nowaGlowa)) // Warunek kończoncy grę !
                {
                    punkty = (wonsz.Count - 10) * mnoznik * (int)mnoznik_za_lvl - punkty_ujemne + punkty_dodatkowe;
                    if (punkty < 0) punkty = 0;
                    punkty = Math.Max(punkty, 0);
                    wyswietl.muzik = this.muzik;
                    wyswietl.game_over(punkty);
                    Thread.Sleep(2000);
                    Console.ReadKey(false);
                    return;
                }

                wonsz.Enqueue(nowaGlowa);// doadnie nowej glowy do kolejki
                wyswietl.usun_stara_glowe(aktualnaGlowa);
                wyswietl.zmien_kierunek_glowy(nowaGlowa, kierunek_poruszania);

                    if (nowaGlowa.col == pokarm_specjalny.col && nowaGlowa.row == pokarm_specjalny.row)
                    {
                        var p2 = new System.Windows.Media.MediaPlayer();
                    //string startupPath = Environment.CurrentDirectory;
                    //Uri uri = new Uri(startupPath + @"sounds\2wav");
                    //MessageBox.Show("You Lose! Your score is "+ uri.ToString(), "Game Over", MessageBoxButton.OK, MessageBoxImage.Hand);
                    p2.Open(new Uri(@"C:\content\3.wav"));
                        p2.Play();

                        if (temp==1)
                        {
                            punkty_ujemne += punkty / 2;
                        }
                        if (temp == 2)
                        {
                            punkty_dodatkowe += 500;
                        }
                        if (temp == 3)
                        {
                            sleepTime += 10;
                            punkty_dodatkowe += 153;
                        }
                        if (temp == 4)
                        {
                            punkty_dodatkowe += 153;
                            sleepTime -= 10;
                        }
                        licznik_karmienia_weza2 = Environment.TickCount;
                        punkty = (wonsz.Count - 10) * mnoznik * (int)mnoznik_za_lvl - punkty_ujemne + punkty_dodatkowe;
                        wyswietl.wyswietl_wynik(Math.Max(punkty, 0));
                        wyswietl.usun_pokarm_lub_ogon(pokarm_specjalny);
                        ///pokarm_specjalny.Clear();
                        pokarm_specjalny = default(Koordynaty);

                }
                else if (nowaGlowa.col == pokarm.col && nowaGlowa.row == pokarm.row)
                {
                    //Metoda laternatywna
                    //new System.Threading.Thread(() =>
                    //{
                    //    var c = new System.Windows.Media.MediaPlayer();
                    //    c.Open(new System.Uri(@"E:\Users\The_BuBu\Documents\Visual Studio 2013\Projects\ConsoleApplication2\ConsoleApplication2\bin\Debug\3.wav"));
                    //    c.Play();
                    //}).Start();

                    var p2 = new System.Windows.Media.MediaPlayer();
                    p2.Open(new System.Uri(@"C:\content\3.wav"));
                    p2.Play();

                    // karmienie weza
                    losuj_jedzenie();
                    licznik_karmienia_weza = Environment.TickCount;
                    punkty = (wonsz.Count - 10) * mnoznik * (int)mnoznik_za_lvl - punkty_ujemne + punkty_dodatkowe;
                    wyswietl.wyswietl_wynik(Math.Max(punkty, 0));
                    wyswietl.jedzenie(pokarm, 0);//klasa game viewer
                }
                else
                {
                    // prouszanie się węża - usunięcie ogona jesli nic nie zjadł
                    Koordynaty last = wonsz.Dequeue(); // uzyskiwanie "adresu" ogona
                    wyswietl.usun_pokarm_lub_ogon(last);
                }

                if (Environment.TickCount - licznik_karmienia_weza2 >= 25000)
                        {
                    if (!pokarm_specjalny.Equals(default(Koordynaty))) { wyswietl.usun_pokarm_lub_ogon(pokarm_specjalny); }
                    pokarm_specjalny = default(Koordynaty);
                             // random do losowania koordynat nowych smakołyków
                        temp = generator.Next(1,5);
                        if (temp==1)
                        {
                            losuj_jedzenie_specjalne();
                            wyswietl.jedzenie(pokarm_specjalny, 1);
                        }
                        if (temp == 2)
                        {
                            losuj_jedzenie_specjalne();
                            wyswietl.jedzenie(pokarm_specjalny, 2);
                        }
                        if (temp == 3)
                        {
                            losuj_jedzenie_specjalne();
                            wyswietl.jedzenie(pokarm_specjalny, 3);
                        }
                        if (temp == 4)
                        {
                            losuj_jedzenie_specjalne();
                            wyswietl.jedzenie(pokarm_specjalny, 4);
                        }
                        licznik_karmienia_weza2 = Environment.TickCount;
                    }

                if (Environment.TickCount - licznik_karmienia_weza >= czas_usuniecia_jedzenia) // usuwanie pokarmu po okreslonym czasie
                {
                    punkty_ujemne = punkty_ujemne + 50;
                    wyswietl.usun_pokarm_lub_ogon(pokarm);
                    losuj_jedzenie();
                    licznik_karmienia_weza = Environment.TickCount;
                }
                wyswietl.jedzenie(pokarm,0);
                //sleepTime -= 0.001;

                Thread.Sleep((int)sleepTime);
            }
        }
コード例 #38
0
ファイル: Game.cs プロジェクト: dennyo/Racegame
 public async void Sounds()
 {
     //Timing and playing of sounds and background music in the game.
     SoundPlayer fanfare = new SoundPlayer(Path.Combine(Environment.CurrentDirectory, "sounds/Race Fanfare.wav"));
     SoundPlayer countdown = new SoundPlayer(Path.Combine(Environment.CurrentDirectory, "sounds/Countdown.wav"));
     var introplayer = new System.Windows.Media.MediaPlayer();
     SoundPlayer soundtrackplayer = new SoundPlayer(Path.Combine(Environment.CurrentDirectory, Soundtrack));
     fanfare.Play();
     await WaitMethod5();
     countdown.Play();
     await WaitMethod7();
     introplayer.Open(new Uri(Path.Combine(Environment.CurrentDirectory, Intro)));
     introplayer.Play();
     await WaitMethod6();
     soundtrackplayer.PlayLooping();
 }