Exemplo n.º 1
0
        public Enemy(int alienType, Vector2 position)
        {
            this.alienType = alienType;
            switch (alienType)
            {
            case 1:
            {
                sprite   = new SpriteObj("Assets/alien1a.png", position);
                files[0] = "Assets/alien1a.png";
                files[1] = "Assets/alien1b.png";
                break;
            }

            case 2:
            {
                sprite   = new SpriteObj("Assets/alien2a.png", position);
                files[0] = "Assets/alien2a.png";
                files[1] = "Assets/alien2b.png";
                break;
            }

            case 3:
            {
                sprite   = new SpriteObj("Assets/alien3a.png", position);
                files[0] = "Assets/alien3a.png";
                files[1] = "Assets/alien3b.png";
                break;
            }
            }
            animation        = new Animation(files, sprite, 1.5f);
            centeredPosition = new Vector2(sprite.Position.X + sprite.Width / 2, sprite.Position.Y + sprite.Height / 2);
            points           = this.alienType * 10;
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 3
0
        public Animation(string[] files, float Fps, SpriteObj own, float frameDuration)
        {
            owner = own;



            nFiles = files.Length;

            frameDur = frameDuration;

            fps = Fps;


            sprites = new Sprite[nFiles];

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

            owner.SetSprite(sprites[0]);

            if (fps > 0.0f)
            {
                frameDur = 1 / fps;
            }

            else
            {
                frameDur = 0.0f;
            }
        }
 public BulletPlayer(int w, int h, Color col)
 {
     Position = new Vector2(0, 0);
     velocity = Position;
     sprite   = new SpriteObj("Assets/bullet.png");
     width    = sprite.width;
     height   = sprite.height;
     color    = col;
 }
Exemplo n.º 5
0
        public Barrier(Vector2 pos)
        {
            position = pos;

            spriteobj = new SpriteObj("Assets/barrier.png", position);
            spriteobj.Translate(-spriteobj.width / 2, -spriteobj.height);

            width  = spriteobj.width;
            height = spriteobj.height;

            ray = width / 2;
        }
Exemplo n.º 6
0
        public Player()
        {
            Vector2 startPosition = new Vector2(GfxTools.Win.width / 2 - sprite.Width / 2, GfxTools.Win.height - Game.Edge * 1.5f - sprite.Height);

            sprite           = new SpriteObj("Assets/player.png", startPosition);
            centeredPosition = new Vector2(sprite.Position.X + sprite.Width / 2, sprite.Position.Y + sprite.Height / 2);
            for (int i = 0; i < bullets.Length; i++)
            {
                SpriteObj bulletSprite = new SpriteObj("Assets/playerBullet.png");
                bullets[i] = new PlayerBullet(bulletSprite);
            }
        }
Exemplo n.º 7
0
        private void DrawLives()
        {
            SpriteObj[] livesArray    = new SpriteObj[lives];
            Vector2     livesPosition = new Vector2(Game.Edge, GfxTools.Win.height - Game.Edge);

            for (int i = 0; i < lives; i++)
            {
                livesArray[i] = new SpriteObj("Assets/player.png", livesPosition);
                livesArray[i].Draw();
                livesPosition.X += livesArray[i].Sprite.width * 1.2f;
            }
        }
Exemplo n.º 8
0
        public 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];
                sprites[i] = new SpriteObj("Assets/number" + currentletter + ".png", nextX, nextY);
                nextX     += sprites[i].Width + 4;
            }
        }
        public void setText(string text)
        {
            this.text = text;
            int numChars = text.Length;
            int charX    = (int)position.X;
            int charY    = (int)position.Y;

            if (numChars > sprites.Length)
            {
                numChars = sprites.Length;
            }

            for (int i = 0; i < numChars; i++)
            {
                char number = text[i];
                sprites[i] = new SpriteObj("Assets/numbers_" + number + ".png", charX, charY);
                charX     += sprites[i].width;
            }
        }
Exemplo n.º 10
0
        public Player(Vector2 pos, Color col)
        {
            position = pos;

            distToSide = 20;
            shootDelay = 0.3f;
            color      = col;

            nrg   = 10;
            score = 0;

            IsAlive   = true;
            spriteobj = new SpriteObj("Assets/playerYellow.png", pos);
            spriteobj.Translate(-spriteobj.width / 2, -spriteobj.height);

            width  = spriteobj.width;
            height = spriteobj.height;
            ray    = width / 2;


            musicP = new SoundPlayer();
            musicP.SoundLocation = "Assets/shoot.wav";
            musicP.Load();



            //baseRect = new Rect(position.X - width / 2, position.Y - height / 2, width, height / 2, color);
            //int cannWidth = width / 3;
            //cannonRect = new Rect(position.X - cannWidth / 2, position.Y - height, cannWidth, height / 2, color);


            bulletPlayer = new BulletPlayer[30];

            Color bulletCol = new Color(200, 0, 0);

            for (int i = 0; i < bulletPlayer.Length; i++)
            {
                bulletPlayer[i] = new BulletPlayer(10, 20, bulletCol);
            }
        }
Exemplo n.º 11
0
        public BulletAliens(int w, int h, Color col)
        {
            Position = new Vector2(0, 0);
            velocity = Position;
            sprite   = new SpriteObj();

            color = col;

            string[] animationfiles = { "Assets/A_F/bulletA1.png",  "Assets/A_F/bulletA2.png",
                                        "Assets/A_F/bulletA3.png",  "Assets/A_F/bulletA4.png", "Assets/A_F/bulletA5.png",
                                        "Assets/A_F/bulletA6.png",  "Assets/A_F/bulletA7.png", "Assets/A_F/bulletA8.png",
                                        "Assets/A_F/bulletA9.png",  "Assets/A_F/bulletA10.png","Assets/A_F/bulletA11.png",
                                        "Assets/A_F/bulletA12.png", "Assets/A_F/bulletA13.png","Assets/A_F/bulletA14.png",
                                        "Assets/A_F/bulletA15.png" };



            animation = new Animation(animationfiles, 24, sprite, 12f);
            width     = sprite.width;
            height    = sprite.height;

            //test
        }
Exemplo n.º 12
0
 public backgorund(string fileName)
 {
     spriteBg = new SpriteObj(fileName);
 }
Exemplo n.º 13
0
 public PlayerBullet(SpriteObj sprite)
 {
     this.sprite = sprite;
     point       = new Vector2(sprite.Position.X + sprite.Width / 2, sprite.Position.Y);
 }