示例#1
0
        private void btn_level4_Click(object sender, EventArgs e)
        {
            Level4 level4 = new Level4();

            level4.Show();
            this.Visible = false;
        }
示例#2
0
        private void tmr_movement_Tick(object sender, EventArgs e)
        {
            pb_Player.Top += playerJumpSpeed;

            if (playerJumping && force < 0)
            {
                playerJumping = false;
            }

            if (movingLeft)
            {
                pb_Player.Left -= 5;
            }

            if (movingRight)
            {
                pb_Player.Left += 5;
            }

            if (playerJumping)
            {
                playerJumpSpeed = -12;
                force          -= 1;
            }

            else
            {
                playerJumpSpeed = 12;
            }

            foreach (Control x in this.Controls)
            {
                if (x is PictureBox && x.Tag == "platform")
                {
                    if (pb_Player.Bounds.IntersectsWith(x.Bounds) && !playerJumping)
                    {
                        force         = 8;
                        pb_Player.Top = x.Top - pb_Player.Height;
                    }
                }

                if (x is PictureBox && x.Tag == "gem")
                {
                    if (pb_Player.Bounds.IntersectsWith(x.Bounds))
                    {
                        this.Controls.Remove(x);
                        gemsCollected++;
                        gemsLeft--;
                    }
                }
            }

            gemLabel.Text = "Collect " + gemsLeft + " more gems";

            if (gemsCollected == 5)
            {
                tmr_movement.Stop();
                MessageBox.Show("Congratulations you beat level 3!");
                Level4 level4 = new Level4();
                level4.Show();
                this.Visible = false;
            }
        }