All pastes #943348 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-03-15 05:12 UTC
rendered paste body
  public void Update()
        {
            _oldMouseState = _currentMouseState;
            _currentMouseState = Mouse.GetState();
            _cursorPosition.X = _currentMouseState.X;
            _cursorPosition.Y = _currentMouseState.Y;

            if ( _currentMouseState.LeftButton == ButtonState.Pressed &&
                 _oldMouseState.LeftButton == ButtonState.Released )
            {
                _isSelectionRectangleVisiible = true;
                _startRectPoint.X = _oldMouseState.X;
                _startRectPoint.Y = _oldMouseState.Y;
                CalculateSelectionRectangle();
            }

            else if ( _currentMouseState.LeftButton == ButtonState.Pressed &&
                      _oldMouseState.LeftButton == ButtonState.Pressed )
            {
                _isSelectionRectangleVisiible = true;
                CalculateSelectionRectangle();
            }
            else
            {
                _startRectPoint.X = _currentMouseState.X;
                _startRectPoint.Y = _currentMouseState.Y;
                _isSelectionRectangleVisiible = false;
            }

.......
}


     void CalculateSelectionRectangle()
        {
                _selectionRectangle =
                    new Rectangle( (int) _startRectPoint.X, (int) _startRectPoint.Y,
                                   _currentMouseState.X - (int) _startRectPoint.X,
                                   _currentMouseState.Y - (int) _startRectPoint.Y );
        }



       public void Draw(SpriteBatch sb)
        {
            if (_isSelectionRectangleVisiible)
            {
                sb.Draw( _selectionRectangletexture,_selectionRectangle,new Rectangle(0,0,_selectionRectangletexture.Width,_selectionRectangletexture.Height),Color.Green);
            }
....
}