Exemplo n.º 1
0
        //Cria pedestres
        private void Pedestres()
        {
            Pedestre p = new Pedestre(ref pbPedestre1, 662, ref osVermelho1);

            p.MovDireita();

            Pedestre p2 = new Pedestre(ref pbPedestre3, 662, ref osVermelho1);

            p2.MovDireita();

            Pedestre p3 = new Pedestre(ref pbPedestre2, 400, ref osVermelho2);

            p3.MovBaixo();

            Pedestre p4 = new Pedestre(ref pbPedestre4, 400, ref osVermelho2);

            p4.MovBaixo();
        }
Exemplo n.º 2
0
        //evento a ser adicionado
        private void Evento1Direita(object sender, EventArgs e)
        {
            Timer t = sender as Timer;

            //Verifica se a posicao atual ainda esta no plano
            if (Veiculo.Location.X < Caminho.Size.Width)
            {
                //Verifica se o sinal esta fechado e se algum pedestre esta atravessando
                if (Veiculo.Location.X + Veiculo.Size.Width > Linha.X1 - 2 && Veiculo.Location.X + Veiculo.Size.Width < Linha.X1 + 2 && (Sinal.BackColor != Color.Lime || Pedestre.PedestreAndandoBaixo() || Pedestre.PedestreAndandoCima()))
                {
                }
                else
                {
                    //Incrementa posicao X
                    Veiculo.Location = new System.Drawing.Point(Veiculo.Location.X + 3, Veiculo.Location.Y);
                }
            }
            else
            {
                Veiculo.Location = new System.Drawing.Point(PosXInicial, PosYInicial);      //Volta para posicao inicial
            }
        }
Exemplo n.º 3
0
        //evento a ser adicionado
        private void Evento4Baixo(object sender, EventArgs e)
        {
            Timer t = sender as Timer;

            //Verifica se a posicao atual ainda esta no plano
            if (Veiculo.Location.Y < Caminho.Size.Height)
            {
                //Verifica se o sinal esta fechado e se algum pedestre esta atravessando
                if (Veiculo.Location.Y + Veiculo.Size.Height > Linha.Y1 - 2 && Veiculo.Location.Y + Veiculo.Size.Height < Linha.Y1 + 2 && (Sinal.BackColor != Color.Lime || Pedestre.PedestreAndandoDireita() || Pedestre.PedestreAndandoEsquerda()))
                {
                }
                else
                {
                    //Incrementa posicao Y
                    Veiculo.Location = new System.Drawing.Point(Veiculo.Location.X, Veiculo.Location.Y + 3);
                }
            }
            else
            {
                Veiculo.Location = new System.Drawing.Point(PosXInicial, PosYInicial);  //Volta para posicao inicial
            }
        }