/// <summary> /// Creates a new SnowDrift to fit the indicated screen size. /// </summary> /// <param name="screenSize">Size of the screen to fill with snowflakes.</param> public SnowDrift(Size screenSize) { // Add in enough room so that snowflakes can drift off screen without just flashing away screenSize.Width += (int)SnowFlake.FLAKE_SIZES.Max() * 2; screenSize.Height += (int)SnowFlake.FLAKE_SIZES.Max() * 2; this.screenSize = screenSize; // Create a black and white buffer based on the adjusted screen sized nextBuffer = new Interactive8BitImage(screenSize.Width, screenSize.Height, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); nextBuffer.SetAlpha(byte.MaxValue); renderedScene = new Interactive8BitImage(screenSize.Width, screenSize.Height, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); renderedScene.SetAlpha(byte.MaxValue); // Create the wind variations generalDirection = new Vector(Random.Float(-3.5f, 3.5f), Random.Float(1, 2.5f)); Vector variance = new Vector(8, 3); windVariations = new WindField[60]; for (int i = 0; i < windVariations.Length; i++) { windVariations[i] = new WindField(screenSize.Width, screenSize.Height, generalDirection, variance, new Size(15, 15)); } snowflakes = new HashSet <SnowFlake>(Properties.Settings.Default.MaximumNumberOfFlakes); }
/// <summary> /// Creates a new snowflake. /// </summary> /// <param name="position">New position for the snowflake to be located at.</param> /// <param name="velocity">New direction and speed for the snowflake to be moving.</param> /// <param name="inertia">Inertia or how heavy teh snowflake is and resistant to changing direction.</param> /// <param name="activeField">Wiendfield that is actively blowing this snowflake.</param> /// <param name="flakeSize">Size of this flake.</param> public SnowFlake(Vector position, Vector velocity, short inertia, WindField activeField, short flakeSize) { // Initialize this snowfalke this.size = flakeSize; ReInit(position, velocity, inertia); this.activeWindField = activeField; // Create the snowflake trail for (int i = 0; i < Properties.Settings.Default.TrailLength; i++) { trail.AddLast(new Point((int)position.x, (int)position.y)); } }