Example #1
0
 public override void Update()
 {
     if (time <= 0)
     {
         dead = true;
     }
     kinetics.Update();
     time--;
     anim.Update();
     anim.SetPosition(kinetics.position);
 }
        public void Update(Kinetic kinetic)
        {
            float orientation = kinetic.orientations.GetRadOrientation();

            if (orientation <= MathHelper.PiOver4 || orientation > 7 * MathHelper.PiOver4)
            {
                idleFrame = (int)Animations.RIGHT;
                current   = right;
            }

            if (orientation <= 3 * MathHelper.PiOver4 && orientation > MathHelper.PiOver4)
            {
                idleFrame = (int)Animations.UP;
                current   = up;
            }

            if (orientation <= 5 * MathHelper.PiOver4 && orientation > 3 * MathHelper.PiOver4)
            {
                idleFrame = (int)Animations.LEFT;
                current   = left;
            }

            if (orientation <= 7 * MathHelper.PiOver4 && orientation > 5 * MathHelper.PiOver4)
            {
                idleFrame = (int)Animations.DOWN;
                current   = down;
            }

            if (kinetic.velocity.LengthSquared() == 0 && idle != null)
            {
                current = idle;
            }

            current.Update();
            current.SetPosition(kinetic.position);
        }