Exemple #1
0
 /// <summary>
 /// Creates an animation manager
 /// </summary>
 /// <param name="p_fps">FpsTimer object onwhich to sync the animations</param>
 public SpriteManager(FpsTimer p_fps)
 {
     fps = p_fps;
     SpriteManager.globalFps = fps.FPS;
     fps.Start();
     selfTiming = false;
 }
Exemple #2
0
 /// <summary>
 /// Creates an animation manager
 /// </summary>
 /// <param name="p_fps">FpsTimer object onwhich to sync the animations</param>
 public SpriteManager(FpsTimer p_fps)
 {
     fps = p_fps;
     SpriteManager.globalFps = fps.FPS;
     fps.Start();
     selfTiming = false;
 }
Exemple #3
0
 /// <summary>
 /// Create DrawManager for a given form
 /// </summary>
 /// <param name="p_form">Form to draw on</param>
 /// <param name="p_fps">FpsTimer object</param>
 public DrawManager(Control p_form, FpsTimer p_fps)
 {
     fpsTimer   = p_fps;
     formBuffer = new FormBuffer(p_form);
     drawables  = new LinkedList <IDrawable>();
     fpsTimer.Start();
     selfTiming = false;
 }
Exemple #4
0
        /// <summary>
        /// Call everytime we want a game redraw. Should be called at the highest frames per second that
        /// the game uses.
        /// </summary>
        public void DrawGame()
        {
            if (selfTiming)
            {
                if (!fpsTimer.TimeElapsed())
                {
                    return;
                }
                fpsTimer.Reset();
                fpsTimer.Start();
            }

            foreach (IDrawable cgd in drawables)
            {
                cgd.Draw(formBuffer.Graphics);
            }
            formBuffer.Render();
        }
Exemple #5
0
        /// <summary>
        /// Tells this AnimationManager to draw all current objects on the given
        /// Graphics object
        /// </summary>
        /// <param name="p_g">the Graphics object onwhich to draw</param>
        public void RunNext(Graphics p_g)
        {
            if (selfTiming)
            {
                if (!fps.TimeElapsed())
                {
                    return;
                }
                fps.Reset();
                fps.Start();
            }

            int removeIndex = 0; // we need to remember how many completed objects to delete

            // A list of AnimationObjects that have completed on this run
            Sprite[] aoToRemove = new Sprite[animationObjects.Count];

            foreach (Sprite animationObject in animationObjects)
            {                                          // Run each Sprite in turn
                if (animationObject.RunNext(p_g) == 1) // a return of 1 indicates completion
                {                                      // Remember to remove this object since it is done
                    aoToRemove[removeIndex++] = (Sprite)(animationObject);
                }
            }

            for (int i = 0; i < removeIndex; i++)
            {   // remove all completed Animation objects from list and
                // call the completion event for each (before removal)
                aoToRemove[i].CallCompletionEvent();
                animationObjects.Remove(aoToRemove[i]);
            }
            if (animationObjects.Count == 0)
            {
                running = false;
            }
        }