示例#1
0
        public void FPSCalculation()
        {
            Animation anim = new Animation(2, 32, 32, 0, 0);
            //30 FPS = New frame every other update
            anim.FramesPerSecond = 30;

            int frame = anim.CurrentFrame;
            anim.Update();
            Assert.That(anim.CurrentFrame, Is.EqualTo(frame));
            anim.Update();
            Assert.That(anim.CurrentFrame, Is.Not.EqualTo(frame));
        }
示例#2
0
        public void Animate()
        {
            Animation anim = new Animation(2, 32, 32, 0, 0);
            anim.FramesPerSecond = 60;

            Rectangle frame1 = anim.CurrentFrameRect;
            anim.Update();
            Rectangle frame2 = anim.CurrentFrameRect;

            Assert.That(frame1, Is.Not.EqualTo(frame2));
        }
示例#3
0
        public void Clone()
        {
            Animation anim = new Animation(2, 32, 32, 0, 0);
            anim.FramesPerSecond = 60;

            anim.Update();
            anim.Update();
            anim.Update();

            Animation clone = (Animation)anim.Clone();

            Assert.That(
                (anim.CurrentFrame == clone.CurrentFrame) &&
                (anim.CurrentFrameRect == clone.CurrentFrameRect) &&
                (anim.FrameHeight == clone.FrameHeight) &&
                (anim.FramesPerSecond == clone.FramesPerSecond) &&
                (anim.FrameWidth == clone.FrameWidth) &&
                (anim.Looped == clone.Looped),
                "Clone did not produce a copy of the Animation.");

            Assert.AreNotSame(anim, clone, "Clone produced a reference copy of the Animation.");
        }
示例#4
0
        public void Reset()
        {
            Animation anim = new Animation(2, 32, 32, 0, 0);
            anim.FramesPerSecond = 60;
            Rectangle frame1 = anim.CurrentFrameRect;
            anim.Update();
            anim.Reset();
            Rectangle resetFrame = anim.CurrentFrameRect;

            Assert.That(frame1, Is.EqualTo(resetFrame));
        }