i have to create a traffic simulator, i want to move a car (picturebox) while the traffic light is not red and have it stopped when it is red, at the point of the traffic light. The traffic lights are 3 pannels changing color.
My problem is that my car does not stop when it meets the red traffic light. I have tried the "pictureBox.Location.X" and the "pictureBox.Left" but it just doesn't work, the pictureBox just goes on moving. I have also tried throwing a messageBox when the car meets the traffic light just to see if the "pictureBox.Location.X" is working but still nothing. Seems like it does not recognize the function.
I have tried to make the traffic light both with panels and pictureboxes but still the same.
Bellow i send you my code so far:
    private void timerCar1_Tick(object sender, EventArgs e)
            {
                //timerCar2.Enabled = true;
                if(panelRed.BackColor == Color.Red)
                {
                    car1.Left -= 5;
                }                
 /* ---> */     else if (car1.Location.X == panelGreen.Location.X & panelRed.BackColor == Color.Red)
                {
                    car1.Left -= 0;
                }
                else if (panelGreen.BackColor == Color.Green)
                {
                    car1.Left -= 20;
                }
                else if (panelOrange.BackColor == Color.Orange)
                {
                    car1.Left -= 10;
                }
            }