Permalink
Browse files

Add medium door speed

  • Loading branch information...
zumpiez committed Apr 1, 2012
1 parent 1398f08 commit 9476b9214b7c4d5f6f6850cacc52d176e60cbad9
Showing with 10 additions and 5 deletions.
  1. +7 −4 DemonDoor/DemonDoor/Door.cs
  2. +3 −1 DemonDoor/DemonDoor/DoorController.cs
@@ -16,14 +16,17 @@ class DoorSprite {
public Sprite Sprite { get; private set; }
- public enum AnimationState {
- Stopped, Slow, Fast
+ public enum AnimationState
+ {
+ Stopped, Slow, Fast,
+ Medium
}
public DoorSprite( SpriteBasis sb ) {
animationAtlas = new Dictionary<AnimationState, Filmstrip>();
animationAtlas[AnimationState.Stopped] = createFilmstrip( new[] { 0 } );
animationAtlas[AnimationState.Slow] = createFilmstrip(new[] { 0, 1, 2 });
+ animationAtlas[AnimationState.Medium] = createFilmstrip(new[] { 0, 1, 2 }, 75);
animationAtlas[AnimationState.Fast] = createFilmstrip(new[] { 3, 4 });
DrawDoor = (int x, int y) => {
@@ -57,9 +60,9 @@ private Filmstrip createFilmstrip(int frame)
/// </summary>
/// <param name="frames"></param>
/// <returns></returns>
- private Filmstrip createFilmstrip(IList<int> frames)
+ private Filmstrip createFilmstrip(IList<int> frames, int framerate = 150)
{
- return new Filmstrip(new Point(38, 24), frames, 150);
+ return new Filmstrip(new Point(38, 24), frames, framerate);
}
public RenderDelegate DrawDoor { get; set; }
@@ -180,8 +180,10 @@ public void UpdateGunImpulse(GameTime gameTime)
GunImpulse = Math.Min(MaxGunImpulse, GunImpulse);
// set animation speed
- if(GunImpulse / MaxGunImpulse > 0.5) {
+ if(GunImpulse / MaxGunImpulse > 0.7) {
sprite.SetAnimationState(DoorSprite.AnimationState.Fast);
+ } else if (GunImpulse / MaxGunImpulse > 0.5) {
+ sprite.SetAnimationState(DoorSprite.AnimationState.Medium);
} else if (GunImpulse / MaxGunImpulse > 0.1) {
sprite.SetAnimationState(DoorSprite.AnimationState.Slow);
} else {

0 comments on commit 9476b92

Please sign in to comment.