コード例 #1
0
        public Player(Game game, Texture2D texture, ArrayList _sounds, int xStart, int yStart)
            : base(game)
        {
            facingDirection = Action.right;
            source = new Rectangle(251, 142, 746 - 251, 805 - 142);
            position = new Rectangle(xStart, yStart, 36, 52);
            sprite = texture;

            int xCenter = xStart + (position.Width / 2);
            int yCenter = yStart - playerPadding;
            this.jumpMeter = new JumpMeter(game, xCenter, yCenter, spriteDepth);

            hidden = 0;
            isJumping = false;
            isStopped = true; // will we need to know this?? Maybe for a funny animation if you take too long...
            isDead = false;
            hasReachedGoal = false;

            sounds = _sounds;

            deltaX = 0;
            deltaY = 0;
        }
コード例 #2
0
ファイル: Player.cs プロジェクト: Terhands/LazerSharktopus
        bool setDead = false; //This is so that i can set frameCountCol to the starting frame of death animation then not do it again in update animation function

        #endregion Fields

        #region Constructors

        public Player(Game _game, Texture2D texture, ArrayList _sounds, int xStart, int yStart)
            : base(_game)
        {
            game = _game;

            facingDirection = Action.right;
            source = new Rectangle(this.frameStartX + this.frameSkipX * this.frameCountCol, this.frameStartY + this.frameSkipY * this.frameCountRow, this.frameWidth, this.frameHeight);
            int screenwidth = Game.GraphicsDevice.Viewport.Width;
            int screenheight = Game.GraphicsDevice.Viewport.Height;
            int playerHeight = screenheight * 4 / 32;
            int playerWidth = screenwidth * 2 / 64;
            position = new Rectangle(xStart, yStart, playerWidth, playerHeight);
            leftRightCollisionRectangle = new Rectangle(position.X, position.Y, position.Width, position.Height - 2);

            sprite = texture;

            int xCenter = xStart + (position.Width / 2);
            int yCenter = yStart - playerPadding;
            jumpMeter = new JumpMeter(game, xCenter, yCenter, spriteDepth);

            healthMeter = new HealthMeter(game, 200, 10, spriteDepth);

            hidden = 0.0f;
            damageCounter = 0;
            fallDistance = 0;
            isJumping = false;
            isStopped = true; // will we need to know this?? Maybe for a funny animation if you take too long...
            isDead = false;
            hasReachedGoal = false;
            displayHealthBar = true;

            sounds = _sounds;

            deltaX = 0;
            deltaY = 0;
        }