Пример #1
0
 private void Form1_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (char.ToUpper(e.KeyChar) == 'P')
     {
         if (flag)
         {
             label2.Visible = true;
             RoadMover.Stop();
             Right_mover.Stop();
             Left_mover.Stop();
             enemy1_mover.Stop();
             enemy2_mover.Stop();
             enemy3_mover.Stop();
             enemy4_mover.Stop();
             flag = false;
         }
         else
         {
             label2.Visible = false;
             RoadMover.Start();
             Right_mover.Start();
             Left_mover.Start();
             enemy1_mover.Start();
             enemy2_mover.Start();
             enemy3_mover.Start();
             enemy4_mover.Start();
             flag = true;
         }
     }
 }
Пример #2
0
 private void gameOver()
 {
     label1.Visible = true;
     RoadMover.Stop();
     Right_mover.Stop();
     Left_mover.Stop();
     enemy1_mover.Stop();
     enemy2_mover.Stop();
     enemy3_mover.Stop();
     enemy4_mover.Stop();
 }
Пример #3
0
 private void Consultas_KeyUp(object sender, KeyEventArgs e)
 {
     Right_mover.Stop();
     Left_mover.Stop();
 }
Пример #4
0
        //--------------------------------------------------------------------------------
        //-------------------------------- ROAD GAME -------------------------------------
        //--------------------------------------------------------------------------------
        private void RoadMover_Tick(object sender, EventArgs e)
        {
            //--------------------------- ROAD MOVEMENT ----------------------------------
            for (int i = 0; i < road.Length; i++)
            {
                road[i].Top += speed;
                if (road[i].Top >= ActiveForm.Height)
                {
                    road[i].Top = -road[i].Height;
                }
            }

            //-------------------------- SPEED INCREMENT ---------------------------------
            if (score > level2 && score <= level3)
            {
                speed = 5;
                level = 2;
            }
            if (score > level3 && speed <= speedToNextArea)
            {
                speed++;
                level = 3;
                Score_Timer.Stop();
                Enemy1_Mover.Stop();
                Enemy2_Mover.Stop();
                Enemy3_Mover.Stop();
                Coin1_Mover.Stop();
                Coin2_Mover.Stop();
                Coin3_Mover.Stop();
                Left_mover.Stop();
                Right_mover.Stop();
                EnemyCar1.Visible = false;
                EnemyCar2.Visible = false;
                EnemyCar3.Visible = false;
                Coin1.Visible     = false;
                Coin2.Visible     = false;
                Coin3.Visible     = false;
                Grandpa_Mover.Start();
                GrandpaCar.Visible = true;
            }

            //---------------------------- COOKIE START ----------------------------------
            if (score > cookiesSpawn && score <= level3)
            {
                Coin1.Visible = true;
                Coin2.Visible = true;
                Coin3.Visible = true;
                Coin1_Mover.Start();
                Coin2_Mover.Start();
                Coin3_Mover.Start();
            }

            //------------------ SHOWS LEVEL --------------------------------------------
            Level_Text.Text = $"Level {level}";

            //------------------------- CAR INTERSECTS ----------------------------------
            if (Car.Bounds.IntersectsWith(EnemyCar1.Bounds))
            {
                GameOver();
            }
            if (Car.Bounds.IntersectsWith(EnemyCar2.Bounds))
            {
                GameOver();
            }
            if (Car.Bounds.IntersectsWith(EnemyCar3.Bounds))
            {
                GameOver();
            }

            //----------------------------- COIN INTERSECTS -----------------------------
            if (Car.Bounds.IntersectsWith(Coin1.Bounds))
            {
                coins++;
                score          += pointsPerCookie;
                Coins_Text.Text = $"Cookies {coins}";
                Score_Text.Text = $"Score {score:#,###}";
                int x = (int)Math.Ceiling(rnd.NextDouble() * coinsX);
                int y = 0;
                Coin1.Location = new Point(x, y);
            }
            if (Car.Bounds.IntersectsWith(Coin2.Bounds))
            {
                coins++;
                score          += pointsPerCookie;
                Coins_Text.Text = $"Cookies {coins}";
                Score_Text.Text = $"Score {score:#,###}";
                int x = (int)Math.Ceiling(rnd.NextDouble() * coinsX);
                int y = 0;
                Coin2.Location = new Point(x, y);
            }
            if (Car.Bounds.IntersectsWith(Coin3.Bounds))
            {
                coins++;
                score          += pointsPerCookie;
                Coins_Text.Text = $"Cookies {coins}";
                Score_Text.Text = $"Score {score:#,###}";
                int x = (int)Math.Ceiling(rnd.NextDouble() * coinsX);
                int y = 0;
                Coin3.Location = new Point(x, y);
            }
        }
Пример #5
0
 private void Form1_KeyUp(object sender, KeyEventArgs e)
 {
     Right_mover.Stop();
     Left_mover.Stop();
 }