Esempio n. 1
0
        public Planet(Vector2 position, int numSprite, float fps, float verticalMaxSpeed, float horizontalMaxSpeed)
        {
            this.position = position;
            position.AddRandom(0, GfxTools.Win.width / 2, -GfxTools.Win.height / 2, 0);
            this.verticalMaxSpeed   = verticalMaxSpeed;
            this.horizontalMaxSpeed = horizontalMaxSpeed;
            do
            {
                horizontalSpeed = RandomGenerator.GetRandom(-(int)this.horizontalMaxSpeed, (int)this.horizontalMaxSpeed);
                verticalSpeed   = RandomGenerator.GetRandom(-(int)this.verticalMaxSpeed, (int)this.verticalMaxSpeed);
            } while (verticalSpeed == 0 || horizontalSpeed == 0);
            IsAlive        = true;
            this.numSprite = numSprite;
            cdSprite       = fps;
            indexPlanet    = 0;
            sprites        = new string[numSprite];

            for (int i = 0; i < sprites.Length; i++)
            {
                sprites[i] = "Assets/background/" + i + ".png";
            }


            sprite    = new SpriteObj(sprites[indexPlanet], position);
            animation = new Animation(sprites, sprite, cdSprite);

            width  = sprite.Width;
            height = sprite.Height;
            ray    = width / 2;
            sprite.Translate(-ray, -height / 2);
        }
Esempio n. 2
0
        public IndexClose(Vector2 position, int numSprite, float fps, float verticalMaxSpeed, float horizontalMaxSpeed)
        {
            //value
            this.position           = position;
            verticalSpeed           = horizontalSpeed = 0;
            this.verticalMaxSpeed   = verticalMaxSpeed;
            this.horizontalMaxSpeed = horizontalMaxSpeed;
            IsAlive = false;


            //sprite
            this.numSprite = numSprite;
            cdSprite       = fps;
            sprites        = new string[numSprite];

            for (int i = 0; i < sprites.Length; i++)
            {
                sprites[i] = "Assets/cmd/close/" + i + ".png";
            }

            sprite    = new SpriteObj(sprites[0], position);
            animation = new Animation(sprites, sprite, cdSprite);

            width  = sprite.Width;
            height = sprite.Height;
            ray    = width / 2;
            sprite.Translate(-ray, -height / 2);
        }
Esempio n. 3
0
        public Asteroid(int numSprite, float fps, float verticalMaxSpeed, float horizontalMaxSpeed)
        {
            verticalSpeed           = (RandomGenerator.GetRandom((int)1, (int)+verticalMaxSpeed));
            horizontalSpeed         = (RandomGenerator.GetRandom((int)1, (int)+horizontalMaxSpeed));
            this.verticalMaxSpeed   = verticalMaxSpeed;
            this.horizontalMaxSpeed = horizontalMaxSpeed;
            IsAlive        = false;
            this.numSprite = numSprite;
            cdSprite       = fps;
            sprites        = new string[numSprite];

            for (int i = 0; i < sprites.Length; i++)
            {
                sprites[i] = "Assets/asteroid/" + i + ".png";
            }

            sprite    = new SpriteObj(sprites[0], position);
            animation = new Animation(sprites, sprite, cdSprite);

            position.GetRandom(sprite.Width, GfxTools.Win.width / 2 + sprite.Width + 10, 1, 10);
            sprite.SetPosition(position);
            width  = sprite.Width;
            height = sprite.Height;
            ray    = width / 2;
            sprite.Translate(-ray, -height / 2);
        }
Esempio n. 4
0
        public Coin(Vector2 position, int numSprite, float fps, float verticalMaxSpeed, float horizontalMaxSpeed)
        {
            this.position           = position;
            verticalSpeed           = horizontalSpeed = 0;
            this.verticalMaxSpeed   = verticalMaxSpeed;
            this.horizontalMaxSpeed = horizontalMaxSpeed;
            IsAlive        = false;
            this.numSprite = numSprite;
            cdSprite       = fps;
            sprites        = new string[numSprite];

            for (int i = 0; i < sprites.Length; i++)
            {
                sprites[i] = "Assets/coin/" + i + ".png";
            }

            sprite    = new SpriteObj(sprites[3], position);
            animation = new Animation(sprites, sprite, cdSprite);

            width  = sprite.Width;
            height = sprite.Height;
            ray    = width / 2;
            sprite.Translate(-ray, -height / 2);


            //AUDIO
            string[] audioPath = { @"Assets\media\coin\coin_1_a.wav" };
            audio = new Audio(audioPath, false);
        }
Esempio n. 5
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;
            }
        }
Esempio n. 6
0
        public CMDSound(Vector2 position, int numSprite, float fps)
        {
            //value
            this.position = position;
            IsAlive       = true;
            isPlaying     = true;

            //sprite
            this.numSprite = numSprite;
            cdSprite       = fps;
            sprites        = new string[numSprite];

            for (int i = 0; i < sprites.Length; i++)
            {
                sprites[i] = "Assets/cmd/sound/" + i + ".png";
            }

            sprite    = new SpriteObj(sprites[0], position);
            animation = new Animation(sprites, sprite, cdSprite);

            width  = sprite.Width;
            height = sprite.Height;
            ray    = width / 2;
            sprite.Translate(-ray, -height / 2);
        }
Esempio n. 7
0
        static Explosion()
        {
            Player player = Game.GetPlayer();

            position = new Vector2(player.Position.X, player.Position.Y);
            fps      = 15;
            sprites  = new string[9];
            for (int i = 0; i < sprites.Length; i++)
            {
                sprites[i] = "Assets/explosion/regularExplosion0" + i + ".png";
            }

            sprite    = new SpriteObj(sprites[0], position);
            animation = new Animation(sprites, sprite, fps)
            {
                Loop = true
            };
            animation.Stop();
        }
Esempio n. 8
0
        public GUI(Vector2 position, int numSprite)
        {
            this.position  = position;
            IsAlive        = false;
            this.numSprite = numSprite;
            sprites        = new string[numSprite];

            for (int i = 0; i < sprites.Length; i++)
            {
                sprites[i] = "Assets/GUI/" + i + ".png";
            }

            sprite = new SpriteObj(sprites[0], position);

            width  = sprite.Width;
            height = sprite.Height;
            ray    = width / 2;
            sprite.Translate(-ray, -height / 2);
        }
Esempio n. 9
0
        public void SetText(string text)
        {
            this.text = text;
            int numberChars = text.Length;
            int charX       = (int)Position.X;
            int charY       = (int)Position.Y;

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

            for (int i = 0; i < numberChars; i++)
            {
                char number = text[i];
                sprites[i] = new SpriteObj("Assets/numbers/numbers_" + number + ".png", charX, charY);
                charX     += sprites[i].Sprite.width;
            }
        }
Esempio n. 10
0
        public Player(Vector2 position, int numSprite, float fps, float verticalMaxSpeed, float horizontalMaxSpeed, int numOfLifes)
        {
            this.position           = position;
            verticalSpeed           = horizontalSpeed = 0;
            this.verticalMaxSpeed   = verticalMaxSpeed;
            this.horizontalMaxSpeed = horizontalMaxSpeed;
            IsAlive = true;
            nrg     = numOfLifes;
            mass    = 50f;
            force   = mass * verticalSpeed;



            this.numSprite = numSprite;
            cdSprite       = fps;
            sprites        = new string[numSprite];

            for (int i = 0; i < sprites.Length; i++)
            {
                sprites[i] = "Assets/rocket/" + i + ".png";
            }

            sprite    = new SpriteObj(sprites[0], position);
            animation = new Animation(sprites, sprite, cdSprite);

            width  = sprite.Width;
            height = sprite.Height;
            ray    = width / 2;
            sprite.Translate(-ray, -height / 2);

            //danger Sprite
            danger = new SpriteObj("Assets/danger/0.png", dangerPosition);

            //platform
            scoreWinner = 100;
        }
Esempio n. 11
0
        public SpaceStation(Vector2 position, int numSprite, float fps)
        {
            this.position = position;
            verticalSpeed = horizontalSpeed = cdSpawn = 0;
            cdSpawn       = 30;
            IsAlive       = false;

            this.numSprite = numSprite;
            cdSprite       = fps;
            sprites        = new string[numSprite];

            for (int i = 0; i < sprites.Length; i++)
            {
                sprites[i] = "Assets/platform/" + i + ".png";
            }

            sprite    = new SpriteObj(sprites[0], position);
            animation = new Animation(sprites, sprite, cdSprite);

            width  = sprite.Width;
            height = sprite.Height;
            ray    = width / 2;
            sprite.Translate(-ray, -height / 2);
        }