Пример #1
0
 //SAFELY sets the value of a clicked tile based on the currently selected tile in the editor
 public void Set(int y, int x, Tile currentTile)
 {
     if (!(x < 0 || y < 0))
     {
         tileMap[y, x] = currentTile;
     }
 }
Пример #2
0
        //Creates a new map based on the size of the screen
        public Map(GraphicsDevice graphics,Texture2D tileSheet)
        {
            height = graphics.DisplayMode.Height / size;
            width = graphics.DisplayMode.Width / size;

            tileMap = new Tile[height, width]; //Initializes the new map

            for (int y = 0; y < height; y++)  //Defaults all values to -1 (saves processing time)
                for (int x = 0; x < width; x++)
                    tileMap[y, x] = null;
            for (int x = 0; x < width; x++) //Better put a floor down!
                tileMap[12, x] = new Tile(tileSheet, new Rectangle(size*1,size*0,size,size),Tile.COLLIDES_WITH_TOP);
            for (int y = 13; y < height; y++)  //Fill everything under the floor so it looks nice
                for (int x = 0; x < width; x++)
                    tileMap[y, x] = new Tile(tileSheet, new Rectangle(size * 1, size * 1, size, size), Tile.SOLID_BLOCK);
        }