コード例 #1
0
ファイル: MapLayer.cs プロジェクト: Sharparam/DiseasedToast
        public void Draw(SpriteBatch spriteBatch, Camera camera, List<Tileset> tilesets)
        {
            Point cameraPoint = Engine.VectorToCell(camera.Position * (1 / camera.Zoom));
            Point viewPoint = Engine.VectorToCell(
                new Vector2((camera.Position.X + camera.Viewport.Width) * (1 / camera.Zoom),
                            (camera.Position.Y + camera.Viewport.Height) * (1 / camera.Zoom)));
            var min = new Point();
            var max = new Point();
            min.X = Math.Max(0, cameraPoint.X - 1);
            min.Y = Math.Max(0, cameraPoint.Y - 1);
            max.X = Math.Min(viewPoint.X + 1, Width);
            max.Y = Math.Min(viewPoint.Y + 1, Height);
            var destination = new Rectangle(0, 0, Engine.TileWidth, Engine.TileHeight);
            Tile tile;

            for (int y = min.Y; y < max.Y; y++)
            {
                destination.Y = y * Engine.TileHeight;
                for (int x = min.X; x < max.X; x++)
                {
                    tile = GetTile(x, y);
                    if (tile.TileIndex == -1 || tile.Tileset == -1)
                        continue;

                    destination.X = x * Engine.TileWidth;
                    spriteBatch.Draw(
                        tilesets[tile.Tileset].Texture,
                        destination,
                        tilesets[tile.Tileset].SourceRectangles[tile.TileIndex],
                        Color.White);
                }
            }
        }
コード例 #2
0
ファイル: Level.cs プロジェクト: Sharparam/DiseasedToast
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Camera camera)
        {
            _map.Draw(spriteBatch, camera);

            foreach (var c in _characters)
                c.Draw(gameTime, spriteBatch);

            foreach (var s in _containers)
                s.Draw(gameTime, spriteBatch);
        }
コード例 #3
0
ファイル: Player.cs プロジェクト: Sharparam/DiseasedToast
        public Player(MainGame game, Character character)
        {
            _gameRef = game;
            _camera = new Camera(_gameRef.ScreenRectangle, ControlsManager.Controls);
            _char = character;
            _mapSize = new Point(0, 0);
            _camera.SetMapSize(_mapSize.X, _mapSize.Y);

            LogManager.GetLogger(this).Debug("Player object created.");
        }
コード例 #4
0
ファイル: World.cs プロジェクト: Sharparam/DiseasedToast
 public void DrawLevel(GameTime gameTime, SpriteBatch spriteBatch, Camera camera)
 {
     _currentLevel.Draw(gameTime, spriteBatch, camera);
 }
コード例 #5
0
ファイル: TileMap.cs プロジェクト: Sharparam/DiseasedToast
 public void Draw(SpriteBatch spriteBatch, Camera camera)
 {
     foreach (var layer in _mapLayers)
         layer.Draw(spriteBatch, camera, _tilesets);
 }