示例#1
0
        public Player(float x, float y)
        {
            isAlive      = true;
            position.X   = x;
            position.Y   = y;
            playerSprite = new SpriteObj("Asset/player.png", position);
            width        = playerSprite.width;
            height       = playerSprite.height;

            hitCounter = 0;
            playerSprite.Traslate(-width / 2, height / 2);

            speed          = 150;
            isSpacePressed = false;

            Color bulletCol;

            bulletCol.R = 0;
            bulletCol.G = 255;
            bulletCol.B = 0;

            for (int i = 0; i < bullet.Length; i++)
            {
                bullet[i] = new Bullet(10, 5, bulletCol);
            }
        }
示例#2
0
        public void Update()
        {
            position.X += speed * GfxTools.window.deltaTime;
            playerSprite.Traslate(speed * GfxTools.window.deltaTime, 0);

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

                    /*if (BarrierManager.Collision(bullet[i]))
                     * {
                     *  bullet[i].IsActive = false;
                     * }*/

                    if (EnemyManager.CollideWithBullet(bullet[i]))
                    {
                        bullet[i].IsActive = false;
                    }
                }
            }
        }