Exemple #1
0
        //SpriteFont font;

        /// <summary>
        /// Creates a new player object
        /// </summary>
        /// <param name="game"></param>
        public Player(Game1 game)
        {
            this.game = game;
            timer     = new TimeSpan(0);
            position  = new Vector2(game.getShipX(), 840);
            state     = State.Idle;
        }
Exemple #2
0
        /// <summary>
        /// Renders the sprite on-screen
        /// </summary>
        /// <param name="spriteBatch"></param>
        public void Draw(SpriteBatch spriteBatch)
        {
            // determine the source rectagle of the sprite's current frame
            var source = new Rectangle(
                frame * FRAME_WIDTH,           // X value
                (int)state % 4 * FRAME_HEIGHT, // Y value
                FRAME_WIDTH,                   // Width
                FRAME_HEIGHT                   // Height
                );

            // render the sprite
            spriteBatch.Draw(texture, new Vector2(game.getShipX() - 50, game.getShipY() - 30), source, Color.White);

            // render the sprite's coordinates in the upper-right-hand corner of the screen
            //spriteBatch.DrawString(font, $"X:{position.X} Y:{position.Y}", Vector2.Zero, Color.White);
        }