Exemplo n.º 1
0
        // UPDATE

        private void MovementManager()
        {
            float deltaY = movementSpeed * Game.DeltaTime;

            sprite.Translate(0, deltaY);
            point = new Vector2(sprite.Position.X + sprite.Width / 2, sprite.Position.Y + sprite.Height);
            if (sprite.Position.Y > GfxTools.Win.height - Game.Edge)
            {
                isFired = false;
            }
        }
Exemplo n.º 2
0
        // UPDATE

        private void MovementManager()
        {
            float deltaY = movementSpeed * Game.DeltaTime;

            sprite.Translate(0, -deltaY);
            point = new Vector2(sprite.Position.X + sprite.Width / 2, sprite.Position.Y);
            if (sprite.Position.Y < -16)
            {
                isFired = false;
            }
        }
Exemplo n.º 3
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;
        }
        public void Update()
        {
            Position.X += velocity.X * GfxTools.Win.deltaTime;
            Position.Y += 50 + (velocity.Y * GfxTools.Win.deltaTime);


            sprite.Translate(Position.X, Position.Y);

            if (Position.Y + height / 2 < 0 || Position.Y - height / 2 >= GfxTools.Win.height)
            {
                IsAlive = false;
            }
            sprite.Position = Position;
        }
Exemplo n.º 5
0
        public void Update()
        {
            float deltaX = speed * GfxTools.Win.deltaTime;

            position.X += deltaX;
            float maxX = position.X + width / 2;
            float minX = position.X - width / 2;

            if (maxX > GfxTools.Win.width - distToSide)
            {
                float overflowX = maxX - (GfxTools.Win.width - distToSide);
                position.X -= overflowX;
                deltaX     -= overflowX;
            }
            else if (minX < distToSide)
            {
                float overflowX = minX - distToSide;
                position.X -= overflowX;
                deltaX     -= overflowX;
            }

            //rectangles update
            //baseRect.Translate(deltaX, 0);
            //cannonRect.Translate(deltaX, 0);

            spriteobj.Translate(deltaX, 0);



            for (int i = 0; i < bulletPlayer.Length; i++)
            {
                if (bulletPlayer[i].IsAlive)
                {
                    bulletPlayer[i].Update();

                    if (Game.BarriersCollides(bulletPlayer[i].Position, bulletPlayer[i].GetWidth()))
                    {
                        bulletPlayer[i].IsAlive = false;
                    }

                    if (EnemyMgr.CollideWithBullet(bulletPlayer[i]))
                    {
                        bulletPlayer[i].IsAlive = false;
                    }
                }
            }
        }
Exemplo n.º 6
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.º 7
0
        private void MovementManager()
        {
            float deltaX = movementSpeed;

            sprite.Position = new Vector2(sprite.Position.X + deltaX, sprite.Position.Y);
            float maxX = sprite.Position.X + sprite.Width;
            float minX = sprite.Position.X;

            if (maxX > GfxTools.Win.width - Game.Edge)
            {
                float overflowX = maxX - (GfxTools.Win.width - Game.Edge);
                sprite.Position = new Vector2(sprite.Position.X - overflowX, sprite.Position.Y);
                deltaX         -= overflowX;
            }
            else if (minX < Game.Edge)
            {
                float overflowX = minX - Game.Edge;
                sprite.Position = new Vector2(sprite.Position.X - overflowX, sprite.Position.Y);
                deltaX         -= overflowX;
            }

            sprite.Translate(deltaX, 0);
        }