Ejemplo n.º 1
0
        public MainTimer(Panel p, CheckBox ch)
        {
            timer          = new System.Windows.Forms.Timer();
            timer.Interval = 10;
            timer.Tick    += OnTickTimer;
            panel          = p;
            chbx           = ch;
            //add boxes
            BoxController b1 = new BoxController("b1", Color.Blue,
                                                 panel,
                                                 new Point(0, 0),
                                                 new Point(0, 0),
                                                 true);

            boxes.Add(b1);

            BoxController b2 = new BoxController("b2", Color.Red,
                                                 panel,
                                                 new Point(250, 250),
                                                 new Point(-1, -1),
                                                 false);

            boxes.Add(b2);

            /*  BoxController b3 = new BoxController("b3", Color.Yellow,
             * panel,
             * new Point(300, 300),
             * new Point(-1, 1),
             * false);
             * boxes.Add(b3);
             */
        }
Ejemplo n.º 2
0
        public void tRestart()
        {
            boxes.Clear();
            panel.Controls.Clear();
            BoxController b1 = new BoxController(Guid.NewGuid().ToString(), Color.Blue,
                                                 panel,
                                                 new Point(0, 0),
                                                 new Point(0, 0),
                                                 true);

            boxes.Add(b1);

            BoxController b2 = new BoxController(Guid.NewGuid().ToString(), Color.Red,
                                                 panel,
                                                 new Point(250, 250),
                                                 new Point(-1, -1),
                                                 false);

            boxes.Add(b2);

            /*   BoxController b3 = new BoxController(Guid.NewGuid().ToString(), Color.Yellow,
             *   panel,
             *   new Point(300, 300),
             *   new Point(-1, 1),
             *   false);
             * boxes.Add(b3);
             */
        }
Ejemplo n.º 3
0
        BoxController createBox(BoxController box, BoxController other, Size s)
        {
            Point         direction = box.move_directon;
            BoxController b1        = new BoxController(Guid.NewGuid().ToString(), Color.FromArgb(255, rnd.Next(255), rnd.Next(255), rnd.Next(255)),
                                                        panel,
                                                        new Point(box.current_location.X + rnd.Next(20) - 10, box.current_location.Y + rnd.Next(20) - 10),
                                                        new Point(direction.X = rnd.Next(3) - 1 * moveSpeed, direction.Y = rnd.Next(3) - 1 * moveSpeed),
                                                        true);

            b1.changeSize(s);
            return(b1);
        }