Exemple #1
0
 public Player(Game game, Character character)
 {
     gameRef = (Game1)game;
     camera = new Camera(gameRef.ScreenRectangle);
     this.character = character;
     Sprite.Position = new Vector2(1000, 1000);
 }
Exemple #2
0
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Camera camera)
        {
            map.Draw(spriteBatch, camera);

            foreach (Character character in characters)
                character.Draw(gameTime, spriteBatch);

            foreach (ItemSprite sprite in chests)
                sprite.Draw(gameTime, spriteBatch);
        }
Exemple #3
0
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Camera camera)
        {
            tileMap.Draw(spriteBatch, camera);
            foreach (Character c in Characters)
            {
                c.Draw(gameTime, spriteBatch);
            }

            foreach (ItemSprite chest in Chests)
            {
                chest.Draw(gameTime, spriteBatch);
            }
        }
Exemple #4
0
        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.ViewPortRectangle.Width) * (1 / camera.Zoom),
                    (camera.Position.Y + camera.ViewPortRectangle.Height) * (1 / camera.Zoom)));

            Point min = new Point();
            Point max = new Point();

            min.X = Math.Max(0, cameraPoint.X - 1);
            min.Y = Math.Max(0, cameraPoint.Y - 1);
            max.X = Math.Max(viewPoint.X + 1, Width);
            max.Y = Math.Max(viewPoint.Y + 1, Height);

            Rectangle 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);
                }
            }
        }
Exemple #5
0
        public void Draw(SpriteBatch spriteBatch, Camera camera)
        {
            var destination = new Rectangle(0, 0, Engine.TileWidth, Engine.TileHeight);

            foreach (var layer in _mapLayers) {
                for (var y = 0; y < layer.Height; y++) {
                    destination.Y = (int) (y * Engine.TileHeight - camera.Position.Y);
                    for (var x = 0; x < layer.Width; x++) {
                        var tile = layer.GetTile(x, y);
                        if (tile.TileIndex == -1 || tile.Tileset == -1) {
                            continue;
                        }
                        destination.X = (int) (x * Engine.TileWidth - camera.Position.X);

                        spriteBatch.Draw(
                            _tilesets[tile.Tileset].Texture,
                            destination,
                            _tilesets[tile.Tileset].SourceRectangles[tile.TileIndex],
                            Color.White);
                    }
                }
            }
        }
Exemple #6
0
 public void Draw(SpriteBatch spriteBatch, Camera camera)
 {
     foreach (MapLayer layer in mapLayers)
     {
         layer.Draw(spriteBatch, camera, tilesets);
     }
 }
Exemple #7
0
 public void DrawLevel(GameTime gameTime, SpriteBatch spriteBatch, Camera camera)
 {
     levels[currentLevel].Draw(gameTime, spriteBatch, camera);
 }
Exemple #8
0
        void mapDisplay_SizeChanged(object sender, EventArgs e)
        {
            Rectangle viewPort = new Rectangle(0, 0, mapDisplay.Width, mapDisplay.Height);
            Vector2 cameraPosition = camera.Position;

            camera = new Camera(viewPort, cameraPosition);
            camera.LockCamera();

            mapDisplay.Invalidate();
        }
Exemple #9
0
        void FormMain_Load(object sender, EventArgs e)
        {
            lbTileset.SelectedIndexChanged += new EventHandler(lbTileset_SelectedIndexChanged);
            nudCurrentTile.ValueChanged += new EventHandler(nudCurrentTile_ValueChanged);

            Rectangle viewPort = new Rectangle(0, 0, mapDisplay.Width, mapDisplay.Height);
            camera = new Camera(viewPort);

            engine = new Engine(32, 32);

            controlTimer.Tick += new EventHandler(controlTimer_Tick);
            controlTimer.Enabled = true;
            controlTimer.Interval = 17;

            tbMapLocation.TextAlign = HorizontalAlignment.Center;
            pbTilesetPreview.MouseDown += new MouseEventHandler(pbTilesetPreview_MouseDown);

            mapDisplay.SizeChanged += new EventHandler(mapDisplay_SizeChanged);
        }
Exemple #10
0
 public Player(Game game, Character character)
 {
     gameRef = (Game1)game;
     camera = new Camera(gameRef.ScreenRectangle);
     this.character = character;
 }
Exemple #11
0
 public Player(Game game, AnimatedSprite sprite)
 {
     gameRef = (Game1) game;
     camera = new Camera(gameRef.ScreenRectangle);
     this.sprite = sprite;
 }
Exemple #12
0
 public Player(Game game)
 {
     _gameRef = (Game1) game;
     Camera = new Camera(_gameRef.ScreenRectangle);
 }