Exemplo n.º 1
0
        private void button4_Click(object sender, EventArgs e)
        {
            Sounds.Klik.Play();
            this.Visible = false;
            var myForm = new Splash_Screen();

            myForm.Show();
        }
Exemplo n.º 2
0
 void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         this.Visible = false;
         var myForm = new Splash_Screen();
         myForm.Show();
     }
     foreach (Car car in cars)
     {
         car.handleKeyDownEvent(e);
     }
 }
Exemplo n.º 3
0
        void Draw(Graphics g)
        {
            int CarIndex = 1;

            Rectangle[] carBoxes = new Rectangle[] {
                new Rectangle(cars[0].getPosition().X, cars[0].getPosition().Y, cars[0].getImage().Width, cars[0].getImage().Height),
                new Rectangle(cars[1].getPosition().X, cars[1].getPosition().Y, cars[1].getImage().Width, cars[1].getImage().Height)
            };


            for (int i = 0; i < cars.Count; i++)
            {
                Car car = cars[i];
                //Start checkpoint code en fuel code
                car.checkpointCount();
                car.AmountFuel();

                //Checkpoint displays
                //String drawCheck1 = "1: " + car.check1;
                //DrawString(g, drawCheck1, 10, 40 * CarIndex);

                //String drawCheck2 = "2: " + car.check2;
                //DrawString(g, drawCheck2, 100, 40 * CarIndex);

                //String drawCheck3 = "3: " + car.check3;
                //DrawString(g, drawCheck3, 200, 40 * CarIndex);

                //String drawFinish = "Finish: " + car.finish;
                //DrawString(g, drawFinish, 300, 40 * CarIndex);

                if (cars[0].laps > 3 && cars[0].pitCount > 0)
                {
                    cars[0].laps     = 1;
                    cars[0].pitCount = 0;
                    Sounds.Finish.PlaySync();
                    System.Threading.Thread.Sleep(200);
                    Sounds.Player2Win.PlaySync();
                    System.Threading.Thread.Sleep(200);
                    Sounds.Victory.Play();
                    System.Threading.Thread.Sleep(2000);
                    this.Visible = false;
                    var myForm = new Splash_Screen();
                    myForm.Show();
                }

                if (cars[1].laps > 3 && cars[1].pitCount > 0)
                {
                    cars[1].laps     = 1;
                    cars[1].pitCount = 0;
                    Sounds.Finish.PlaySync();
                    System.Threading.Thread.Sleep(200);
                    Sounds.Player1Win.PlaySync();
                    System.Threading.Thread.Sleep(200);
                    Sounds.Victory.Play();
                    System.Threading.Thread.Sleep(2000);
                    this.Visible = false;
                    var myForm = new Splash_Screen();
                    myForm.Show();
                }

                if (Map == 1)
                {
                    //Showplayer
                    if (CarIndex == 2)
                    {
                        String DrawPlayer = "Player 1: ";
                        DrawString(g, DrawPlayer, 12, 12);
                    }
                    if (CarIndex == 1)
                    {
                        String DrawPlayer = "Player 2: ";
                        DrawString(g, DrawPlayer, 12, 142);
                    }

                    //ShowSpeed
                    if (CarIndex == 2)
                    {
                        String drawSpeed = "Speed: " + Math.Round(car.speed * 45) + "km/u";
                        DrawString(g, drawSpeed, 12, 32);
                    }
                    if (CarIndex == 1)
                    {
                        String drawSpeed = "Speed: " + Math.Round(car.speed * 45) + "km/u";
                        DrawString(g, drawSpeed, 12, 162);
                    }

                    //ShowLaps
                    if (CarIndex == 2)
                    {
                        String drawLaps = "Lap: " + car.laps + "/3";
                        DrawString(g, drawLaps, 12, 52);
                    }
                    if (CarIndex == 1)
                    {
                        String drawLaps = "Lap: " + car.laps + "/3";
                        DrawString(g, drawLaps, 12, 182);
                    }

                    //ShowFuel
                    if (CarIndex == 2)
                    {
                        String drawFuel = "Fuel: " + Math.Round(car.fuel);
                        DrawString(g, drawFuel, 12, 72);
                    }
                    if (CarIndex == 1)
                    {
                        String drawFuel = "Fuel: " + Math.Round(car.fuel);
                        DrawString(g, drawFuel, 12, 202);
                    }

                    //ShowPit
                    if (CarIndex == 2)
                    {
                        String drawPit = "Pits: " + car.pitCount;
                        DrawString(g, drawPit, 12, 92);
                    }
                    if (CarIndex == 1)
                    {
                        String drawPit = "Pits: " + car.pitCount;
                        DrawString(g, drawPit, 12, 222);
                    }
                }

                if (Map == 2)
                {
                    //Showplayer
                    if (CarIndex == 2)
                    {
                        String DrawPlayer = "Player 1: ";
                        DrawString(g, DrawPlayer, 690, 620);
                    }
                    if (CarIndex == 1)
                    {
                        String DrawPlayer = "Player 2: ";
                        DrawString(g, DrawPlayer, 860, 620);
                    }

                    //ShowSpeed
                    if (CarIndex == 2)
                    {
                        String drawSpeed = "Speed: " + Math.Round(car.speed * 45) + "km/u";
                        DrawString(g, drawSpeed, 690, 642);
                    }
                    if (CarIndex == 1)
                    {
                        String drawSpeed = "Speed: " + Math.Round(car.speed * 45) + "km/u";
                        DrawString(g, drawSpeed, 860, 642);
                    }

                    //ShowLaps
                    if (CarIndex == 2)
                    {
                        String drawLaps = "Lap: " + car.laps + "/3";
                        DrawString(g, drawLaps, 690, 664);
                    }
                    if (CarIndex == 1)
                    {
                        String drawLaps = "Lap: " + car.laps + "/3";
                        DrawString(g, drawLaps, 860, 664);
                    }

                    //ShowFuel
                    if (CarIndex == 2)
                    {
                        String drawFuel = "Fuel: " + Math.Round(car.fuel);
                        DrawString(g, drawFuel, 690, 686);
                    }
                    if (CarIndex == 1)
                    {
                        String drawFuel = "Fuel: " + Math.Round(car.fuel);
                        DrawString(g, drawFuel, 860, 686);
                    }

                    //ShowPit
                    if (CarIndex == 2)
                    {
                        String drawPit = "Pits: " + car.pitCount;
                        DrawString(g, drawPit, 690, 708);
                    }
                    if (CarIndex == 1)
                    {
                        String drawPit = "Pits: " + car.pitCount;
                        DrawString(g, drawPit, 860, 708);
                    }
                }
                if (Map == 3)
                {
                    //Showplayer
                    if (CarIndex == 2)
                    {
                        String DrawPlayer = "Player 1: ";
                        DrawString(g, DrawPlayer, 12, 640);
                    }
                    if (CarIndex == 1)
                    {
                        String DrawPlayer = "Player 2: ";
                        DrawString(g, DrawPlayer, 182, 640);
                    }

                    //ShowSpeed
                    if (CarIndex == 2)
                    {
                        String drawSpeed = "Speed: " + Math.Round(car.speed * 45) + "km/u";
                        DrawString(g, drawSpeed, 12, 662);
                    }
                    if (CarIndex == 1)
                    {
                        String drawSpeed = "Speed: " + Math.Round(car.speed * 45) + "km/u";
                        DrawString(g, drawSpeed, 182, 662);
                    }

                    //ShowLaps
                    if (CarIndex == 2)
                    {
                        String drawLaps = "Lap: " + car.laps + "/3";
                        DrawString(g, drawLaps, 12, 684);
                    }
                    if (CarIndex == 1)
                    {
                        String drawLaps = "Lap: " + car.laps + "/3";
                        DrawString(g, drawLaps, 182, 684);
                    }

                    //ShowFuel
                    if (CarIndex == 2)
                    {
                        String drawFuel = "Fuel: " + Math.Round(car.fuel);
                        DrawString(g, drawFuel, 12, 706);
                    }
                    if (CarIndex == 1)
                    {
                        String drawFuel = "Fuel: " + Math.Round(car.fuel);
                        DrawString(g, drawFuel, 182, 706);
                    }

                    //ShowPit
                    if (CarIndex == 2)
                    {
                        String drawPit = "Pits: " + car.pitCount;
                        DrawString(g, drawPit, 12, 728);
                    }
                    if (CarIndex == 1)
                    {
                        String drawPit = "Pits: " + car.pitCount;
                        DrawString(g, drawPit, 182, 728);
                    }
                }

                //Zet middelpunt van auto
                float moveX = car.getImage().Width / 2f + car.getPosition().X;
                float moveY = car.getImage().Height / 2f + car.getPosition().Y;
                g.TranslateTransform(moveX, moveY);
                g.RotateTransform(car.getRotation());
                g.TranslateTransform(-moveX, -moveY);

                //g.DrawRectangle(Pens.Red, carBoxes[i]);

                if (carBoxes[0].IntersectsWith(carBoxes[1]))
                {
                    car.speed = 2;
                }

                //Draw de auto
                g.DrawImage(car.getImage(), car.getPosition().X, car.getPosition().Y);
                g.ResetTransform();
                CarIndex++;

                //Coords van auto
                //String drawPos = "X: " + car.getPosition().X + " Y:" + car.getPosition().Y;
                //DrawString(g, drawPos, car.getPosition().X + 20, car.getPosition().Y + 20);
            }
        }