Esempio n. 1
0
        public Animation(string[] files, SpriteObj animationOwner, float fps, bool loop = true)
        {
            Loop      = loop;
            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;
            }
        }
Esempio n. 2
0
 public AlienBullet(int damage, Vector2 velocity, string[] AnimationString)
 {
     Position      = new Vector2(0, 0);
     this.velocity = velocity;
     sprite        = new SpriteObj(AnimationString[0], Position);
     animation     = new Animation2(AnimationString, 2, sprite, true);
     this.damage   = damage;
 }
Esempio n. 3
0
        public Animation2(string[] spriteAnimation, float fps, SpriteObj owner, bool loop)
        {
            this.fps             = fps;
            this.owner           = owner;
            this.spriteAnimation = spriteAnimation;
            this.loop            = loop;
            isPlaying            = true;
            sprites = new Sprite[spriteAnimation.Length];

            for (int i = 0; i < sprites.Length; i++)
            {
                sprites[i] = new Sprite(spriteAnimation[i]);
            }
        }
Esempio n. 4
0
        public Player(Vector2 pos, /*ColorRGB colorBackground, ColorRGB colorBorder*/ int energy = 3)
        {
            position   = pos;
            distToSide = 20;
            shootDelay = 1f;
            counter    = shootDelay;
            isAlive    = true;

            isFirePressed = false;
            isVisible     = true;
            this.energy   = energy;

            //timeDeadAnim = 0.05f;
            //currentTimeDead = timeDeadAnim;
            //this.colorBackground = colorBackground;
            //this.colorBorder = colorBorder;

            //baseRect = new Rectangle(position.X - width / 2, position.Y - height / 2, height / 2, width);
            //baseRect.SetColor(colorBackground, colorBorder);
            //int cannWidth = width / 3;
            //cannonRect = new Rectangle(position.X - cannWidth / 2, position.Y - height, height / 2, cannWidth);
            //cannonRect.SetColor(colorBackground, colorBorder);

            sprite = new SpriteObj("Assets/player.png", position);
            sprite.Translate(-sprite.Width / 2, -sprite.Height); //la sposttiamo sopra, il pivot no però
            width   = sprite.Width;
            height  = sprite.Height;
            ray     = width / 2;
            bullets = new Bullet[30];

            //bullet
            ColorRGB bulletCol = new ColorRGB(255, 255, 255);
            Vector2  velocity  = new Vector2(0, -200f);

            for (int i = 0; i < bullets.Length; i++)
            {
                bullets[i] = new Bullet(2, 11, 1, bulletCol, velocity);
            }

            //hearts energy
            heartsEnergy = new SpriteObj[energy];
            Vector2 heartPos = new Vector2(position.X - width / 2 - 6, position.Y);

            for (int i = 0; i < energy; i++)
            {
                heartsEnergy[i] = new SpriteObj(HEART_SPRITE_NAME, heartPos);
                heartPos.X     += heartsEnergy[i].Width - 5;
            }
        }
Esempio n. 5
0
 public Barrier(int x, int y)
 {
     sprite   = new SpriteObj(BARRIER_FILE, x, y);
     position = new Vector2(x, y);
     sprite.Translate(-Width / 2, -Height / 2);
 }