Exemplo n.º 1
0
        private void Bucle_Tick(object sender, EventArgs e)
        {
            g.Clear(Color.White);
            cabeza.dibujar(g);
            comida.dibujar(g);
            comida2.dibujar(g);
            Movimiento();
            ChoqueCuerpo();
            ChoquePared();
            if (cabeza.interseccion(comida))
            {
                comida.colocar();
                cabeza.meter();
                puntaje++;
                Puntos.Text = puntaje.ToString();
            }

            if (cabeza.interseccion(comida2))
            {
                comida2.colocar();
                cabeza.meter();
                puntaje++;
                Puntos.Text = puntaje.ToString();
            }

            if (puntaje > rapidez)
            {
                if (bucle.Interval > 20)
                {
                    bucle.Interval = bucle.Interval - 20;
                    rapidez        = rapidez + 5;
                }
            }
        }
Exemplo n.º 2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (!gameOver)
            {
                label1.Text = "Score: " + Convert.ToString(score);
                x          += dirx;
                y          += diry;
                if (((x < 0 || x > 59) || (y < 0 || y > 44)) && !godmode)
                {
                    gameOver = true;
                }
                if (check_collision(x, y, objetos) && !godmode)
                {
                    gameOver = true;
                }
                objetos[0].Add(new Comida(x, y, rand));

                foreach (List <Comida> objeto in objetos)
                {
                    foreach (Comida parte in objeto)
                    {
                        parte.dibujar(papel);
                    }
                }

                bit.dibujar(papel);

                move();
                if (score >= 5 && level == 1)
                {
                    for (int i = 0; i < rand.Next(3, 4); i++)
                    {
                        objetos.Add(add_obstaculo());
                    }
                    level = 2;
                }
                if (score >= 10 && score != 4)
                {
                    timer1.Interval = speed - (score - 5) * 2;
                    level           = 3;
                }

                if (score >= 15)
                {
                    level = 4;
                }
            }
            else
            {
                timer1.Stop();
                button_Pausa.Hide();
                button_start.Show();
                checkBox1.Show();
                textBox1.Show();
                label2.Show();
                papel.DrawEllipse(new Pen(Color.Red, 2), x * bit.size - 7, y * bit.size - 7, bit.size + 15, bit.size + 15);
                papel.DrawString("Game Over", new Font("Arial", 50), new SolidBrush(Color.Yellow), new PointF(120, 180));
            }
        }
Exemplo n.º 3
0
 private void Bucle_Tick(object sender, EventArgs e)
 {
     g.Clear(Color.White);
     cabeza.dibujar(g);
     comida.dibujar(g);
     movimiento();
     choquecuerpo();
     choquepared();
     if (cabeza.interseccion(comida))
     {
         comida.colocar();
         cabeza.metieron();
         punto++;
         puntos.Text = punto.ToString();
     }
 }
Exemplo n.º 4
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     g.Clear(Color.White);
     cabeza.dibujar(g);
     comida.dibujar(g);
     movimiento();
     if (cabeza.interseccion(comida))
     {
         comida.colocar();
         cabeza.meter();
         puntaje++;
         puntos.Text = puntaje.ToString();
     }
     choquedeljuego();
     choquePared();
 }
Exemplo n.º 5
0
        private void bucle_Tick(object sender, EventArgs e)
        {
            g.Clear(Color.White);
            cabeza.dibujar(g);
            comida.dibujar(g);
            movimiento();
            choquecuerpo();
            choquePared();
            velocidad();
            bucle.Interval = tiempo;

            if (cabeza.interseccion(comida))
            {
                comida.colocar();
                cabeza.meter();
                puntaje++;
                puntos.Text = puntaje.ToString();
            }
        }