Example #1
0
        private static void DirectionManager()
        {
            if (!isAlive || isLanded || directionCooldown > 0)
            {
                return;
            }

            if (GfxTools.Win.GetKey(KeyCode.A) || GfxTools.Win.GetKey(KeyCode.Left))
            {
                positionNumber--;
                if (positionNumber < 0)
                {
                    positionNumber = 15;
                }
                directionCooldown = directionTempo;
                ship = new SpriteObj("Assets/Player/player" + positionNumber + ".png", ship.Position);
            }
            else if (GfxTools.Win.GetKey(KeyCode.D) || GfxTools.Win.GetKey(KeyCode.Right))
            {
                positionNumber++;
                if (positionNumber > 15)
                {
                    positionNumber = 0;
                }
                directionCooldown = directionTempo;
                ship = new SpriteObj("Assets/Player/player" + positionNumber + ".png", ship.Position);
            }
        }
Example #2
0
        public Animation(string[] files, SpriteObj animationOwner, float fps)
        {
            Loop      = true;
            IsPlaying = true;
            numFrames = files.Length;
            owner     = animationOwner;

            sprites = new Sprite[numFrames];

            for (int i = 0; i < sprites.Length; i++)
            {
                sprites[i] = new Sprite(files[i]);
            }

            owner.SetSprite(sprites[0]);

            if (fps > 0.0f)
            {
                frameDuration = 1 / fps;
            }
            else
            {
                frameDuration = 0.0f;
            }
        }
Example #3
0
 private static void Explosion()
 {
     if (!isAlive)
     {
         positionNumber++;
         if (positionNumber >= 16)
         {
             positionNumber = 0;
         }
         ship = new SpriteObj("Assets/Player/player" + positionNumber + ".png", ship.Position);
     }
 }
Example #4
0
        private void SetText(string text)
        {
            this.text = text;
            int nextX = (int)Position.X;
            int nextY = (int)Position.Y;

            for (int i = 0; i < text.Length; i++)
            {
                char currentletter = text[i];
                if (currentletter == ' ')
                {
                    sprites[i] = new SpriteObj("Assets/Font/s..png", nextX, nextY);
                }
                else if (currentletter == ':')
                {
                    sprites[i] = new SpriteObj("Assets/Font/2..png", nextX, nextY);
                }
                else
                {
                    sprites[i] = new SpriteObj("Assets/Font/" + currentletter + ".png", nextX, nextY);
                }
                nextX += sprites[i].Width + 4;
            }
        }