示例#1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var titleSong = new System.Windows.Media.MediaPlayer();

            titleSong.Open(new Uri(Application.StartupPath + "/Resources/blip.wav"));

            // Create an instance of the MainScreen
            MainScreen ms = new MainScreen();

            titleMusic.PlayLooping();

            // Add the User Control to the Form
            this.Controls.Add(ms);

            ms.Location = new Point((this.Width - ms.Width) / 2, (this.Height - ms.Height) / 2);
            loadHighscores();
        }
示例#2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            titleMusic.Open(new Uri(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "BONGO.mp3")));
            mainGameMusic.Open(new Uri(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "funky beat.mp3")));

            // Create an instance of the MainScreen
            MainScreen ms = new MainScreen();

            titleMusic.Stop();
            titleMusic.Play();

            // Add the User Control to the Form
            this.Controls.Add(ms);

            ms.Location = new Point((this.Width - ms.Width) / 2, (this.Height - ms.Height) / 2);
            loadHighscores();
        }
示例#3
0
        private void loseScreen_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            lastSelected = selected;

            if (leftArrowDown || rightArrowDown)
            {
                lastArrowDown = true;
            }
            else
            {
                lastArrowDown = false;
            }

            switch (e.KeyCode)
            {
            case Keys.Left:
                leftArrowDown = true;
                break;

            case Keys.Down:
                downArrowDown = true;
                break;

            case Keys.Right:
                rightArrowDown = true;
                break;

            case Keys.Up:
                upArrowDown = true;
                break;

            case Keys.Space:
                spaceDown = true;
                break;

            default:
                break;
            }
            if (lastArrowDown == false)
            {
                if (rightArrowDown == true)
                {
                    if (selected == 4)
                    {
                        selected = 0;
                    }
                    else
                    {
                        selected++;
                    }
                }

                if (leftArrowDown == true)
                {
                    if (selected == 0)
                    {
                        selected = 4;
                    }
                    else
                    {
                        selected--;
                    }
                }
            }

            switch (selected)
            {
            case 0:
                nameText1.ForeColor = Color.Lime;

                if (upArrowDown == true)
                {
                    index1++;

                    if (index1 == 26)
                    {
                        index1 = 0;
                    }
                }

                if (downArrowDown == true)
                {
                    index1--;

                    if (index1 == -1)
                    {
                        index1 = 25;
                    }
                }
                break;

            case 1:
                nameText2.ForeColor = Color.Lime;

                if (upArrowDown == true)
                {
                    index2++;

                    if (index2 == 26)
                    {
                        index2 = 0;
                    }
                }

                if (downArrowDown == true)
                {
                    index2--;

                    if (index2 == -1)
                    {
                        index2 = 25;
                    }
                }
                break;

            case 2:
                nameText3.ForeColor = Color.Lime;

                if (upArrowDown == true)
                {
                    index3++;

                    if (index3 == 26)
                    {
                        index3 = 0;
                    }
                }

                if (downArrowDown == true)
                {
                    index3--;

                    if (index3 == -1)
                    {
                        index3 = 25;
                    }
                }
                break;

            case 3:
                menuButton.ForeColor = Color.Lime;

                if (spaceDown == true)
                {
                    Highscore hs = new Highscore(nameText1.Text + nameText2.Text + nameText3.Text, Convert.ToString(0), Form1.score.ToString("0000"));
                    hs.save(hs);
                    hs.saveScores(Form1.highscoreList);
                    // Goes to the game screen
                    Form       form = this.FindForm();
                    MainScreen ms   = new MainScreen();
                    ms.Location = new Point(this.Left, this.Top);
                    form.Controls.Add(ms);
                    form.Controls.Remove(this);
                }
                break;

            case 4:

                if (spaceDown == true)
                {
                }
                break;
            }

            if (selected != lastSelected)
            {
                switch (lastSelected)
                {
                case 0:
                    nameText1.ForeColor = Color.White;
                    break;

                case 1:
                    nameText2.ForeColor = Color.White;
                    break;

                case 2:
                    nameText3.ForeColor = Color.White;
                    break;

                case 3:
                    menuButton.ForeColor = Color.White;
                    break;

                case 4:
                    //playButton.ForeColor = Color.White;
                    break;
                }
            }

            switch (index1)
            {
            case 0:
                nameText1.Text = "A";
                break;

            case 1:
                nameText1.Text = "B";
                break;

            case 2:
                nameText1.Text = "C";
                break;

            case 3:
                nameText1.Text = "D";
                break;

            case 4:
                nameText1.Text = "E";
                break;

            case 5:
                nameText1.Text = "F";
                break;

            case 6:
                nameText1.Text = "G";
                break;

            case 7:
                nameText1.Text = "H";
                break;

            case 8:
                nameText1.Text = "I";
                break;

            case 9:
                nameText1.Text = "J";
                break;

            case 10:
                nameText1.Text = "K";
                break;

            case 11:
                nameText1.Text = "L";
                break;

            case 12:
                nameText1.Text = "M";
                break;

            case 13:
                nameText1.Text = "N";
                break;

            case 14:
                nameText1.Text = "O";
                break;

            case 15:
                nameText1.Text = "P";
                break;

            case 16:
                nameText1.Text = "Q";
                break;

            case 17:
                nameText1.Text = "R";
                break;

            case 18:
                nameText1.Text = "S";
                break;

            case 19:
                nameText1.Text = "T";
                break;

            case 20:
                nameText1.Text = "U";
                break;

            case 21:
                nameText1.Text = "V";
                break;

            case 22:
                nameText1.Text = "W";
                break;

            case 23:
                nameText1.Text = "X";
                break;

            case 24:
                nameText1.Text = "Y";
                break;

            case 25:
                nameText1.Text = "Z";
                break;
            }

            switch (index2)
            {
            case 0:
                nameText2.Text = "A";
                break;

            case 1:
                nameText2.Text = "B";
                break;

            case 2:
                nameText2.Text = "C";
                break;

            case 3:
                nameText2.Text = "D";
                break;

            case 4:
                nameText2.Text = "E";
                break;

            case 5:
                nameText2.Text = "F";
                break;

            case 6:
                nameText2.Text = "G";
                break;

            case 7:
                nameText2.Text = "H";
                break;

            case 8:
                nameText2.Text = "I";
                break;

            case 9:
                nameText2.Text = "J";
                break;

            case 10:
                nameText2.Text = "K";
                break;

            case 11:
                nameText2.Text = "L";
                break;

            case 12:
                nameText2.Text = "M";
                break;

            case 13:
                nameText2.Text = "N";
                break;

            case 14:
                nameText2.Text = "O";
                break;

            case 15:
                nameText2.Text = "P";
                break;

            case 16:
                nameText2.Text = "Q";
                break;

            case 17:
                nameText2.Text = "R";
                break;

            case 18:
                nameText2.Text = "S";
                break;

            case 19:
                nameText2.Text = "T";
                break;

            case 20:
                nameText2.Text = "U";
                break;

            case 21:
                nameText2.Text = "V";
                break;

            case 22:
                nameText2.Text = "W";
                break;

            case 23:
                nameText2.Text = "X";
                break;

            case 24:
                nameText2.Text = "Y";
                break;

            case 25:
                nameText2.Text = "Z";
                break;
            }

            switch (index3)
            {
            case 0:
                nameText3.Text = "A";
                break;

            case 1:
                nameText3.Text = "B";
                break;

            case 2:
                nameText3.Text = "C";
                break;

            case 3:
                nameText3.Text = "D";
                break;

            case 4:
                nameText3.Text = "E";
                break;

            case 5:
                nameText3.Text = "F";
                break;

            case 6:
                nameText3.Text = "G";
                break;

            case 7:
                nameText3.Text = "H";
                break;

            case 8:
                nameText3.Text = "I";
                break;

            case 9:
                nameText3.Text = "J";
                break;

            case 10:
                nameText3.Text = "K";
                break;

            case 11:
                nameText3.Text = "L";
                break;

            case 12:
                nameText3.Text = "M";
                break;

            case 13:
                nameText3.Text = "N";
                break;

            case 14:
                nameText3.Text = "O";
                break;

            case 15:
                nameText3.Text = "P";
                break;

            case 16:
                nameText3.Text = "Q";
                break;

            case 17:
                nameText3.Text = "R";
                break;

            case 18:
                nameText3.Text = "S";
                break;

            case 19:
                nameText3.Text = "T";
                break;

            case 20:
                nameText3.Text = "U";
                break;

            case 21:
                nameText3.Text = "V";
                break;

            case 22:
                nameText3.Text = "W";
                break;

            case 23:
                nameText3.Text = "X";
                break;

            case 24:
                nameText3.Text = "Y";
                break;

            case 25:
                nameText3.Text = "Z";
                break;
            }
        }
示例#4
0
        private void mainGame_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            imgStill = 0;
            if (e.KeyCode == Keys.Escape)
            {
                pause = true;
                if (brightness > 100)
                {
                    backBrush.Color = Color.FromArgb(140, 0, 0, 0); backBrush2.Color = Color.FromArgb(120, 0, 0, 0);
                }
                timer1.Enabled = false; Refresh();
            }

            if (!pause)
            {
                if (e.KeyCode == Keys.Right && !fart)
                {
                    right = true;
                }
                if (e.KeyCode == Keys.Left && !fart)
                {
                    left = true;
                }
                if (e.KeyCode == Keys.Space)
                {
                    right = false; left = false; fart = true; Form1.fartSound.Play();
                }
            }

            else
            {
                if (e.KeyCode == Keys.Space)
                {
                    pause = false; timer1.Enabled = true; Refresh();
                }
                if (e.KeyCode == Keys.M)
                {
                    // Create an instance of the SecondScreen
                    Form1.mainGameMusic.Stop();
                    Form1.titleMusic.PlayLooping();
                    MainScreen cs = new MainScreen();
                    cs.Location = new Point(this.Left, this.Top);
                    // Add the User Control to the Form
                    Form f = this.FindForm();
                    f.Controls.Remove(this);
                    f.Controls.Add(cs);
                    cs.Focus();
                }
            }
            if (brightness < 245)
            {
                if (e.KeyCode == Keys.B)
                {
                    brightness += 10;
                }
            }
            if (brightness > 12)
            {
                if (e.KeyCode == Keys.M)
                {
                    brightness -= 10;
                }
            }

            //gameOver
            if (e.KeyCode == Keys.G)
            {
                // Create an instance of the SecondScreen
                loseScreen cs = new loseScreen();
                cs.Location = new Point(this.Left, this.Top);
                // Add the User Control to the Form
                Form f = this.FindForm();
                f.Controls.Remove(this);
                f.Controls.Add(cs);
                cs.Focus();
            }
        }