Exemplo n.º 1
0
            public StarPoint(Rectangle drawLimits, StarPointCollection owner)
            {
                this._drawBounds = drawLimits;
                int xCen = _drawBounds.Width / 2, yCen = _drawBounds.Height / 2;

                Random rnd;

                if (owner != null)
                {
                    this._owner = owner;
                    rnd         = _owner.Rnd;
                }
                else
                {
                    rnd = new Random();
                }

                while (_xPos == 0 || _xPos == xCen || (_xPos > xCen - 5 && _xPos < xCen + 5))
                {
                    this._xPos = rnd.Next(drawLimits.Width);
                }
                while (_yPos == 0 || _yPos == yCen || (_yPos > yCen - 5 && _yPos < yCen + 5))
                {
                    this._yPos = rnd.Next(drawLimits.Height);
                }
                this._xSpd  = (_xPos - xCen) / 2;
                this._ySpd  = (_yPos - yCen) / 2;
                this._steps = 0;
            }
Exemplo n.º 2
0
 //***************************************************************************
 // Private Methods
 //
 private void InitStarfield()
 {
     if (this._starCol == null)
     {
         this._starCol = new StarPointCollection();
     }
     _starCol.Clear();
     for (int i = 0; i < _starCount; i++)
     {
         _starCol.Add(new StarPoint(this.ClientRectangle, _starCol));
     }
 }
            public StarPoint(Rectangle drawLimits, StarPointCollection owner)
            {
                this._drawBounds = drawLimits;
                int xCen = _drawBounds.Width / 2, yCen = _drawBounds.Height / 2;

                Random rnd;
                if (owner != null)
                {
                    this._owner = owner;
                    rnd = _owner.Rnd;
                }
                else
                    rnd = new Random();

                while (_xPos == 0 || _xPos == xCen || (_xPos > xCen - 5 && _xPos < xCen + 5))
                    this._xPos = rnd.Next(drawLimits.Width);
                while (_yPos == 0 || _yPos == yCen || (_yPos > yCen - 5 && _yPos < yCen + 5))
                    this._yPos = rnd.Next(drawLimits.Height);
                this._xSpd = (_xPos - xCen) / 2;
                this._ySpd = (_yPos - yCen) / 2;
                this._steps = 0;
            }
 //***************************************************************************
 // Private Methods
 // 
 private void InitStarfield()
 {
     if (this._starCol == null)
         this._starCol = new StarPointCollection();
     _starCol.Clear();
     for (int i = 0; i < _starCount; i++)
         _starCol.Add(new StarPoint(this.ClientRectangle, _starCol));
 }