public static Explosion GetExplosion() { Dictionary<AnimationKey, Animation> animations = new Dictionary<AnimationKey, Animation>(); Animation animation = new Animation(16, 64, 64, 0, 0); animation.FramesPerSecond = 20; animations.Add(AnimationKey.Down, animation); Explosion explosion = new Explosion(ExplosionTexture, animations); return explosion; }
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)); }
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)); }
public static Character GetCharacter() { Dictionary<AnimationKey, Animation> animations = new Dictionary<AnimationKey, Animation>(); Animation animation = new Animation(3, 32, 32, 0, 0); animations.Add(AnimationKey.Down, animation); animation = new Animation(3, 32, 32, 0, 32); animations.Add(AnimationKey.Left, animation); animation = new Animation(3, 32, 32, 0, 64); animations.Add(AnimationKey.Right, animation); animation = new Animation(3, 32, 32, 0, 96); animations.Add(AnimationKey.Up, animation); Character character = new Character(SceneGraph, CharacterTexture, animations); character.AI = new PlayerAI(); character.SetCollisionSize(32, 32); return character; }
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."); }
public static Fireball GetFireBall() { Dictionary<AnimationKey, Animation> animations = new Dictionary<AnimationKey, Animation>(); Animation animation = new Animation(3, 32, 32, 0, 0); animations.Add(AnimationKey.Down, animation); animation = new Animation(3, 32, 32, 0, 32); animations.Add(AnimationKey.Left, animation); animation = new Animation(3, 32, 32, 0, 64); animations.Add(AnimationKey.Right, animation); animation = new Animation(3, 32, 32, 0, 96); animations.Add(AnimationKey.Up, animation); Fireball fireBall = new Fireball(SceneGraph, FireBallTexture, animations); fireBall.SetCollisionSize(32, 32); return fireBall; }
public void FPS_ValidValues(int fps) { Animation anim = new Animation(2, 32, 32, 0, 0); anim.FramesPerSecond = fps; }
public void Default5FPS() { Animation anim = new Animation(2, 32, 32, 0, 0); Assert.That(anim.FramesPerSecond == 5); }
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)); }
//TODO: Evaluate necesity of the cloning public object Clone() { Animation animationClone = new Animation(this); animationClone._CurrentFrame = this._CurrentFrame; animationClone.FramesPerSecond = this._FramesPerSecond; animationClone._FrameWidth = this._FrameWidth; animationClone._FrameHeight = this._FrameHeight; animationClone._FramesPerSecond = this._FramesPerSecond; animationClone.Looped = this.Looped; return animationClone; }
private Animation(Animation animation) { this._Frames = animation._Frames; }