Esempio n. 1
0
        public World(ArmorPotionsGame game)
        {
            _game = game;
            _projectiles = new List<Projectile>();
            _projectilesToAdd = new List<Projectile>();

            _player = new Player(this, _game.Content.Load<Texture2D>(@"Player\PlayerWalking"), _game.Content.Load<Texture2D>(@"Player\SwordAttack"));
            _player.Position = new Vector2(350, 350);

            Rectangle clientBounds = _game.Window.ClientBounds;
            _camera = new Camera(_game, 0, 0, clientBounds.Width, clientBounds.Height, 1f);
            _game.Components.Add(_camera);

            MaxTileWidth = clientBounds.Width / Tile.Width;
            MaxTileHeight = clientBounds.Height / Tile.Height;
        }
Esempio n. 2
0
        public Map(Tile[,] mapTop, Tile[,] mapBottom, List<Enemy> enemies, World world)
        {
            _tileMaps = new List<Tile[,]>();
            _tileMaps.Add(mapBottom);
            _tileMaps.Add(mapTop);

            _enemies = enemies;

            if (mapTop.GetLength(0) != mapBottom.GetLength(0) || mapBottom.GetLength(1) != mapTop.GetLength(1))
                throw new Exception("Invalid map lengths.");

            _width = mapTop.GetLength(0) - 1;
            _height = mapBottom.GetLength(1) - 1;

            _world = world;
            _camera = _world.Camera;
        }
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Vector2 position, Camera camera, float textureScale)
        {
            Rectangle currentRect = _animations[_currentAnimation].CurrentFrameRect;
            Rectangle tempRect = new Rectangle(
                currentRect.X + (int)camera.CameraX,
                currentRect.Y + (int)camera.CameraY,
                currentRect.Width,
                currentRect.Height);

            spriteBatch.Draw(
                _texture,
                new Vector2(position.X * camera.Scale, position.Y * camera.Scale),
                currentRect,
                _tintColor,
                0,
                Vector2.Zero,
                camera.Scale + textureScale,
                SpriteEffects.None,
                0);
        }
 public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Vector2 position, Camera camera)
 {
     this.Draw(gameTime, spriteBatch, position, camera, 0);
 }