Example #1
0
        public void Instantiate(Size notUsed)
        {
            LoadUserSettings();

            this.screenSize = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size;
            animatedDrift   = new SnowDrift(this.screenSize);

            // TODO: REMOVE QUICK FILL
#if QUICK_FILL
            for (int i = 0; i < 1000; i++)
            {
                animatedDrift.AddFlakes( );
            }
#endif

            fpsCounter.Start();
        }
Example #2
0
        public void Animate()
        {
            // Do performance check
            fpsCounter.MarkFrame();

            bool rampUp   = frameCount < RAMP_UP_FRAMES;
            bool rampDown = !rampUp && frameCount < RAMP_DOWN_FRAMES + RAMP_UP_FRAMES;
            int  targetFlakes;

            if (rampUp)
            {
                double x = (double)frameCount / RAMP_UP_FRAMES;
                targetFlakes = (int)(x * x * Properties.Settings.Default.MaximumNumberOfFlakes);

                frameCount++;
            }
            else if (rampDown)
            {
                double x = ((double)frameCount - RAMP_UP_FRAMES) / RAMP_DOWN_FRAMES;
                targetFlakes = (int)((1 - x) * (1 - x) * Properties.Settings.Default.MaximumNumberOfFlakes + MIN_RAMP_DOWN_FLAKES);

                frameCount++;
            }
            else
            {
                targetFlakes = 0;
                if (animatedDrift.SnowFlakeCount <= 0)
                {
                    frameCount++;

                    if (frameCount - RAMP_FRAMES_TOTAL > EMPTY_SCREEN_FRAMES)
                    {
                        // Reset
                        animatedDrift = new SnowDrift(screenSize);
                        frameCount    = 0;
                    }
                }
            }

            animatedDrift.TargetFlakes = targetFlakes;
            animatedDrift.Update();
        }