예제 #1
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);
        }
예제 #2
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (MarioGame game = new MarioGame())
     {
         game.Run();
     }
 }
예제 #3
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();
        }
예제 #4
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (MarioGame game = new MarioGame())
     {
         game.Run();
     }
 }
예제 #5
0
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Vector2 position, SpriteEffects spriteEffects)
        {
            if (Animation == null)
            {
                throw new NotSupportedException("No animation is currently playing.");
            }

            time += (float)gameTime.ElapsedGameTime.TotalSeconds;
            while (time > Animation.FrameTime)
            {
                time -= Animation.FrameTime;

                if (Animation.IsLooping)
                {
                    frameIndex = (frameIndex + 1) % Animation.FrameCount;
                }
                else
                {
                    frameIndex = Math.Min(frameIndex + 1, Animation.FrameCount - 1);
                }
            }

            Rectangle source = new Rectangle(FrameIndex * Animation.Texture.Height, 0, Animation.Texture.Height, Animation.Texture.Height);

            position.X += MarioGame.GetScrollX();
            spriteBatch.Draw(Animation.Texture, position, source, Color.White, 0.0f, Origin, 1.0f, spriteEffects, 0.0f);
        }
예제 #6
0
 public AnimateSprite(Rectangle rect, Texture2D ide, Texture2D run, Texture2D jump, MarioGame game)
 {
     this.run = run;
     this.ide = ide;
     this.rect = rect;
     this.jump = jump;
     frameWidth = frameHeight = run.Height;
     this.game = game;
 }
예제 #7
0
 public AnimateSprite(Rectangle rect, Texture2D ide, Texture2D run, Texture2D jump, MarioGame game)
 {
     this.run   = run;
     this.ide   = ide;
     this.rect  = rect;
     this.jump  = jump;
     frameWidth = frameHeight = run.Height;
     this.game  = game;
 }
예제 #8
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);
        }
예제 #9
0
 public Level(MarioGame game)
 {
     levelObjects = new List <LevelObject>();
     this.game    = game;
 }
예제 #10
0
 public  Level(MarioGame game)
 {
     levelObjects = new List<LevelObject>();
     this.game = game;
 }