Exemplo n.º 1
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     sec           = sec - 1;
     SecLabel.Text = sec.ToString();
     if (sec == 0)
     {
         timer1.Enabled   = false;
         StudentHero.Left = 95;
         StudentHero.Top  = 50;
         this.Hide();
         var GameOver = new GameOver();
         GameOver.Closed += (s, args) => this.Close();
         GameOver.Show();
         sec   = 60;
         lifes = 3;
     }
 }
Exemplo n.º 2
0
        private void Form_KeyDown(object sender, KeyEventArgs e)
        {
            int x = StudentHero.Location.X;
            int y = StudentHero.Location.Y;

            if (e.KeyCode == Keys.Right)
            {
                x += 10;
            }
            else if (e.KeyCode == Keys.Left)
            {
                x -= 10;
            }
            else if (e.KeyCode == Keys.Up)
            {
                y -= 10;
            }
            else if (e.KeyCode == Keys.Down)
            {
                y += 10;
            }

            StudentHero.Location = new Point(x, y);

            if (StudentHero.Bounds.IntersectsWith(pictureBox1.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox2.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox3.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox4.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox5.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox6.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox7.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox8.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox9.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox10.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox11.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox12.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox13.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox14.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox15.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox16.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox17.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox18.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox19.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox20.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox21.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox22.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox23.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox24.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox25.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox26.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox27.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox28.Bounds))
            {
                StudentHero.Left = 47;
                StudentHero.Top  = 72;
                lifes           -= 1;
                sec             = 60;
                SecLabel.Text   = sec.ToString();
                LifesLabel.Text = lifes.ToString();
            }

            if (StudentHero.Bounds.IntersectsWith(FinishLabel.Bounds))
            {
                this.Hide();
                var YouWon = new YouWon();
                YouWon.Closed += (s, args) => this.Close();
                YouWon.Show();
            }

            if (lifes <= 0)
            {
                this.Hide();
                var GameOver = new GameOver();
                GameOver.Closed += (s, args) => this.Close();
                GameOver.Show();
            }
        }
Exemplo n.º 3
0
        private void LevelMichael_KeyDown(object sender, KeyEventArgs key)
        {
            int x = StudentHero.Location.X;
            int y = StudentHero.Location.Y;

            if (key.KeyCode == Keys.Right)
            {
                x += 20;
            }
            else if (key.KeyCode == Keys.Left)
            {
                x -= 20;
            }
            else if (key.KeyCode == Keys.Up)
            {
                y -= 20;
            }
            else if (key.KeyCode == Keys.Down)
            {
                y += 20;
            }

            StudentHero.Location = new Point(x, y);

            if (StudentHero.Bounds.IntersectsWith(pictureBox2.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox3.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox4.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox5.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox6.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox7.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox8.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox9.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox10.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox11.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox12.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox13.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox14.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox15.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox16.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox17.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox18.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox19.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox20.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox21.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox22.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox23.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox24.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox25.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox26.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox27.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox28.Bounds))
            {
                pictureBox1.Left = 95;
                pictureBox1.Top  = 50;
                lifes           -= 1;
                LifesLabel.Text  = lifes.ToString();
            }

            //TODO: implement next Level StartUp
            //if (StudentHero.Bounds.IntersectsWith(FinishLabel.Bounds))
            //{
            //    this.Hide();
            //    var Level2 = new Level2();
            //    Level2.Closed += (s, args) => this.Close();
            //    Level2.Show();
            //}
            if (lifes == 0 || StudentHero.Bounds.IntersectsWith(TrapLabel.Bounds))
            {
                this.Hide();
                var GameOver = new GameOver();
                GameOver.Closed += (s, args) => this.Close();
                GameOver.Show();
            }
        }
Exemplo n.º 4
0
        private void LevelMichael_KeyDown(object sender, KeyEventArgs key)
        {
            int x = StudentHero.Location.X;
            int y = StudentHero.Location.Y;

            if (key.KeyCode == Keys.Right)
            {
                x += 10;
            }
            else if (key.KeyCode == Keys.Left)
            {
                x -= 10;
            }
            else if (key.KeyCode == Keys.Up)
            {
                y -= 10;
            }
            else if (key.KeyCode == Keys.Down)
            {
                y += 10;
            }

            StudentHero.Location = new Point(x, y);

            if (StudentHero.Bounds.IntersectsWith(pictureBox1.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox2.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox3.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox4.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox5.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox6.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox7.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox8.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox9.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox10.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox12.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox13.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox14.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox15.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox16.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox17.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox18.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox19.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox20.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox21.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox22.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox23.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox24.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox25.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox26.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox27.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox28.Bounds))
            {
                StudentHero.Left = 3;
                StudentHero.Top  = 30;
                lifes           -= 1;
                sec             = 60;
                SecLabel.Text   = sec.ToString();
                LifesLabel.Text = lifes.ToString();
            }

            if (StudentHero.Bounds.IntersectsWith(FinishLabel.Bounds))
            {
                sec              = 60;
                lifes            = 3;
                LifesLabel.Text  = lifes.ToString();
                SecLabel.Text    = sec.ToString();
                Timer3.Enabled   = false;
                StudentHero.Left = 95;
                StudentHero.Top  = 50;
                this.Hide();
                var Level4 = new Level4();
                Level4.Closed += (s, args) => this.Close();
                Level4.Show();
            }

            if (lifes == 0)
            {
                sec             = 60;
                lifes           = 3;
                LifesLabel.Text = lifes.ToString();
                SecLabel.Text   = sec.ToString();
                Timer3.Enabled  = false;

                StudentHero.Left = 95;
                StudentHero.Top  = 50;

                this.Hide();
                var GameOver = new GameOver();
                GameOver.Closed += (s, args) => this.Close();
                GameOver.Show();
            }
        }
Exemplo n.º 5
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            int x = StudentHero.Location.X;
            int y = StudentHero.Location.Y;

            if (e.KeyCode == Keys.Right)
            {
                x += 10;
            }
            else if (e.KeyCode == Keys.Left)
            {
                x -= 10;
            }
            else if (e.KeyCode == Keys.Up)
            {
                y -= 10;
            }
            else if (e.KeyCode == Keys.Down)
            {
                y += 10;
            }

            StudentHero.Location = new Point(x, y);

            if (StudentHero.Bounds.IntersectsWith(pictureBox2.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox3.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox4.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox5.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox6.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox7.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox8.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox9.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox10.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox11.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox12.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox13.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox14.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox15.Bounds) ||
                StudentHero.Bounds.IntersectsWith(pictureBox18.Bounds))
            {
                StudentHero.Left = 95;
                StudentHero.Top  = 50;
                lifes           -= 1;
                sec             = 60;
                SecLabel.Text   = sec.ToString();
                LifesLabel.Text = lifes.ToString();
            }
            if (StudentHero.Bounds.IntersectsWith(KeyPicture.Bounds))
            {
                KeyPicture.Left      = 800;
                KeyPicture.Visible   = false;
                pictureBox18.Left    = 800;
                pictureBox18.Visible = false;
            }
            if (StudentHero.Bounds.IntersectsWith(FinishLabel.Bounds))
            {
                sec              = 60;
                lifes            = 3;
                LifesLabel.Text  = lifes.ToString();
                SecLabel.Text    = sec.ToString();
                Timer1.Enabled   = false;
                StudentHero.Left = 95;
                StudentHero.Top  = 50;
                this.Hide();
                var Level2 = new Level2();
                Level2.Closed += (s, args) => this.Close();
                Level2.Show();
            }
            if (lifes == 0)
            {
                sec              = 60;
                lifes            = 3;
                LifesLabel.Text  = lifes.ToString();
                SecLabel.Text    = sec.ToString();
                Timer1.Enabled   = false;
                StudentHero.Left = 95;
                StudentHero.Top  = 50;
                this.Hide();
                var GameOver = new GameOver();
                GameOver.Closed += (s, args) => this.Close();
                GameOver.Show();
            }
        }