コード例 #1
0
        public void Draw(SpriteBatch spriteBatch, int screenWidth, int screenHeight)
        {
            spriteBatch.Draw(Background, new Rectangle(0, 0, screenWidth, screenHeight), Color.White);

            int d = (int)Roy.Position.X + Roy.Bounds.Width / 2 - screenWidth / 2;

            d = MathHelper.Clamp(d, 0, LevelWidth - screenWidth);
            Rectangle screenWorldRect = new Rectangle(d, 0, screenWidth, screenHeight);

            foreach (Tile tile in Tiles)
            {
                if (tile.Bounds.Intersects(screenWorldRect))
                {
                    tile.Draw(spriteBatch, d);
                }
            }

            foreach (Entity entity in Entities)
            {
                if (entity.Bounds.Intersects(screenWorldRect))
                {
                    entity.Draw(spriteBatch, d);
                }
            }

            Roy.Draw(spriteBatch, d);
        }