コード例 #1
0
        /// <summary>
        /// this just pulls for mouse clicks and spawns sand if their holding the mouse down
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer_Tick(object sender, EventArgs e)
        {
            Point p;

            if (_Canvas != null && _Canvas.GetLastMouseLeftClickScaled(out p))
            {
                for (int i = 0; i < trackBarBrushSize.Value; i++)
                {
                    try
                    {
                        sandArray[p.X, p.Y]         = _Selected_Type;
                        sandArray[p.X + i, p.Y]     = _Selected_Type;
                        sandArray[p.X, p.Y + i]     = _Selected_Type;
                        sandArray[p.X - i, p.Y]     = _Selected_Type;
                        sandArray[p.X, p.Y - i]     = _Selected_Type;
                        sandArray[p.X + i, p.Y + i] = _Selected_Type;
                        sandArray[p.X - i, p.Y + i] = _Selected_Type;
                        sandArray[p.X - i, p.Y - i] = _Selected_Type;
                        sandArray[p.X + i, p.Y - i] = _Selected_Type;
                    }
                    catch
                    {
                        //lol
                    }
                }
                last_coords = p;
            }
            if (_Canvas != null && _Canvas.GetMouseDown())
            {
                _Canvas.GetLastMousePositionScaled(out last_coords);
                for (int i = 0; i < trackBarBrushSize.Value; i++)
                {
                    try
                    {
                        //v shit way to draw a bunch of sand. throws when trying to draw off screen
                        sandArray[last_coords.X, last_coords.Y]         = _Selected_Type;
                        sandArray[last_coords.X + i, last_coords.Y]     = _Selected_Type;
                        sandArray[last_coords.X, last_coords.Y + i]     = _Selected_Type;
                        sandArray[last_coords.X - i, last_coords.Y]     = _Selected_Type;
                        sandArray[last_coords.X, last_coords.Y - i]     = _Selected_Type;
                        sandArray[last_coords.X + i, last_coords.Y + i] = _Selected_Type;
                        sandArray[last_coords.X - i, last_coords.Y + i] = _Selected_Type;
                        sandArray[last_coords.X - i, last_coords.Y - i] = _Selected_Type;
                        sandArray[last_coords.X + i, last_coords.Y - i] = _Selected_Type;
                    }
                    catch
                    {
                        //lol
                    }
                }
            }
        }