Esempio n. 1
0
        public Partida()
        {
            InitializeComponent();
            dateTimePicker1.Enabled = false;
            timer1.Start();
            timer1.Interval = 1000;
            string DatoTime = dateTimePicker1.Value.ToString();

            string[] trozos = DatoTime.Split(' ');
            HoraInicial = trozos[1];

            agar           = new agario(ag_x, ag_y, ag_vol);
            obs            = new ListaObst(pictureBox1.Width, pictureBox1.Height, max_volume_obs, num_obst);
            g              = pictureBox1.CreateGraphics();
            timer2.Enabled = true;
        }
Esempio n. 2
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            g.Clear(Color.White);
            obs.graphs(g);
            agar.graph(g);
            mover();
            int i = 0;

            while (i < obs.GetNum())
            {
                if (agar.colision(obs.GetOB(i)) == 1)
                {
                    int v = obs.GetOB(i).GetV();
                    puntos = puntos + v;
                    obs.borrar(obs.GetOB(i));
                    agar.comer(pictureBox1.Width, pictureBox1.Height, v);
                    puntos_lbl.Invoke(new DelegadoParaPonerTexto(PonPuntos), new Object[] { Convert.ToString(puntos) });
                }
                i++;
            }

            if (obs.GetNum() == 0)
            {
                x      = 0;
                y      = 0;
                puntos = 0;
                agar   = new agario(ag_x, ag_y, ag_vol);
                obs    = new ListaObst(pictureBox1.Width, pictureBox1.Height, max_volume_obs, num_obst);
                timer1.Stop();


                //Enviar datos de partida
                string   DatoTime = dateTimePicker1.Value.ToString();
                string[] trozos   = DatoTime.Split(' ');
                fecha = trozos[0];

                HoraFinal = DateTime.Now.ToString("HH:mm:ss");
                this.time = Convert.ToInt32(timelbl.Text);



                string mensaje = "13/" + cont + "-" + fecha + "-" + HoraFinal + "-" + time + "-" + usuario;
                byte[] msg     = System.Text.Encoding.ASCII.GetBytes(mensaje);
                server.Send(msg);
            }
        }