コード例 #1
0
        public Form1()
        {
            InitializeComponent();
            gameTimer.Enabled = false;

            //main menu view
            mainMenuBackground.Visible = true;
            mainMenuView.Visible       = true;
            mainMenuView.Rows.Add();
            var row  = (DataGridViewRow)mainMenuView.Rows[0].Clone();
            var row1 = (DataGridViewRow)mainMenuView.Rows[0].Clone();
            var row2 = (DataGridViewRow)mainMenuView.Rows[0].Clone();

            row.Cells[0].Value  = "Play";
            row1.Cells[0].Value = "Controls";
            row2.Cells[0].Value = "Exit";

            mainMenuView.Rows.Add(row);
            mainMenuView.Rows.Add(row1);
            mainMenuView.Rows.Add(row2);
            mainMenuView.Rows.RemoveAt(0);

            DoubleBuffered            = true;
            Level2.Text               = "Level: 2";
            fuelLabel.Text            = "Fuel Gauge: ";
            Level2.Visible            = false;
            highScoreGridView.Visible = false;
            pipeTop.Left             -= pipeSpeed;
            pipeBottom.Left          -= pipeSpeed;
            sword.Left            -= pipeSpeed;
            fuel.Left             -= pipeSpeed;
            flappyBird.Top        += gravity;
            flappyBird.BorderStyle = BorderStyle.None;
            slashBox.Top          += gravity;
            slashBox.BorderStyle   = BorderStyle.None;
            scoreText.Text         = "Score: " + Inscore;
            fuelBar.Value--;
            ModifyProgressBarColor.SetState(fuelBar, 1);
            System.Media.SoundPlayer player = new System.Media.SoundPlayer();
            //player.SoundLocation = @"C:\Users\Logan Minor\documents\visual studio 2015\Projects\AoTGame\AoTGame\Resources\gameBackgroundMusic.wav";
            //player.PlayLooping();
        }
コード例 #2
0
        private void gameTimer_Tick(object sender, EventArgs e)
        {
            fuelLabel.Text            = "Fuel Gauge: ";
            highScoreGridView.Visible = false;
            pipeTop.Left          -= pipeSpeed;
            pipeBottom.Left       -= pipeSpeed;
            sword.Left            -= pipeSpeed;
            fuel.Left             -= pipeSpeed;
            flappyBird.Top        += gravity;
            flappyBird.BorderStyle = BorderStyle.None;
            slashBox.Top          += gravity;
            slashBox.BorderStyle   = BorderStyle.None;
            scoreText.Text         = "Score: " + Inscore;
            fuelBar.Value--;
            ModifyProgressBarColor.SetState(fuelBar, 1);

            if (slashBox.Visible && slashBox.Bounds.IntersectsWith(pipeTop.Bounds))
            {
                Random rnd = new Random();
                for (int ctr = 274; ctr <= 1500; ctr++)
                {
                    var newLocation = rnd.Next(275, 1500);
                    pipeTop.Location = new Point(newLocation, 0);
                }

                Inscore += 50;
            }

            else if (slashBox.Visible && slashBox.Bounds.IntersectsWith(pipeBottom.Bounds))
            {
                Random rnd = new Random();
                for (int ctr = 435; ctr <= 1500; ctr++)
                {
                    var newLocation = rnd.Next(436, 1500);
                    pipeBottom.Location = new Point(newLocation, 396);
                }
                Inscore += 100;
            }

            if (flappyBird.Bounds.IntersectsWith(ground.Bounds) || flappyBird.Bounds.IntersectsWith(pipeTop.Bounds) || flappyBird.Bounds.IntersectsWith(pipeBottom.Bounds))
            {
                endGame();
            }

            else if (flappyBird.Bounds.IntersectsWith(sword.Bounds))
            {
                Inscore += 25;
                xBounds  = this.Width;
                yBounds  = this.Height;
                moveSword();
            }
            else if (flappyBird.Bounds.IntersectsWith(fuel.Bounds))
            {
                fuelBar.Increment(200);
                xBounds = this.Width;
                yBounds = this.Height;
                moveFuel();
            }

            if (fuelBar.Value <= 1)
            {
                endGame();
            }

            if (sword.Bounds.IntersectsWith(ground.Bounds) || sword.Bounds.IntersectsWith(pipeTop.Bounds) || sword.Bounds.IntersectsWith(pipeBottom.Bounds))
            {
                moveSword();
            }

            if (fuel.Bounds.IntersectsWith(ground.Bounds) || fuel.Bounds.IntersectsWith(pipeTop.Bounds) || fuel.Bounds.IntersectsWith(pipeBottom.Bounds))
            {
                moveFuel();
            }

            if (pipeTop.Left < -80)
            {
                pipeTop.Enabled = true;
                pipeTop.Visible = true;
                pipeTop.Left    = 1000;
                pipeTop.Visible = true;
                Inscore        += 1;
            }
            else if (pipeBottom.Left < -95)
            {
                pipeTop.Enabled    = true;
                pipeTop.Visible    = true;
                pipeBottom.Left    = 1100;
                pipeBottom.Visible = true;
                Inscore           += 1;
            }
            else if (sword.Left < -80)
            {
                moveSword();
            }
            else if (fuel.Left < -2500)
            {
                moveFuel();
            }

            if (Inscore > 500)
            {
                Level2.Visible = true;
                pipeSpeed      = 15;
            }

            else if (Inscore > 550)
            {
                Level2.Visible = false;
            }

            else if (Inscore > 800)
            {
                Level2.Visible = true;
                Level2.Text    = "Level 3";
                pipeSpeed      = 20;
            }

            else if (Inscore > 850)
            {
                Level2.Visible = false;
            }

            else if (Inscore > 1500)
            {
                Level2.Visible = true;
                Level2.Text    = "Level 4";
                pipeSpeed      = 25;
            }

            else if (Inscore > 5000)
            {
                Level2.Visible = true;
                Level2.Text    = "Level 5";
                pipeSpeed      = 30;
            }
        }