Exemple #1
0
        private void IniciaValores()
        {
            //Instanciando com valores 0 em 'ordem'
            for (int i = 0; i < 4; i++)
            {
                ordem[i] = new Fila();
                for (int j = 0; j < ordem[i].GetMaxElemt(); j++)
                {
                    ordem[i].Insere(0, ref deuCerto);
                }
            }

            //Instanciando com os valores 0 em 'desenhos'
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    desenhos[i, j] = 0;
                }
            }

            //Instanciando com os valores 0 em 'arvores'
            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    arvores[i, j] = 0;
                }
            }

            fundo            = "capa";
            stagio           = "menu";
            pause            = false;
            esquerda         = false;
            direita          = false;
            controleEntradas = false;
            disparo          = false;
            score            = 0;
            auxMovimento     = 0;
            auxArvore        = 0;
            auxExplosion     = 0;
            auxLaser         = 0;
            posXLaser        = 0;
            cargasLaser      = 1;
            auxTempo         = 0;
            tam[0]           = 0;
            tam[1]           = 0;
            tam[2]           = 850;
            tam[3]           = 650;
            tamArvores[0]    = 50;
            tamArvores[1]    = 120;
            tamArvores[2]    = 800;
            tamArvores[3]    = 710;
            Player           = new Carro(carroEscolhido);
            PlayGround.LimpaTela();
            PlayGround.Desenha(fundo, tam[0], tam[1], tam[2], tam[3]);
            explosion.Stop();
            music.Play();
        }
Exemple #2
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            Keys tecla = e.KeyData;

            if (tecla == Keys.P && stagio == "inGame")
            {
                if (!pause)
                {
                    music.Stop();
                    pause                = true;
                    Pause.Text           = "PAUSE";
                    Pause.ForeColor      = System.Drawing.Color.Red;
                    Pause.Location       = new Point(425 - 93, 300 - 50);
                    Pause.Size           = new System.Drawing.Size(200, 200);
                    Pause.Visible        = true;
                    timer_pontua.Enabled = false;
                }
                else
                {
                    music.Play();
                    pause                = false;
                    Pause.Visible        = false;
                    timer_pontua.Enabled = true;
                }
            }
            if (tecla == Keys.Down && stagio != "menu")
            {
                if (stagio == "colissao")
                {
                    //Instanciando com valores 0 em 'ordem'
                    for (int i = 0; i < 4; i++)
                    {
                        ordem[i] = new Fila();
                        for (int j = 0; j < ordem[i].GetMaxElemt(); j++)
                        {
                            ordem[i].Insere(0, ref deuCerto);
                        }
                    }

                    //Instanciando com os valores 0 em 'desenhos'
                    for (int i = 0; i < 5; i++)
                    {
                        for (int j = 0; j < 4; j++)
                        {
                            desenhos[i, j] = 0;
                        }
                    }

                    //Instanciando com os valores 0 em 'arvores'
                    for (int i = 0; i < 7; i++)
                    {
                        for (int j = 0; j < 4; j++)
                        {
                            arvores[i, j] = 0;
                        }
                    }

                    pause            = false;
                    esquerda         = false;
                    direita          = false;
                    controleEntradas = false;
                    disparo          = false;
                    score            = 0;
                    auxMovimento     = 0;
                    auxArvore        = 0;
                    auxExplosion     = 0;
                    auxLaser         = 0;
                    posXLaser        = 0;
                    cargasLaser      = 1;
                    auxTempo         = 0;
                    tam[0]           = 0;
                    tam[1]           = 0;
                    tam[2]           = 850;
                    tam[3]           = 650;
                    tamArvores[0]    = 50;
                    tamArvores[1]    = 120;
                    tamArvores[2]    = 800;
                    tamArvores[3]    = 710;
                    Player           = new Carro(carroEscolhido);
                    DesativaInterfaces();
                    stagio = "inGame";
                    fundo  = "Rua";
                    tam[0] = 175;
                    tam[1] = 0;
                    tam[2] = 500;
                    tam[3] = 1000;
                    explosion.Stop();
                    music.Play();
                    Pause.Visible        = false;
                    timer1.Enabled       = true;
                    timer_pontua.Enabled = true;
                }
                else
                {
                    IniciaValores();
                    HabilitaInterfaces();
                    timer1.Enabled         = false;
                    timer_pontua.Enabled   = false;
                    timer_explosao.Enabled = false;
                    Pause.Visible          = false;
                }
            }
            if (tecla == Keys.Right && !controleEntradas && stagio == "inGame")
            {
                direita          = true;
                controleEntradas = true;
                this.KeyPreview  = false;
            }
            if (tecla == Keys.Left && !controleEntradas && stagio == "inGame")
            {
                esquerda         = true;
                controleEntradas = true;
                this.KeyPreview  = false;
            }
            if (tecla == Keys.Up && !disparo && stagio == "inGame" && cargasLaser > 0)
            {
                cima    = true;
                disparo = true;
            }
        }