Example #1
0
        SpriteBatch spriteBatch; // Used to draw the level to the screen.

        #endregion Fields

        #region Constructors

        // Constructs a level.
        public Level(IServiceProvider serviceProvider, Game1 game, SpriteBatch spriteBatch, int numLayers)
        {
            this.spriteBatch = spriteBatch;
            this.game = game;
            // Create a new content manager to load content used just by this level.
            content = new ContentManager(serviceProvider, "Content");
            LoadContent();
            LoadLevel(numLayers);
            camera = new Camera(game.screenRectangle);
        }
Example #2
0
        public void Draw(SpriteBatch spriteBatch, Camera camera)
        {
            Rectangle destination = new Rectangle(0, 0, Engine.TileWidth, Engine.TileHeight);
            Tile tile;
            foreach (MapLayer layer in mapLayers)
            {
                for (int y = 0; y < layer.Height; y++)
                {
                    destination.Y = y * Engine.TileHeight - (int)camera.Position.Y;
                    for (int x = 0; x < layer.Width; x++)
                    {
                        tile = layer.GetTile(x, y);

                        if (tile.TileIndex == -1 || tile.Tileset == -1)
                            continue;

                        destination.X = x * Engine.TileWidth - (int)camera.Position.X;
                        spriteBatch.Draw(tilesets[tile.Tileset].Image, destination, tilesets[tile.Tileset].SourceRectangles[tile.TileIndex], Color.White);
                    }
                }
            }
        }
Example #3
0
 /// <summary>
 /// Draws the projectile to the screen.
 /// </summary>
 /// <param name="gameTime"></param>
 public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch, Camera camera)
 {
     spriteBatch.Draw(projectileTexture, Position - camera.Position, null, Color.White, rotation, Origin, .50f, SpriteEffects.None, 0);
 }
Example #4
0
 /// <summary>
 /// Draws the charged laser to the screen.
 /// </summary>
 /// <param name="gameTime"></param>
 public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, Camera camera)
 {
     spriteBatch.Draw(currentAnimation.spriteStrip, Position - camera.Position, currentAnimation.SourceRectangle, Color.White, Rotation, Origin, 1, SpriteEffects.None, 0);
 }
Example #5
0
 /// <summary>
 /// Draw all sprites in the game.
 /// </summary>
 /// <param name="gameTime"></param>
 /// <param name="spriteBatch"></param>
 public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Camera camera)
 {
     foreach (Projectile projectile in ProjectileList)
     {
         projectile.Draw(gameTime, spriteBatch, camera);
     }
 }
Example #6
0
 /// <summary>
 /// Draws the animated sprite to the screen.
 /// </summary>
 /// <param name="gameTime"></param>
 public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Camera camera)
 {
     spriteBatch.Draw(spriteTexture, position - camera.Position, currentAnimation.SourceRectangle, Color.White, rotation, Origin, 1, SpriteEffects.None, 0);
 }
Example #7
0
 /// <summary>
 /// Creates a new player for the level.  It's position is updated and then added to the list of animated sprites in the game.
 /// </summary>
 /// <param name="position"></param>
 /// <returns></returns>
 public Player CreatePlayer(Vector2 position, Game1 game, Camera camera)
 {
     Player player = new Player(game, position, camera);
     player.Position = position;
     Instance.SpriteList.Add(player);
     return player;
 }
Example #8
0
 /// <summary>
 /// Draw all sprites in the game.
 /// </summary>
 /// <param name="gameTime"></param>
 /// <param name="spriteBatch"></param>
 /// <param name="camera"></param>
 public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Camera camera)
 {
     foreach (AnimatedSprite sprite in SpriteList)
     {
         sprite.Draw(gameTime, spriteBatch, camera);
     }
 }