Stores the appearance and collision behavior of a tile.
Esempio n. 1
0
        public Tile getTile(int x, int y)
        {
            Tile tile = null;

            // Prevent escaping past the level ends.
            if (x < 0 || x >= Width)
                tile = new Tile(new Sprite(null, Tile.Width, Tile.Height), TileCollision.Impassable);

            // Allow jumping past the level top and falling through the bottom.
            if(y < 0 || y >= Height)
                tile = new Tile(new Sprite(null, Tile.Width, Tile.Height), TileCollision.Passable);

            if (tile == null)
                tile = tiles[x, y];

            return tile;
        }
Esempio n. 2
0
 /// <summary>
 /// Adds a tile into the tile array.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="newTile"></param>
 public void addTile(int x, int y, Tile newTile)
 {
     newTile.Sprite.Position = new Vector2(x * Tile.Width, y * Tile.Height);
     tiles[x, y] = newTile;
 }