Beispiel #1
0
        protected override void Initialize()
        {
            // Character

            character = new Character(Content.Load<Texture2D>("character_stand"),
                new Vector2(100,100), new Vector2(1f,1f), new Vector2(64,128));

            // Tiles
            var blockTexture = Content.Load<Texture2D>("glowy_tile_multicolor");

            tileMap = new TileMap(new Vector2(64, 64), blockTexture);

            tileMap.AddNewLayer();
            var layer = tileMap.GetTileLayerByIndex(0);

            var rnd = new Random();
            for (int x = 0; x < graphics.GraphicsDevice.Viewport.Width / 64 + 1; x++)
            {
                for (int y = 0; y < graphics.GraphicsDevice.Viewport.Height / 64 + 1; y++)
                {
                    var animation = new TileAnimation(blockTexture, new Vector2(512, 512), rnd.Next(200, 500));
                    layer.AddNewTileToLayer(new Vector2(64, 64), new Vector2(x * 64, y* 64), Color.White, blockTexture, animation);
                }
            }

            base.Initialize();
        }
Beispiel #2
0
 public Tile(Vector2 size, Vector2 screenPosition, Color color, Texture2D texture, TileAnimation animation)
 {
     _size = size;
     _screenPosition = screenPosition;
     _color = color;
     _animation = animation;
     _texture = texture;
     _currentFrameTextureBounds = GetBounds();
 }
Beispiel #3
0
 public Tile()
 {
     _size = Vector2.Zero;
     _screenPosition = Vector2.Zero;
     _color = Color.White;
     _animation = null;
     _currentFrameTextureBounds = Rectangle.Empty;
     _texture = null;
 }
Beispiel #4
0
 public void AddNewTileToLayer(Vector2 size, Vector2 screenPosition, Color color, Texture2D texture, TileAnimation animation)
 {
     var tile = new Tile(size, screenPosition, color, texture, animation);
     AddTileToLayer(tile);
 }