Exemple #1
0
        public void Draw(SpriteBatch spriteBatch)
        {
            Rectangle     r             = new Rectangle(curentFrame * frameWidth, 0, frameWidth, frameHeight);
            SpriteEffects spriteEffects = SpriteEffects.None;

            spriteBatch.Begin();
            Rectangle screnRect = MarioGame.GetScrenRect(rect);

            if (!isRuningRight)
            {
                spriteEffects = SpriteEffects.FlipHorizontally;
            }
            if (isJumping)
            {
                spriteBatch.Draw(jump, screnRect, r, Color.White, 0, Vector2.Zero, spriteEffects, 0);
            }
            else
            if (isRuning)
            {
                spriteBatch.Draw(run, screnRect, r, Color.White, 0, Vector2.Zero, spriteEffects, 0);
            }
            else
            {
                spriteBatch.Draw(ide, screnRect, r, Color.White, 0, Vector2.Zero, spriteEffects, 0);
            }

            spriteBatch.End();
        }
Exemple #2
0
        public void Draw(SpriteBatch spriteBatch)
        {
            Rectangle r         = new Rectangle(curentFrame * frameWidth, 0, frameWidth, frameHeight);
            Rectangle screnRect = MarioGame.GetScrenRect(rectangle);

            spriteBatch.Draw(texture, screnRect, r, Color.White);
        }
Exemple #3
0
        public void Update(GameTime gameTime)
        {
            timeEclapsed += gameTime.ElapsedGameTime.Milliseconds;
            if (isRuning)
            {
                if (timeEclapsed > timeForFreme)
                {
                    if (!isJumping)
                    {
                        curentFrame = (curentFrame + 1) % FrameCountRun;
                    }
                    else
                    {
                        curentFrame = (curentFrame + 1) % FrameCountJump;
                    }
                    timeEclapsed = 0;
                }
                int dx = 3 * gameTime.ElapsedGameTime.Milliseconds / 10;
                if (!isRuningRight)
                {
                    dx = -dx;
                }
                Rectangle nextPosition = rect;
                nextPosition.Offset(dx, 0);

                Rectangle boundingRect = GetBoundingRect(nextPosition);
                Rectangle screnRect    = MarioGame.GetScrenRect(boundingRect);

                if (screnRect.Left > 0 && screnRect.Right < MarioGame.Width && !game.CollidesWithLevel(boundingRect))
                {
                    rect = nextPosition;
                }
            }
            else
            {
                if (timeEclapsed > timeForFreme)
                {
                    System.Diagnostics.Debug.WriteLine("FrameCountIde=" + FrameCountIde);
                    curentFrame  = (curentFrame + 1) % FrameCountIde;
                    timeEclapsed = 0;
                }
            }
            ApplyGravity(gameTime);
        }