示例#1
0
        public Carro(Transito transito, Posicao posicao)
        {
            this.t = transito;

            car          = new PictureBox();
            car.Location = new System.Drawing.Point(posicao.x, posicao.y);
            car.Size     = new System.Drawing.Size(tamanho, tamanho);

            Random r   = new Random();
            int    cor = r.Next(1, 4);

            if (cor == 1)
            {
                car.Image = testes.Properties.Resources.amarelo;
            }
            else if (cor == 2)
            {
                car.Image = testes.Properties.Resources.azul;
            }
            else
            {
                car.Image = testes.Properties.Resources.vermelho;
            }

            car.BackColor = System.Drawing.Color.Transparent;


            car.SizeMode = PictureBoxSizeMode.Zoom;
            t.form.Controls.Add(car);
            definir_sentido(posicao.sentido);
        }
示例#2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            t = new Transito(this);

            //Adicionar Pontos de entrada de carros
            t.pontos.Add(new Posicao(814, 165, AnchorStyles.Left));
            t.pontos.Add(new Posicao(-80, 255, AnchorStyles.Right));
            t.pontos.Add(new Posicao(320, -80, AnchorStyles.Bottom));
            t.pontos.Add(new Posicao(420, 488, AnchorStyles.Top));

            t.gerenciador.addSemafaro(semBaixo, barBaixo, new Point(410, 310), new Point(500, 500), new Point(410, 310), new Point(500, 335));
            t.gerenciador.addSemafaro(semCima, barCima, new Point(300, 0), new Point(390, 160), new Point(300, 130), new Point(390, 160));
            t.gerenciador.addSemafaro(semDireita, barDireita, new Point(500, 160), new Point(810, 225), new Point(500, 160), new Point(530, 225));
            t.gerenciador.addSemafaro(semEsquerda, barEsquerda, new Point(0, 245), new Point(295, 313), new Point(260, 250), new Point(296, 310));

            t.gerenciador.iniciar();
            t.iniciar();
        }